Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

IRegisterSource.h

Go to the documentation of this file.
00001 #ifndef _H_IRegisterSource
00002 #define _H_IRegisterSource
00003 
00004 // includes
00005 #include "GaudiKernel/IAlgTool.h"
00006 #include "flux/ISpectrumFactory.h"
00007 #include <typeinfo>
00008 
00009 
00010 #include "IFluxSvc.h"
00011 
00012 static const InterfaceID IID_IRegisterSource("IRegisterSource", 1 , 0); 
00013 
00014 
00079 class IRegisterSource : virtual public IAlgTool {
00080 public:
00082     static const InterfaceID& interfaceID() { return IID_IRegisterSource; }
00084     virtual StatusCode registerMe(IFluxSvc*) = 0;
00085 };
00086 
00087 template <class T> class RemoteSpectrumFactory : public ISpectrumFactory 
00088 {
00089 public:
00090     
00091     RemoteSpectrumFactory(IFluxSvc* svc){
00092         //Get class name using RTTI:
00093         std::string m_classname = typeid(T).name();
00094         int s = m_classname.find_first_of("class");
00095         if( s==0 ) s=6; //found it
00096         else s =m_classname.find_first_not_of("0123456789");
00097         m_classname = m_classname.substr(s);
00098         svc->addFactory(m_classname, this); 
00099     }
00105     virtual ISpectrum* instantiate(const std::string& params) const{
00106         return new T(params);
00107     }
00108     
00110     virtual void addRef()const{}
00111 
00112     std::string name()const{return m_classname;}
00113 private:
00114     std::string m_classname;
00115 };
00116 
00117 
00118 #endif  // _H_IRegisterSource

Generated on Thu Dec 4 07:57:37 2008 by doxygen 1.3.3