CMS 3D CMS Logo

IgPluginFactory.h

Go to the documentation of this file.
00001 #ifndef IGUANA_FRAMEWORK_IG_PLUGIN_DB_VIEW_H
00002 # define IGUANA_FRAMEWORK_IG_PLUGIN_DB_VIEW_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "Iguana/Framework/interface/IgMapUniqueIterator.h"
00007 # include "Iguana/Framework/interface/IgPluginFactoryBase.h"
00008 # include "Iguana/Framework/interface/IgModuleDef.h"
00009 # include "Iguana/Framework/interface/IgModule.h"
00010 # include "classlib/utils/DebugAids.h"
00011 # include <map>
00012 
00013 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00014 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00015 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00016 
00055 template <class Proto> class IgPluginFactory;
00056 template <class Proto> class IgPluginFactoryImpl;
00057 template <class Proto> class IgPluginFactoryImplTypes;
00058 template <class Types> class IgPluginFactoryImplBase;
00059 
00060 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00061 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00062 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00063 
00067 // Specialisations of IgPluginInfo for various argument combinations.  Up
00068 // to three arguments are supported now.  Arbitrary many *could* be
00069 // supported, it's just a question of tedious work to make it happen.
00070 // (See boost absolute and total preprocessor abuse package for another
00071 // solution that scales up to 256 arguments -- it results in totally
00072 // incomprehensible code, both before and after expansion.)
00073 //
00074 // The IgPluginFactoryImplTypes defines helper types needed to implement
00075 // a particular plug-in factory kind.  The template argument is a
00076 // function prototype (return value and argument list), or just "void"
00077 // for factory that never creates anything, only loads modules.
00078 template <>
00079 class IgPluginFactoryImplTypes<void>
00080 {
00081 public:
00082     class Info : public IgPluginInfo
00083     {
00084     public:
00085         Info (IgModule *module, const std::string &name, const std::string &tag);
00086         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00087         ~Info (void);
00088     };
00089 };
00090 
00091 template <class R>
00092 class IgPluginFactoryImplTypes<R * (void)>
00093 {
00094 public:
00095     typedef R Object;
00096     class Factory {
00097     public:
00098         virtual ~Factory (void);
00099         virtual R *create (void) = 0;
00100     };
00101 
00102     template <class T> class AutoFactory : public Factory
00103     {
00104     public:
00105         virtual R *create (void);
00106     };
00107 
00108     class Info : public IgPluginInfo
00109     {
00110     public:
00111         Info (IgModule *module, const std::string &name, const std::string &tag);
00112         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00113         ~Info (void);
00114 
00115         R *             create (void);
00116         void            attach (Factory *factory);
00117         virtual void    detach (void);
00118         
00119 
00120     private:
00121         Factory *       factory (void) const;
00122         Factory         *m_factory;     /*< Factory for creating instances
00123                                             of this type, set when the
00124                                             module is attached.  */
00125     };
00126 };
00127 
00129 template <class R, class T1>
00130 class IgPluginFactoryImplTypes<R * (T1)>
00131 {
00132 public:
00133     typedef R Object;
00134     class Factory {
00135     public:
00136         virtual ~Factory (void);
00137         virtual R *create (T1 a1) = 0;
00138     };
00139 
00140     template <class T> class AutoFactory : public Factory
00141     {
00142     public:
00143         virtual R *create (T1 a1);
00144     };
00145 
00146     class Info : public IgPluginInfo
00147     {
00148     public:
00149         Info (IgModule *module, const std::string &name, const std::string &tag);
00150         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00151         ~Info (void);
00152 
00153         R *             create (T1 a1);
00154         void            attach (Factory *factory);
00155         virtual void    detach (void);
00156 
00157     private:
00158         Factory *       factory (void) const;
00159         Factory         *m_factory;     /*< Factory for creating instances
00160                                             of this type, set when the
00161                                             module is attached.  */
00162     };
00163 };
00164 
00166 template <class R, class T1, class T2>
00167 class IgPluginFactoryImplTypes<R * (T1, T2)>
00168 {
00169 public:
00170     typedef R Object;
00171     class Factory {
00172     public:
00173         virtual ~Factory (void);
00174         virtual R *create (T1 a1, T2 a2) = 0;
00175     };
00176 
00177     template <class T> class AutoFactory : public Factory
00178     {
00179     public:
00180         virtual R *create (T1 a1, T2 a2);
00181     };
00182 
00183     class Info : public IgPluginInfo
00184     {
00185     public:
00186         Info (IgModule *module, const std::string &name, const std::string &tag);
00187         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00188         ~Info (void);
00189 
00190         R *             create (T1 a1, T2 a2);
00191         void            attach (Factory *factory);
00192         virtual void    detach (void);
00193 
00194     private:
00195         Factory *       factory (void) const;
00196         Factory         *m_factory;     /*< Factory for creating instances
00197                                             of this type, set when the
00198                                             module is attached.  */
00199     };
00200 };
00201 
00203 template <class R, class T1, class T2, class T3>
00204 class IgPluginFactoryImplTypes<R * (T1, T2, T3)>
00205 {
00206 public:
00207     typedef R Object;
00208     class Factory {
00209     public:
00210         virtual ~Factory (void);
00211         virtual R *create (T1 a1, T2 a2, T3 a3) = 0;
00212     };
00213 
00214     template <class T> class AutoFactory : public Factory
00215     {
00216     public:
00217         virtual R *create (T1 a1, T2 a2, T3 a3);
00218     };
00219 
00220     class Info : public IgPluginInfo
00221     {
00222     public:
00223         Info (IgModule *module, const std::string &name, const std::string &tag);
00224         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00225         ~Info (void);
00226 
00227         R *             create (T1 a1, T2 a2, T3 a3);
00228         void            attach (Factory *factory);
00229         virtual void    detach (void);
00230 
00231     private:
00232         Factory *       factory (void) const;
00233         Factory         *m_factory;     /*< Factory for creating instances
00234                                             of this type, set when the
00235                                             module is attached.  */
00236     };
00237 };
00238 
00240 template <class R, class T1, class T2, class T3, class T4>
00241 class IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>
00242 {
00243 public:
00244     typedef R Object;
00245     class Factory {
00246     public:
00247         virtual ~Factory (void);
00248         virtual R *create (T1 a1, T2 a2, T3 a3, T4 a4) = 0;
00249     };
00250 
00251     template <class T> class AutoFactory : public Factory
00252     {
00253     public:
00254         virtual R *create (T1 a1, T2 a2, T3 a3, T4 a4);
00255     };
00256 
00257     class Info : public IgPluginInfo
00258     {
00259     public:
00260         Info (IgModule *module, const std::string &name, const std::string &tag);
00261         Info (IgModule *module, IgModuleDescriptor *details, const std::string &tag);
00262         ~Info (void);
00263 
00264         R *             create (T1 a1, T2 a2, T3 a3, T4 a4);
00265         void            attach (Factory *factory);
00266         virtual void    detach (void);
00267 
00268     private:
00269         Factory *       factory (void) const;
00270         Factory         *m_factory;     /*< Factory for creating instances
00271                                             of this type, set when the
00272                                             module is attached.  */
00273     };
00274 };
00275 
00279 // Definition on the main factory implementation base class.  This
00280 // class defines all the utilities for maintaining info objects,
00281 // including their declarations from modules, but includes no support
00282 // for creating objects or accessing object factories.
00283 
00284 template <class Types>
00285 class IgPluginFactoryImplBase : public IgPluginFactoryBase
00286 {
00287 public:
00289     typedef typename Types::Info                Info;
00290 
00295     typedef std::multimap<std::string, Info *>  Map;
00296 
00298     typedef typename Map::value_type            MapValue;
00299 
00303     typedef IgMapUniqueIterator<Map>            Iterator;
00304 
00305     IgPluginFactoryImplBase (const std::string &tag);
00306     ~IgPluginFactoryImplBase (void);
00307 
00308     Iterator            begin (void) const;
00309     Iterator            end (void) const;
00310     Iterator            locate (const std::string &name) const;
00311     Info *              info (const std::string &name) const;
00312 
00313     virtual void        declare (IgModuleDef *def, std::string name);
00314 
00315     // Notifications from IgPluginManager.
00316     virtual void        rebuild (void);
00317     virtual void        restore (IgModule *module, IgModuleDescriptor *info);
00318     virtual void        addInfo (IgPluginInfo *info);
00319     virtual void        removeInfo (IgPluginInfo *info);
00320 
00321 private:
00322     Map                 m_map;
00323 };
00324 
00328 // Intermediate implementation base class for factories that actually
00329 // instantiate objects.  Adds factories atop IgPluginFactoryImplBase.
00330 
00331 template <class Proto>
00332 class IgPluginFactoryImpl
00333     : public IgPluginFactoryImplBase< IgPluginFactoryImplTypes<Proto> >
00334 {
00335 public:
00337     typedef IgPluginFactoryImplTypes<Proto>     Types;
00338 
00340     typedef typename Types::Object              Object;
00341 
00343     typedef typename Types::Factory             Factory;
00344 
00346     typedef typename Types::Info                Info;
00347 
00348     IgPluginFactoryImpl (const std::string &name);
00349 
00350     virtual void        installFactory (IgModuleDef *def,
00351                                         std::string name,
00352                                         Factory *factory);
00353 };
00354 
00356 // Custom specialisation for "void", i.e. no factory.
00357 
00358 template <>
00359 class IgPluginFactoryImpl<void>
00360     : public IgPluginFactoryImplBase< IgPluginFactoryImplTypes<void> >
00361 {
00362 public:
00363     typedef IgPluginFactoryImplTypes<void>      Types;
00364 
00365     IgPluginFactoryImpl (const std::string &name);
00366 };
00367 
00371 // Final client-visible factory base classes, specialised for various
00372 // constructor argument types.  These add the actual load()/create()
00373 // method signatures and thus have a specialisation for every possible
00374 // number of arguments (currently zero to three; see above for comments
00375 // on why this is not expanded to more arguments).
00376 
00377 template <>
00378 class IgPluginFactory<void> : public IgPluginFactoryImpl<void>
00379 {
00380 public:
00381     IgPluginFactory (const std::string &name);
00382 
00383     virtual void        load (Iterator info) const;
00384     virtual void        load (const std::string &name) const;
00385 };
00386 
00388 template <class R>
00389 class IgPluginFactory<R * (void)> : public IgPluginFactoryImpl<R * (void)>
00390 {
00391  public:
00392     typedef typename IgPluginFactoryImpl<R * (void)>::Iterator Iterator;
00393     IgPluginFactory (const std::string &name);
00394 
00395     virtual R *         create (Iterator info) const;
00396     virtual R *         create (const std::string &name) const;
00397 };
00398 
00400 template <class R, class T1>
00401 class IgPluginFactory<R * (T1)> : public IgPluginFactoryImpl<R * (T1)>
00402 {
00403  public:
00404     typedef typename IgPluginFactoryImpl<R * (T1)>::Iterator Iterator;
00405     IgPluginFactory (const std::string &name);
00406 
00407     virtual R *         create (const std::string &name, T1 a1) const;
00408     virtual R *         create (Iterator item, T1 a1) const;
00409 };
00410 
00412 template <class R, class T1, class T2>
00413 class IgPluginFactory<R * (T1, T2)> : public IgPluginFactoryImpl<R * (T1, T2)>
00414 {
00415  public:
00416     typedef typename IgPluginFactoryImpl<R * (T1, T2)>::Iterator Iterator;
00417     IgPluginFactory (const std::string &name);
00418 
00419     virtual R *         create (const std::string &name, T1 a1, T2 a2) const;
00420     virtual R *         create (Iterator item, T1 a1, T2 a2) const;
00421 };
00422 
00424 template <class R, class T1, class T2, class T3>
00425 class IgPluginFactory<R * (T1, T2, T3)> : public IgPluginFactoryImpl<R * (T1, T2, T3)>
00426 {
00427  public:
00428     typedef typename IgPluginFactoryImpl<R * (T1, T2, T3)>::Iterator Iterator;
00429     IgPluginFactory (const std::string &name);
00430 
00431     virtual R *         create (const std::string &name, T1 a1, T2 a2, T3 a3) const;
00432     virtual R *         create (Iterator item, T1 a1, T2 a2, T3 a3) const;
00433 };
00434 
00436 template <class R, class T1, class T2, class T3, class T4>
00437 class IgPluginFactory<R * (T1, T2, T3, T4)> : public IgPluginFactoryImpl<R * (T1, T2, T3, T4)>
00438 {
00439  public:
00440     typedef typename IgPluginFactoryImpl<R * (T1, T2, T3, T4)>::Iterator Iterator;
00441     IgPluginFactory (const std::string &name);
00442 
00443     virtual R *         create (const std::string &name, T1 a1, T2 a2, T3 a3, T4 a4) const;
00444     virtual R *         create (Iterator item, T1 a1, T2 a2, T3 a3, T4 a4) const;
00445 };
00446 
00448 template <class I>
00449 class IgPluginFactory : public IgPluginFactoryBase
00450 {
00451 public:
00452     typedef I                                   Info;
00453 
00454     typedef typename I::Factory                 Factory;
00455 
00456     typedef std::multimap<std::string, Info *>  Map;
00457 
00458     typedef typename Map::value_type            MapValue;
00459  
00460     typedef IgMapUniqueIterator<Map>            Iterator;
00461 
00462     IgPluginFactory (const std::string &tag);
00463     ~IgPluginFactory (void);
00464 
00465     Iterator            begin (void) const;
00466     Iterator            end (void) const;
00467     Iterator            locate (const std::string &name) const;
00468     Info *              info (const std::string &name) const;
00469 
00470     virtual void        declare (IgModuleDef *def, std::string name);
00471     virtual void        installFactory (IgModuleDef *def,
00472                                         std::string name,
00473                                         Factory *factory);
00474 
00475     virtual void        rebuild (void);
00476     virtual void        restore (IgModule *module, IgModuleDescriptor *info);
00477     virtual void        addInfo (IgPluginInfo *info);
00478     virtual void        removeInfo (IgPluginInfo *info);
00479 
00480 private:
00481     Map                 m_map;
00482 };
00483 
00484 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00485 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00486 
00490 
00495 template <class Types>
00496 inline
00497 IgPluginFactoryImplBase<Types>::IgPluginFactoryImplBase (const std::string &tag)
00498     : IgPluginFactoryBase (tag)
00499 {
00500     ASSERT (! tag.empty ());
00501     rebuild ();
00502 }
00503 
00505 template <class Types>
00506 inline
00507 IgPluginFactoryImplBase<Types>::~IgPluginFactoryImplBase (void)
00508 {
00509     // Remove all my infos.
00510     while (! m_map.empty ())
00511         delete m_map.begin ()->second;
00512 }
00513 
00514 template <class Types>
00515 inline typename IgPluginFactoryImplBase<Types>::Iterator
00516 IgPluginFactoryImplBase<Types>::begin (void) const
00517 { return Iterator (m_map.begin (), &m_map); }
00518 
00519 template <class Types>
00520 inline typename IgPluginFactoryImplBase<Types>::Iterator
00521 IgPluginFactoryImplBase<Types>::end (void) const
00522 { return Iterator (m_map.end (), &m_map); }
00523 
00524 template <class Types>
00525 inline typename IgPluginFactoryImplBase<Types>::Iterator
00526 IgPluginFactoryImplBase<Types>::locate (const std::string &name) const
00527 { return Iterator (m_map.find (name), &m_map); }
00528 
00529 template <class Types>
00530 inline typename IgPluginFactoryImplBase<Types>::Info *
00531 IgPluginFactoryImplBase<Types>::info (const std::string &name) const
00532 { Iterator pos (locate (name)); return pos != end () ? *pos : 0; }
00533 
00534 template <class Types>
00535 inline void
00536 IgPluginFactoryImplBase<Types>::declare (IgModuleDef *def, std::string name)
00537 {
00538     // This will eventually come back to us, see comments in add().
00539     ASSERT (def);
00540     ASSERT (def->module ());
00541     ASSERT (! name.empty ());
00542     new Info (def->module (), name, category ());
00543 }
00544 
00545 template <class Types>
00546 inline void
00547 IgPluginFactoryImplBase<Types>::rebuild (void)
00548 {
00549     // First remove all my infos
00550     while (! m_map.empty ())
00551         delete m_map.begin ()->second;
00552 
00553     // And now regenerate them from cache contents
00554     IgPluginFactoryBase::rebuild ();
00555 }
00556 
00557 template <class Types>
00558 inline void
00559 IgPluginFactoryImplBase<Types>::restore (IgModule *module, IgModuleDescriptor *info)
00560 {
00561     // The info item registers itself in the module on creation,
00562     // causing IgPluginManager to be notified, and us getting notified
00563     // again via addInfo() below.  On exit the info item already
00564     // exists in our map.
00565     new Info (module, info, category ());
00566 }
00567 
00568 template <class Types>
00569 inline void
00570 IgPluginFactoryImplBase<Types>::addInfo (IgPluginInfo *info)
00571 {
00572     // We insert entries in a multi-map because similar entries might
00573     // get inserted from multiple modules.  When modules are removed
00574     // we still have a list of previous choices.  The infos are used
00575     // in the order inserted, relying on the knowledge that IgPluginManager
00576     // always processes modules in preference order, i.e. first those
00577     // earlier in the search path, putting them first on our map's
00578     // list of values.
00579     ASSERT (dynamic_cast<Info *> (info));
00580     m_map.insert (MapValue (info->name (), static_cast<Info *> (info)));
00581 }
00582 
00583 template <class Types>
00584 inline void
00585 IgPluginFactoryImplBase<Types>::removeInfo (IgPluginInfo *info)
00586 {
00587     // Remove the info from the appropriate position.
00588     typename Map::iterator pos = m_map.find (info->name ());
00589     while (pos != m_map.end ()
00590            && pos->first == info->name ()
00591            && pos->second != info)
00592         ++pos;
00593 
00594     ASSERT (pos != m_map.end ());
00595     ASSERT (pos->second == info);
00596     m_map.erase (pos);
00597 }
00598 
00602 template <class Proto>
00603 inline
00604 IgPluginFactoryImpl<Proto>::IgPluginFactoryImpl (const std::string &tag)
00605     : IgPluginFactoryImplBase<Types> (tag)
00606 {}
00607 
00608 template <class Proto>
00609 inline void
00610 IgPluginFactoryImpl<Proto>::installFactory (IgModuleDef *def,
00611                                             std::string name,
00612                                             Factory *factory)
00613 {
00614     ASSERT (def);
00615 
00616     Info *info = this->info (name);
00617 
00618     ASSERT (info);
00619     ASSERT (info->module ());
00620     ASSERT (info->module () == def->module ());
00621     ASSERT (! info->name ().empty ());
00622     ASSERT (info->name () == name);
00623     ASSERT (factory);
00624 
00625     info->attach (factory);
00626 }
00627 
00631 inline
00632 IgPluginFactoryImpl<void>::IgPluginFactoryImpl (const std::string &tag)
00633     : IgPluginFactoryImplBase<Types> (tag)
00634 {}
00635 
00639 inline
00640 IgPluginFactory<void>::IgPluginFactory (const std::string &tag)
00641     : IgPluginFactoryImpl<void> (tag)
00642 {}
00643 
00644 inline void
00645 IgPluginFactory<void>::load (Iterator info) const
00646 { if (info != this->end ()) (*info)->module ()->attach (); }
00647 
00648 inline void
00649 IgPluginFactory<void>::load (const std::string &name) const
00650 { load (this->locate (name)); }
00651 
00655 template <class R>
00656 inline
00657 IgPluginFactory<R * (void)>::IgPluginFactory (const std::string &tag)
00658     : IgPluginFactoryImpl<R * (void)> (tag)
00659 {}
00660 
00661 template <class R>
00662 inline R *
00663 IgPluginFactory<R * (void)>::create (Iterator info) const
00664 { return info == this->end () ? 0 : (*info)->create (); }
00665 
00666 template <class R>
00667 inline R *
00668 IgPluginFactory<R * (void)>::create (const std::string &name) const
00669 { return create (this->locate (name)); }
00670 
00674 template <class R, class T1>
00675 inline
00676 IgPluginFactory<R * (T1)>::IgPluginFactory (const std::string &tag)
00677     : IgPluginFactoryImpl<R * (T1)> (tag)
00678 {}
00679 
00680 template <class R, class T1>
00681 inline R *
00682 IgPluginFactory<R * (T1)>::create (Iterator info, T1 a1) const
00683 { return info == this->end () ? 0 : (*info)->create (a1); }
00684 
00685 template <class R, class T1>
00686 inline R *
00687 IgPluginFactory<R * (T1)>::create (const std::string &name, T1 a1) const
00688 { return create (this->locate (name), a1); }
00689 
00693 template <class R, class T1, class T2>
00694 inline
00695 IgPluginFactory<R * (T1, T2)>::IgPluginFactory (const std::string &tag)
00696     : IgPluginFactoryImpl<R * (T1, T2)> (tag)
00697 {}
00698 
00699 template <class R, class T1, class T2>
00700 inline R *
00701 IgPluginFactory<R * (T1, T2)>::create (Iterator info, T1 a1, T2 a2) const
00702 { return info == this->end () ? 0 : (*info)->create (a1, a2); }
00703 
00704 template <class R, class T1, class T2>
00705 inline R *
00706 IgPluginFactory<R * (T1, T2)>::create (const std::string &name, T1 a1, T2 a2) const
00707 { return create (this->locate (name), a1, a2); }
00708 
00712 template <class R, class T1, class T2, class T3>
00713 inline
00714 IgPluginFactory<R * (T1, T2, T3)>::IgPluginFactory (const std::string &tag)
00715     : IgPluginFactoryImpl<R * (T1, T2, T3)> (tag)
00716 {}
00717 
00718 template <class R, class T1, class T2, class T3>
00719 inline R *
00720 IgPluginFactory<R * (T1, T2, T3)>::create (Iterator info, T1 a1, T2 a2, T3 a3) const
00721 { return info == this->end () ? 0 : (*info)->create (a1, a2, a3); }
00722 
00723 template <class R, class T1, class T2, class T3>
00724 inline R *
00725 IgPluginFactory<R * (T1, T2, T3)>::create (const std::string &name, T1 a1, T2 a2, T3 a3) const
00726 { return create (this->locate (name), a1, a2, a3); }
00727 
00731 template <class R, class T1, class T2, class T3, class T4>
00732 inline
00733 IgPluginFactory<R * (T1, T2, T3, T4)>::IgPluginFactory (const std::string &tag)
00734     : IgPluginFactoryImpl<R * (T1, T2, T3, T4)> (tag)
00735 {}
00736 
00737 template <class R, class T1, class T2, class T3, class T4>
00738 inline R *
00739 IgPluginFactory<R * (T1, T2, T3, T4)>::create (Iterator info, T1 a1, T2 a2, T3 a3, T4 a4) const
00740 { return info == this->end () ? 0 : (*info)->create (a1, a2, a3, a4); }
00741 
00742 template <class R, class T1, class T2, class T3, class T4>
00743 inline R *
00744 IgPluginFactory<R * (T1, T2, T3, T4)>::create (const std::string &name, T1 a1, T2 a2, T3 a3, T4 a4) const
00745 { return create (this->locate (name), a1, a2, a3, a4); }
00746 
00750 inline
00751 IgPluginFactoryImplTypes<void>::Info::Info (IgModule *module,
00752                                             const std::string &name,
00753                                             const std::string &tag)
00754     : IgPluginInfo (module, name, tag)
00755 { finish (true); }
00756 
00757 inline
00758 IgPluginFactoryImplTypes<void>::Info::Info (IgModule *module,
00759                                             IgModuleDescriptor *details,
00760                                             const std::string &tag)
00761     : IgPluginInfo (module, details->token (1), tag)
00762 { ASSERT (details->tokens () == 2); finish (false); }
00763 
00764 inline
00765 IgPluginFactoryImplTypes<void>::Info::~Info (void)
00766 { detach (); }
00767 
00769 template <class R>
00770 inline
00771 IgPluginFactoryImplTypes<R * (void)>::Factory::~Factory (void)
00772 {}
00773 
00774 template <class R>
00775 template <class T>
00776 inline R *
00777 IgPluginFactoryImplTypes<R * (void)>::AutoFactory<T>::create (void)
00778 { return new T; }
00779 
00780 template <class R>
00781 inline
00782 IgPluginFactoryImplTypes<R * (void)>::Info::Info (IgModule *module,
00783                                                   const std::string &name,
00784                                                   const std::string &tag)
00785     : IgPluginInfo (module, name, tag),
00786       m_factory (0)
00787 { finish (true); }
00788 
00789 template <class R>
00790 inline
00791 IgPluginFactoryImplTypes<R * (void)>::Info::Info (IgModule *module,
00792                                                   IgModuleDescriptor *details,
00793                                                   const std::string &tag)
00794     : IgPluginInfo (module, details->token (1), tag),
00795       m_factory (0)
00796 { ASSERT (details->tokens () == 2); finish (false); }
00797 
00798 template <class R>
00799 inline
00800 IgPluginFactoryImplTypes<R * (void)>::Info::~Info (void)
00801 { detach (); }
00802 
00803 template <class R>
00804 inline R *
00805 IgPluginFactoryImplTypes<R * (void)>::Info::create (void)
00806 {
00807     ASSERT (module ());
00808     ASSERT (! name ().empty ());
00809     return factory ()->create ();
00810 }
00811 
00812 template <class R>
00813 inline void
00814 IgPluginFactoryImplTypes<R * (void)>::Info::attach (Factory *factory)
00815 {
00816     ASSERT (module ());
00817     ASSERT (! name ().empty ());
00818     ASSERT (! m_factory);
00819     ASSERT (factory); 
00820     m_factory = factory;
00821 }
00822 
00823 template <class R>
00824 inline void
00825 IgPluginFactoryImplTypes<R * (void)>::Info::detach (void)
00826 {
00827     ASSERT (module ());
00828     ASSERT (! name ().empty ());
00829     delete m_factory;
00830     m_factory = 0;
00831 }
00832 
00833 template <class R>
00834 inline typename IgPluginFactoryImplTypes<R * (void)>::Factory *
00835 IgPluginFactoryImplTypes<R * (void)>::Info::factory (void) const
00836 {
00837     ASSERT (module ());
00838     ASSERT (! name ().empty ());
00839 
00840     if (! m_factory)
00841         module ()->attach ();
00842 
00843     if (! m_factory)
00844         noFactory ();
00845 
00846     return m_factory;
00847 }
00848 
00850 template <class R, class T1>
00851 inline
00852 IgPluginFactoryImplTypes<R * (T1)>::Factory::~Factory (void)
00853 {}
00854 
00855 template <class R, class T1>
00856 template <class T>
00857 inline R *
00858 IgPluginFactoryImplTypes<R * (T1)>::AutoFactory<T>::create (T1 a1)
00859 { return new T (a1); }
00860 
00861 template <class R, class T1>
00862 inline
00863 IgPluginFactoryImplTypes<R * (T1)>::Info::Info (IgModule *module,
00864                                                 const std::string &name,
00865                                                 const std::string &tag)
00866     : IgPluginInfo (module, name, tag),
00867       m_factory (0)
00868 { finish (true); }
00869 
00870 template <class R, class T1>
00871 inline
00872 IgPluginFactoryImplTypes<R * (T1)>::Info::Info (IgModule *module,
00873                                                 IgModuleDescriptor *details,
00874                                                 const std::string &tag)
00875     : IgPluginInfo (module, details->token (1), tag),
00876       m_factory (0)
00877 { ASSERT (details->tokens () == 2); finish (false); }
00878 
00879 template <class R, class T1>
00880 inline
00881 IgPluginFactoryImplTypes<R * (T1)>::Info::~Info (void)
00882 { detach (); }
00883 
00884 template <class R, class T1>
00885 inline R *
00886 IgPluginFactoryImplTypes<R * (T1)>::Info::create (T1 a1)
00887 {
00888     ASSERT (module ());
00889     ASSERT (! name ().empty ());
00890     return factory ()->create (a1);
00891 }
00892 
00893 template <class R, class T1>
00894 inline void
00895 IgPluginFactoryImplTypes<R * (T1)>::Info::attach (Factory *factory)
00896 {
00897     ASSERT (module ());
00898     ASSERT (! name ().empty ());
00899     ASSERT (! m_factory);
00900     ASSERT (factory); 
00901     m_factory = factory;
00902 }
00903 
00904 template <class R, class T1>
00905 inline void
00906 IgPluginFactoryImplTypes<R * (T1)>::Info::detach (void)
00907 {
00908     ASSERT (module ());
00909     ASSERT (! name ().empty ());
00910     delete m_factory;
00911     m_factory = 0;
00912 }
00913 
00914 template <class R, class T1>
00915 inline typename IgPluginFactoryImplTypes<R * (T1)>::Factory *
00916 IgPluginFactoryImplTypes<R * (T1)>::Info::factory (void) const
00917 {
00918     ASSERT (module ());
00919     ASSERT (! name ().empty ());
00920 
00921     if (! m_factory)
00922         module ()->attach ();
00923 
00924     if (! m_factory)
00925         noFactory ();
00926 
00927     return m_factory;
00928 }
00929 
00931 template <class R, class T1, class T2>
00932 inline
00933 IgPluginFactoryImplTypes<R * (T1, T2)>::Factory::~Factory (void)
00934 {}
00935 
00936 template <class R, class T1, class T2>
00937 template <class T>
00938 inline R *
00939 IgPluginFactoryImplTypes<R * (T1, T2)>::AutoFactory<T>::create (T1 a1, T2 a2)
00940 { return new T (a1, a2); }
00941 
00942 template <class R, class T1, class T2>
00943 inline
00944 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::Info (IgModule *module,
00945                                                     const std::string &name,
00946                                                     const std::string &tag)
00947     : IgPluginInfo (module, name, tag),
00948       m_factory (0)
00949 { finish (true); }
00950 
00951 template <class R, class T1, class T2>
00952 inline
00953 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::Info (IgModule *module,
00954                                                     IgModuleDescriptor *details,
00955                                                     const std::string &tag)
00956     : IgPluginInfo (module, details->token (1), tag),
00957       m_factory (0)
00958 { ASSERT (details->tokens () == 2); finish (false); }
00959 
00960 template <class R, class T1, class T2>
00961 inline
00962 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::~Info (void)
00963 { detach (); }
00964 
00965 template <class R, class T1, class T2>
00966 inline R *
00967 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::create (T1 a1, T2 a2)
00968 {
00969     ASSERT (module ());
00970     ASSERT (! name ().empty ());
00971     return factory ()->create (a1, a2);
00972 }
00973 
00974 template <class R, class T1, class T2>
00975 inline void
00976 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::attach (Factory *factory)
00977 {
00978     ASSERT (module ());
00979     ASSERT (! name ().empty ());
00980     ASSERT (! m_factory);
00981     ASSERT (factory); 
00982     m_factory = factory;
00983 }
00984 
00985 template <class R, class T1, class T2>
00986 inline void
00987 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::detach (void)
00988 {
00989     ASSERT (module ());
00990     ASSERT (! name ().empty ());
00991     delete m_factory;
00992     m_factory = 0;
00993 }
00994 
00995 template <class R, class T1, class T2>
00996 inline typename IgPluginFactoryImplTypes<R * (T1, T2)>::Factory *
00997 IgPluginFactoryImplTypes<R * (T1, T2)>::Info::factory (void) const
00998 {
00999     ASSERT (module ());
01000     ASSERT (! name ().empty ());
01001 
01002     if (! m_factory)
01003         module ()->attach ();
01004 
01005     if (! m_factory)
01006         noFactory ();
01007 
01008     return m_factory;
01009 }
01010 
01012 template <class R, class T1, class T2, class T3>
01013 inline
01014 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Factory::~Factory (void)
01015 {}
01016 
01017 template <class R, class T1, class T2, class T3>
01018 template <class T>
01019 inline R *
01020 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::AutoFactory<T>::create (T1 a1, T2 a2, T3 a3)
01021 { return new T (a1, a2, a3); }
01022 
01023 template <class R, class T1, class T2, class T3>
01024 inline
01025 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::Info (IgModule *module,
01026                                                         const std::string &name,
01027                                                         const std::string &tag)
01028     : IgPluginInfo (module, name, tag),
01029       m_factory (0)
01030 { finish (true); }
01031 
01032 template <class R, class T1, class T2, class T3>
01033 inline
01034 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::Info (IgModule *module,
01035                                                         IgModuleDescriptor *details,
01036                                                         const std::string &tag)
01037     : IgPluginInfo (module, details->token (1), tag),
01038       m_factory (0)
01039 { ASSERT (details->tokens () == 2); finish (false); }
01040 
01041 template <class R, class T1, class T2, class T3>
01042 inline
01043 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::~Info (void)
01044 { detach (); }
01045 
01046 template <class R, class T1, class T2, class T3>
01047 inline R *
01048 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::create (T1 a1, T2 a2, T3 a3)
01049 {
01050     ASSERT (module ());
01051     ASSERT (! name ().empty ());
01052     return factory ()->create (a1, a2, a3);
01053 }
01054 
01055 template <class R, class T1, class T2, class T3>
01056 inline void
01057 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::attach (Factory *factory)
01058 {
01059     ASSERT (module ());
01060     ASSERT (! name ().empty ());
01061     ASSERT (! m_factory);
01062     ASSERT (factory); 
01063     m_factory = factory;
01064 }
01065 
01066 template <class R, class T1, class T2, class T3>
01067 inline void
01068 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::detach (void)
01069 {
01070     ASSERT (module ());
01071     ASSERT (! name ().empty ());
01072     delete m_factory;
01073     m_factory = 0;
01074 }
01075 
01076 template <class R, class T1, class T2, class T3>
01077 inline typename IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Factory *
01078 IgPluginFactoryImplTypes<R * (T1, T2, T3)>::Info::factory (void) const
01079 {
01080     ASSERT (module ());
01081     ASSERT (! name ().empty ());
01082 
01083     if (! m_factory)
01084         module ()->attach ();
01085 
01086     if (! m_factory)
01087         noFactory ();
01088 
01089     return m_factory;
01090 }
01091 
01093 template <class R, class T1, class T2, class T3, class T4>
01094 inline
01095 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Factory::~Factory (void)
01096 {}
01097 
01098 template <class R, class T1, class T2, class T3, class T4>
01099 template <class T>
01100 inline R *
01101 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::AutoFactory<T>::create (T1 a1, T2 a2, T3 a3, T4 a4)
01102 { return new T (a1, a2, a3, a4); }
01103 
01104 template <class R, class T1, class T2, class T3, class T4>
01105 inline
01106 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::Info (IgModule *module,
01107                                                             const std::string &name,
01108                                                             const std::string &tag)
01109     : IgPluginInfo (module, name, tag),
01110       m_factory (0)
01111 { finish (true); }
01112 
01113 template <class R, class T1, class T2, class T3, class T4>
01114 inline
01115 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::Info (IgModule *module,
01116                                                             IgModuleDescriptor *details,
01117                                                             const std::string &tag)
01118     : IgPluginInfo (module, details->token (1), tag),
01119       m_factory (0)
01120 { ASSERT (details->tokens () == 2); finish (false); }
01121 
01122 template <class R, class T1, class T2, class T3, class T4>
01123 inline
01124 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::~Info (void)
01125 { detach (); }
01126 
01127 template <class R, class T1, class T2, class T3, class T4>
01128 inline R *
01129 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::create (T1 a1, T2 a2, T3 a3, T4 a4)
01130 {
01131     ASSERT (module ());
01132     ASSERT (! name ().empty ());
01133     return factory ()->create (a1, a2, a3, a4);
01134 }
01135 
01136 template <class R, class T1, class T2, class T3, class T4>
01137 inline void
01138 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::attach (Factory *factory)
01139 {
01140     ASSERT (module ());
01141     ASSERT (! name ().empty ());
01142     ASSERT (! m_factory);
01143     ASSERT (factory); 
01144     m_factory = factory;
01145 }
01146 
01147 template <class R, class T1, class T2, class T3, class T4>
01148 inline void
01149 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::detach (void)
01150 {
01151     ASSERT (module ());
01152     ASSERT (! name ().empty ());
01153     delete m_factory;
01154     m_factory = 0;
01155 }
01156 
01157 template <class R, class T1, class T2, class T3, class T4>
01158 inline typename IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Factory *
01159 IgPluginFactoryImplTypes<R * (T1, T2, T3, T4)>::Info::factory (void) const
01160 {
01161     ASSERT (module ());
01162     ASSERT (! name ().empty ());
01163 
01164     if (! m_factory)
01165         module ()->attach ();
01166 
01167     if (! m_factory)
01168         noFactory ();
01169 
01170     return m_factory;
01171 }
01172 
01173 #endif // IGUANA_FRAMEWORK_IG_PLUGIN_DB_VIEW_H

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