libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/base/file_manager.hpp
Go to the documentation of this file.
00001 
00011 /*
00012  *  Copyright (C) 2008, 2009 Juan Pedro BolĂ­var Puente
00013  *
00014  *  This file is part of Psychosynth.
00015  *   
00016  *  Psychosynth is free software: you can redistribute it and/or modify
00017  *  it under the terms of the GNU General Public License as published by
00018  *  the Free Software Foundation, either version 3 of the License, or
00019  *  (at your option) any later version.
00020  *
00021  *  Psychosynth is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  You should have received a copy of the GNU General Public License
00027  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00028  *
00029  */
00030 
00031 #ifndef PSYNTH_FILEMANAGER_H
00032 #define PSYNTH_FILEMANAGER_H
00033 
00034 #include <psynth/base/file_finder.hpp>
00035 #include <psynth/base/tree.hpp>
00036 #include <psynth/base/singleton.hpp>
00037 
00038 namespace psynth
00039 {
00040 namespace base
00041 {
00042 
00049 class file_mgr_node : public file_finder,
00050                       public tree_node <file_mgr_node>,
00051                       public PSYNTH_DEFAULT_THREADING <file_mgr_node>,
00052                       public boost::noncopyable
00053 {
00054     friend class tree_node <file_mgr_node>;
00055     
00056 public:    
00057     template <class PathPredicate>
00058     void find_if_all (PathPredicate pred,
00059                       file_finder::path_list& res) const;
00060 
00061     boost::filesystem::path
00062     find_all (const boost::filesystem::path& file) const;
00063 };
00064 
00065 template<class StringPredicate>
00066 void file_mgr_node::find_if_all (StringPredicate pred,
00067                                  file_finder::path_list& res) const
00068 {
00069     lock lock (this);
00070     const_iterator it;
00071 
00072     res = find_if (pred, res);
00073     
00074     for (it = begin(); it != end(); ++it)
00075         it->find_if_all (pred, res);
00076 }
00077 
00078 typedef singleton_holder<file_mgr_node> file_manager;
00079 
00080 extern template class singleton_holder <file_mgr_node>;
00081 extern template class tree_node <file_mgr_node>;
00082 extern template class PSYNTH_DEFAULT_THREADING <file_mgr_node>;
00083 
00084 } /* namespace base */
00085 } /* namespace psynth */
00086 
00087 #endif /* PSYNTH_FILEMANAGER_H */