00001
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
00028 std::string classname = typeid(T).name();
00029 int s = classname.find_first_of("class");
00030 if( s==0 ) s=6;
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_)