emcCalFEMFactory.C

Go to the documentation of this file.
00001 #include "emcCalFEMFactory.h"
00002 #include "emcDefines.h"
00003 
00004 #include <string>
00005 #include <iostream>
00006 
00007 //_____________________________________________________________________________
00008 emcCalFEMFactory::CreatorMap&
00009 emcCalFEMFactory::fCreators()
00010 {
00011   static CreatorMap map_;
00012   return map_;
00013 }
00014 
00015 //_____________________________________________________________________________
00016 emcCalFEM*
00017 emcCalFEMFactory::Create(const char* category, int absPosition,
00018                          const PHTimeStamp& start, const PHTimeStamp& end)
00019 {
00020   return create(category,absPosition,start,end,false);
00021 }
00022 
00023 //_____________________________________________________________________________
00024 emcCalFEM*
00025 emcCalFEMFactory::create(const char* category,
00026                          int absPosition,
00027                          const PHTimeStamp& start,
00028                          const PHTimeStamp& end,
00029                          bool isDefault)
00030 {
00031   CreatorMap::iterator it = fCreators().find(category);
00032   if ( it != fCreators().end() )
00033     {
00034       return (it->second)(absPosition,start,end,isDefault);
00035     }
00036   else
00037     {
00038       std::cerr << "emcCalFEMFactory::create : I do not know this flavour :"
00039                 << category << std::endl;
00040       return 0;
00041     }
00042 }
00043 
00044 //_____________________________________________________________________________
00045 emcCalFEM* emcCalFEMFactory::CreateDefault(const char* category,
00046                                            int absPosition,
00047                                            const PHTimeStamp& start,
00048                                            const PHTimeStamp& end)
00049 {
00050   return create(category,absPosition,start,end,true);
00051 }
00052 
00053 //_____________________________________________________________________________
00054 void
00055 emcCalFEMFactory::print(std::ostream& os)
00056 {
00057   CreatorMap::iterator it;
00058   os << "emcCalFEMFactory: I know the following flavors:" << std::endl;
00059   for ( it = fCreators().begin(); it != fCreators().end(); ++it ) 
00060     {
00061       os << it->first << std::endl;
00062     }
00063 }
00064 
00065 //_____________________________________________________________________________
00066 bool
00067 emcCalFEMFactory::registerCreator(const char* category,
00068                                   emcCalFEMFactory::Creator creator)
00069 {
00070   return fCreators().insert(CreatorMap::value_type(category,creator)).second;
00071 }