Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsFileSystemTree.h
Go to the documentation of this file.
1 
13 #ifndef WS_FILESYSTEM_TREE_H__
14 #define WS_FILESYSTEM_TREE_H__
15 #define BOOST_FILESYSTEM_NO_DEPRECATED
16 #include <iostream>
17 
18 #include "WsAbstractNode.h"
19 #include "WsNode.h"
20 #include "WsDirNode.h"
21 #include "WsFileNode.h"
23 
24 #include <boost/thread/mutex.hpp>
25 #include <boost/shared_ptr.hpp>
26 
28 
29 typedef boost::shared_ptr<WsFileSystemTree> FileSystemTreePtr;
30 
31 
37 public:
43  WsFileSystemTree(const std::string& p, bool m = false);
44 
46 
51  int start();
52 
57  NodePtr getRoot();
58 
63  NodePtr eatPath(const std::string& p);
64 
68  int getUseCount();
69 
74  void incrementUseCount();
75 
79  void decrementUseCount();
80 
85  const boost::filesystem::path& getRootPath() const;
86 
90  std::vector<boost::filesystem::path>& getMonitorPaths();
91 
95  const std::string& getStamp();
96 
103  int insertNode(NodePtr newNode);
104 
105 private:
110  int applyFile(const boost::filesystem::path& filePath);
111 
116  int applyDirectory(const boost::filesystem::path& dirPath);
117 
121  void beginChild(const boost::filesystem::path& p);
122 
126  void endChild(const boost::filesystem::path& p);
127 
131  void createStamp();
132 
136  boost::filesystem::path m_rootPath;
137 
138  boost::mutex m_lMutex;
139 
143  std::vector<boost::filesystem::path> m_monitorPaths;
144 
148  std::string m_stamp;
149 
154 
155  /*
156  * Monitor with Gamin ?
157  */
158  bool m_monitor;
159 
164 
169 };
170 
171 #endif
const std::string & getStamp()
returns the Tree unique stamp
Abstract class used to crawl a directory.
Represents the file structure on disk.
boost::shared_ptr< WsAbstractNode > NodePtr
WsFileSystemTree(const std::string &p, bool m=false)
Constructor for the FileSystemTree object.
std::vector< boost::filesystem::path > m_monitorPaths
int start()
crawls the diretory and sorts the children. It is called by WsDirectoryCrawler::start() ...
NodePtr getRoot()
returns the root of the WsFileSystemTree
Fetch a directory and all subdirs.
boost::mutex m_lMutex
A dir node.
NodePtr eatPath(const std::string &p)
Node structure, must be inherited.
void endChild(const boost::filesystem::path &p)
this method is called when finished browsing the subdir
const boost::filesystem::path & getRootPath() const
returns the boost::filesystem::path to the base directory where documents are stored ...
int getUseCount()
returns the number of users that are using this fileSystemTree version
int applyDirectory(const boost::filesystem::path &dirPath)
this method is called by browse when the boost::filesystem::path is a folder
void incrementUseCount()
increments the number of uses of the tree by 1
boost::shared_ptr< WsFileSystemTree > FileSystemTreePtr
int applyFile(const boost::filesystem::path &filePath)
this method is called by browse when the boost::filesystem::path is a file
boost::filesystem::path m_rootPath
int insertNode(NodePtr newNode)
inserts the node in the tree The node is inserted on the right place on the tree depending on it's pa...
std::vector< boost::filesystem::path > & getMonitorPaths()
returns the std::vector containing the boost::filesystem::path that should be monitored by the WsUpda...
Abstract Node class.
void decrementUseCount()
decrements the numbers of uses by one
void createStamp()
creates unique stamp for the tree
void beginChild(const boost::filesystem::path &p)
this method is called before browsing a subdirectory