VFSTreePopulator.h

Go to the documentation of this file.
00001 #ifndef VFSTREEPOPULATOR_H_
00002 #define VFSTREEPOPULATOR_H_
00003 
00004 #include <gtk/gtktreestore.h>
00005 
00006 #include <map>
00007 #include <string>
00008 #include <set>
00009 
00010 namespace gtkutil
00011 {
00012 
00031     class VFSTreePopulator
00032     {
00033             // The GtkTreeStore to populate
00034             GtkTreeStore* _store;
00035 
00036             // Toplevel node to add children under
00037             GtkTreeIter* _topLevel;
00038 
00039             // Maps of names to corresponding GtkTreeIter* nodes, for both intermediate
00040             // paths and explicitly presented paths
00041             typedef std::map<std::string, GtkTreeIter*> NamedIterMap;
00042             NamedIterMap _iters;
00043 
00044             // Set of paths that are passed in through addPath(), to distinguish them
00045             // from intermediate constructed paths
00046             std::set<std::string> _explicitPaths;
00047 
00048         private:
00049 
00050             // Main recursive add function. Accepts a VFS path and adds the new node,
00051             // calling itself if necessary to add all of the parent directories, then
00052             // returns a GtkTreeIter* pointing to the new node.
00053             GtkTreeIter* addRecursive (const std::string& path);
00054 
00055         public:
00056 
00068             VFSTreePopulator (GtkTreeStore* store, GtkTreeIter* toplevel = NULL);
00069 
00072             virtual ~VFSTreePopulator ();
00073 
00077             void addPath (const std::string& path);
00078 
00081             struct Visitor
00082             {
00083 
00100                     virtual void visit (GtkTreeStore* store, GtkTreeIter* iter, const std::string& path,
00101                             bool isExplicit) = 0;
00102             };
00103 
00107             void forEachNode (Visitor& visitor);
00108     };
00109 
00110 }
00111 
00112 #endif /*VFSTREEPOPULATOR_H_*/

Generated by  doxygen 1.6.2