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

SpectrumFactory.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/FluxSvc/src/SpectrumFactory.h,v 1.4 2002/07/23 19:00:57 srobinsn Exp $
00002 
00003 #if !defined(AFX_SPECTRUMFACTORY_H__211C2F25_9111_44B9_B357_0762789222AF__INCLUDED_)
00004 #define AFX_SPECTRUMFACTORY_H__211C2F25_9111_44B9_B357_0762789222AF__INCLUDED_
00005 
00012 #if _MSC_VER > 1000
00013 #pragma once
00014 #endif // _MSC_VER > 1000
00015 
00016 #include "FluxSvc/ISpectrumFactory.h"
00017 #include "SpectrumFactoryTable.h"
00018 #include <typeinfo>
00019 #include <vector>
00020 
00021 
00022 template <class T> class SpectrumFactory : public ISpectrumFactory 
00023 {
00024 public:
00025     
00026     SpectrumFactory(){
00027         //Get class name using RTTI:
00028         std::string classname = typeid(T).name();
00029         int s = classname.find_first_of("class");
00030         if( s==0 ) s=6; //found it
00031         else s =classname.find_first_not_of("0123456789");
00032         classname = classname.substr(s);
00033         SpectrumFactoryTable::instance()->addFactory(classname, this); 
00034     }
00036     virtual ISpectrum* instantiate(const std::string& params) const{return new T(params);}
00037     
00039     virtual void addRef()const{}
00040 };
00041 
00042 
00043 
00044 #endif // !defined(AFX_SPECTRUMFACTORY_H__211C2F25_9111_44B9_B357_0762789222AF__INCLUDED_)

Generated on Wed Oct 16 14:01:31 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001