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

ISpectrumFactory.h

Go to the documentation of this file.
00001 
00012 #if !defined(AFX_ISPECTRUMFACTORY_H__10BF6F57_E416_4B69_A7CF_220E55281676__INCLUDED_)
00013 #define AFX_ISPECTRUMFACTORY_H__10BF6F57_E416_4B69_A7CF_220E55281676__INCLUDED_
00014 
00015 #if _MSC_VER > 1000
00016 #pragma once
00017 #endif // _MSC_VER > 1000
00018 #include "FluxSvc/ISpectrum.h"
00019 #include "FluxSvc/IFluxSvc.h"
00020 
00021 #include <typeinfo>
00022 #include <vector>
00023 
00024 class ISpectrumFactory
00025 {
00026 public:
00027     
00029     virtual ISpectrum* instantiate(const std::string& params)const=0;
00030     
00032     virtual void addRef()const=0;
00033     
00034 };
00035 
00036 
00037 template <class T> class RemoteSpectrumFactory : public ISpectrumFactory 
00038 {
00039 public:
00040     
00041     RemoteSpectrumFactory(IFluxSvc* svc){
00042         //Get class name using RTTI:
00043         std::string classname = typeid(T).name();
00044         int s = classname.find_first_of("class");
00045         if( s==0 ) s=6; //found it
00046         else s =classname.find_first_not_of("0123456789");
00047         classname = classname.substr(s);
00048         svc->addFactory(classname, this); 
00049     }
00051     virtual ISpectrum* instantiate(const std::string& params) const{return new T(params);}
00052     
00054     virtual void addRef()const{}
00055 };
00056 
00057 
00058 #endif // !defined(AFX_ISPECTRUMFACTORY_H__10BF6F57_E416_4B69_A7CF_220E55281676__INCLUDED_)

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