CMS 3D CMS Logo

IgModuleCache.h

Go to the documentation of this file.
00001 #ifndef IGUANA_FRAMEWORK_IG_MODULE_CACHE_H
00002 # define IGUANA_FRAMEWORK_IG_MODULE_CACHE_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "Iguana/Framework/interface/config.h"
00007 # include "classlib/iobase/Filename.h"
00008 # include <iosfwd>
00009 # include <utility>
00010 # include <string>
00011 # include <list>
00012 
00013 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00014 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00015 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00016 
00017 class IgPluginManager;
00018 class IgModuleDescriptor;
00019 class IgModule;
00020 
00021 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00022 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00023 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00024 
00068 class IgModuleCache
00069 {
00071     typedef std::list<IgModule *>       ModuleList;
00073     typedef ModuleList::iterator        ModuleIterator;
00074 
00075 public:
00077     typedef ModuleList::const_iterator          Iterator;
00078 
00079     IgModuleCache (IgPluginManager *manager, const lat::Filename &directory);
00080     ~IgModuleCache (void);
00081 
00082     // cache definition
00083     IgPluginManager *   manager (void) const;
00084     lat::Filename       directory (void) const;
00085 
00086     // cache management
00087     void                refresh (void);
00088 
00089     // module access
00090     Iterator            begin (void) const;
00091     Iterator            end (void) const;
00092 
00093 protected:
00094     void                load (void);
00095     void                rebuild (void);
00096     void                notify (void);
00097     void                update (void);
00098 
00099 private:
00100     struct CacheContext;
00101     struct ParseContext;
00102     class FileByName;
00103 
00104     friend struct CacheContext;
00105     friend struct ParseContext;
00106     friend class FileByName;
00107 
00109     enum CacheStatus {
00110         CACHE_MISSING   = 1,            //< No cache
00111         CACHE_OLD       = 2,            //< Cache exists but is outdated
00112         CACHE_VALID     = 3             //< Cache exists and is up-to-date
00113     };
00114 
00116     struct CacheContext {
00117         CacheStatus     status  : 3;    //< Cache status
00118         bool            added   : 1;    //< Flag for new modules
00119         bool            removed : 1;    //< Flag for removed modules
00120         bool            changed : 1;    //< Flag for changed modules
00121         bool            skipped : 1;    //< Flag for skipped modules or files
00122     };
00123 
00127     struct ParseContext {
00128         ModuleList      result;         //< Reconstructed read result
00129         IgModule        *module;        //< Parse stack: current module spec
00130     };
00131 
00132     bool                parse (const lat::Filename &filename,
00133                                IgModuleDescriptor *root = 0);
00134     static IgModuleDescriptor *makeBad (const std::string &file,
00135                                       const std::string &time);
00136     CacheStatus         scanModules (ModuleList &cache);
00137     void                reconstruct (IgModuleDescriptor *info);
00138     void                write (std::ostream &s,
00139                                IgModuleDescriptor *doc,
00140                                int level = 0);
00141 
00142     IgPluginManager     *m_manager;     //< Manager that owns this cache
00143     lat::Filename       m_directory;    //< Module directory
00144     ModuleList          m_cache;        //< Raw cache contents
00145     CacheContext        m_state;        //< Cache status flags
00146     ParseContext        m_parse;        //< Parsing working storage
00147     ModuleList          m_modules;      //< List of modules in this directory
00148 
00149     static const char   s_cacheFile []; //< Cache file name
00150     static const char   s_cacheTag [];  //< Descriptor tag for the cache root
00151     static const char   s_fileTag [];   //< Descriptor tag for the file tree
00152     static const char   s_moduleTag []; //< Descriptor tag for a module tree
00153 };
00154 
00155 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00156 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00157 
00158 #endif // IGUANA_FRAMEWORK_IG_MODULE_CACHE_H

Generated on Tue Jun 9 17:38:19 2009 for CMSSW by  doxygen 1.5.4