QGlobalWriter.hh Go to the documentation of this file. 00001 #ifndef _Q_GLOBAL_WRITER_HH_
00002 #define _Q_GLOBAL_WRITER_HH_
00003
00027 #include "QCuore.hh"
00028 #include "QNamed.hh"
00029 #include "QError.hh "
00030 #include "QMessage.hh"
00031 #include "QGlobalRWFactory.hh "
00032 #include <string>
00033
00034
00035 namespace Cuore {class QObject ;}
00036 using namespace Cuore;
00037
00038
00039 class QGlobalWriter : public QNamed
00040 {
00041 public :
00043 QGlobalWriter (const std::string& name) : QNamed(name) {}
00044
00046 virtual ~QGlobalWriter () {}
00047
00049 virtual void SetQObject (const std::string& name, const QObject * obj);
00050
00052 virtual void SetTObject (const std::string& name, TObject* obj);
00053
00055 virtual void SetDouble (const std::string& name, double obj);
00056
00058 virtual void SetInt (const std::string& name, int obj);
00059
00061 virtual void SetFloat (const std::string& name, float obj);
00062
00064 virtual void SetBool (const std::string& name, bool obj );
00065
00067 virtual void SetString (const std::string& name, const std::string& obj);
00068
00069 protected :
00070
00072 virtual QError Open (const std::string& filename, const std::string& opt = "" ) = 0;
00073
00075 virtual QError Close () = 0;
00076
00077 friend class QGlobalWriterDispatcher ;
00078 };
00079
00085 class QGlobalWriterFactory {
00086 public :
00087 QGlobalWriterFactory (const std::string& name, const std::string& ext) {fName = name; fExt = ext;}
00088 const std::string& GetName() const { return fName;}
00089 const std::string& GetExt() const { return fExt;}
00090 virtual ~QGlobalWriterFactory () {};
00091 private :
00092 virtual QGlobalWriter * Create() = 0;
00093 std::string fName;
00094 std::string fExt;
00095 friend class QGlobalRWFactory ;
00096 };
00097
00098
00099 #define CREATE_GOLBAL_WRITER_IMPL(clazz, ext) \
00100 class clazz ## Factory: public QGlobalWriterFactory{\
00101 public:\
00102 clazz ## Factory() : QGlobalWriterFactory(#clazz,ext) {}\
00103 QGlobalWriter *Create(){ return new clazz; }\
00104 };
00105
00106 #define REGISTER_GLOBAL_WRITER(clazz, ext) \
00107 CREATE_GOLBAL_WRITER_IMPL(clazz, ext);\
00108 extern "C" void registerInFactory ## clazz() {\
00109 QGlobalWriterFactory* pt = new clazz ## Factory;\
00110 QGlobalRWFactory::GetInstance().RegisterGlobalWriter(pt);\
00111 }
00112
00113 #endif
In questo sito non sono utilizzati cookie per la profilazione degli utenti. Utilizza cookie di sessione, necessari per il corretto funzionamento dello stesso e per gestire l'autenticazione ai servizi on-line, alla intranet e alle aree riservate...
leggi tutto Più info OK