CMS 3D CMS Logo

IgPluginFactoryBase.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/Framework/interface/IgPluginFactoryBase.h"
00004 #include "Iguana/Framework/interface/IgPluginManager.h"
00005 #include "Iguana/Framework/interface/IgModuleDescriptor.h"
00006 #include "Iguana/Framework/interface/IgModuleCache.h"
00007 #include "Iguana/Framework/interface/IgModule.h"
00008 #include "classlib/utils/DebugAids.h"
00009 
00010 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00018 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00019 
00020 IgPluginFactoryBase::IgPluginFactoryBase (const std::string &tag)
00021     : m_tag (tag)
00022 {
00023     ASSERT (IgPluginManager::get ());
00024     ASSERT (! m_tag.empty ());
00025     IgPluginManager::get ()->addFactory (this);
00026 }
00027 
00028 IgPluginFactoryBase::~IgPluginFactoryBase (void)
00029 {
00030     ASSERT (IgPluginManager::get ());
00031     ASSERT (! m_tag.empty ());
00032     IgPluginManager::get ()->removeFactory (this);
00033 }
00034 
00035 const std::string &
00036 IgPluginFactoryBase::category (void) const
00037 { return m_tag; }
00038 
00039 void
00040 IgPluginFactoryBase::rebuild (void)
00041 {
00042     IgPluginManager                     *db = IgPluginManager::get ();
00043     IgPluginManager::DirectoryIterator  dir;
00044     IgModuleCache::Iterator             module;
00045     IgModuleDescriptor                  *cache;
00046     unsigned                            i;
00047 
00048     // The modules cannot have infos already cached that we need to
00049     // avoid recreating.  This is because the infos can be created
00050     // only in one of two ways, and in either case the factory knows
00051     // *and* has already cleared out those infos in the derived
00052     // rebuild() before invoking us.  Infos restored from the cache
00053     // are managed by the factory, and thus the known and already
00054     // deleted.  When infos are created via the factory's describe()
00055     // method, the factory must already exist and thus the infos are
00056     // automatically registered (and thus already deleted).  The
00057     // latter is because the factory must be in the same library as the
00058     // one invoking describe(), or one of its dependents; either way
00059     // since the factory is a global object, it has been constructed (the
00060     // query happens after global constructors).
00061     //
00062     // Which brings us back to the point: there cannot be infos we
00063     // care about at this point.  As we start, the derived factory has no
00064     // infos (guaranteed by derived rebuild()), so the only infos that
00065     // exist are those we create here below.
00066     for (dir = db->beginDirectories (); dir != db->endDirectories (); ++dir)
00067         for (module = (*dir)->begin (); module != (*dir)->end (); ++module)
00068             for (cache=(*module)->cacheRoot(), i=0; i < cache->children(); ++i)
00069                 if (cache->child (i)->token (0) == category ())
00070                     restore (*module, cache->child (i));
00071 }

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