emcManageable.h

Go to the documentation of this file.
00001 #ifndef __EMCMANAGEABLE_H__
00002 #define __EMCMANAGEABLE_H__
00003 
00004 #ifndef __EMCNAMED_H__
00005 #include "emcNamed.h"
00006 #endif
00007 #include <string>
00008 
00009 class PHTimeStamp;
00010 
00023 class emcManageable : public emcNamed
00024 {
00025 
00026 public:
00027 
00029   enum EStorage {
00031     kNone = -1,
00033     kDB_Objy,
00035     kFile_ASCII,
00037     kDB_Construction,
00039     kDB_Pg
00040   };
00041 
00043   emcManageable() : emcNamed(), fDestination(kNone), fSource(kNone)
00044   {}
00045 
00047   emcManageable(const char* name, const char* title, const char* classname)
00048     : emcNamed(name, title, classname), fDestination(kNone), fSource(kNone)
00049   {}
00050 
00052   virtual ~emcManageable()
00053   {}
00054 
00056   emcManageable(const emcManageable& obj) : emcNamed()
00057   {
00058     obj.Copy(*this);
00059   }
00060 
00062   emcManageable& operator=(const emcManageable& obj)
00063   {
00064     if ( &obj != this )
00065       {
00066         obj.Copy(*this);
00067       }
00068     return *this;
00069   }
00070 
00075   virtual const char* GetCategory(void) const = 0;
00076 
00078   static const char* GetStorageName(emcManageable::EStorage storage)
00079   {
00080     if ( storage == emcManageable::kNone )
00081       return "None";
00082     if ( storage == emcManageable::kDB_Objy )
00083       return "Objy FD";
00084     if ( storage == emcManageable::kFile_ASCII )
00085       return "ASCII File";
00086     if ( storage == emcManageable::kDB_Construction )
00087       return "Construction DB";
00088     if ( storage == emcManageable::kDB_Pg )
00089       return "Pg";
00090 
00091     return "not valid";
00092   }
00093 
00095   static emcManageable::EStorage GetStorage(const char* storagename)
00096   {
00097     std::string name = storagename;
00098     if ( name == "Objy FD" || name == "Objy" || name == "Objectivity" )
00099       {
00100         return emcManageable::kDB_Objy;
00101       }
00102     else if ( name == "PostgreSQL" || name == "Pg" || name == "pg" )
00103       {
00104         return emcManageable::kDB_Pg;
00105       }
00106     else if ( name == "ASCII File" )
00107       {
00108         return emcManageable::kFile_ASCII;
00109       }
00110     else if ( name == "Construction DB" )
00111       {
00112         return emcManageable::kDB_Construction;
00113       }
00114     return emcManageable::kNone;
00115   }
00116 
00118   EStorage GetDestination(void) const
00119   {
00120     return fDestination;
00121   }
00122 
00124   EStorage GetSource(void) const
00125   {
00126     return fSource;
00127   }
00128 
00132   virtual bool IsValid(const PHTimeStamp& /*when*/) const
00133   {
00134     return false;
00135   }
00136 
00138   virtual void Reset(void)
00139   {}
00140 
00142   virtual void SetDestination(emcManageable::EStorage destination)
00143   {
00144     fDestination = destination;
00145   }
00146   
00148   virtual void SetSource(emcManageable::EStorage origine)
00149   {
00150     fSource = origine;
00151   }
00152 
00153  protected:
00154   
00155   void Copy(emcNamed& obj) const
00156   {
00157     emcManageable& man = static_cast<emcManageable&>(obj);
00158     emcNamed::Copy(obj);
00159     man.fSource = fSource;
00160     man.fDestination = fDestination;
00161   }
00162   
00163  private:
00164   EStorage fDestination;
00165   EStorage fSource;
00166 };
00167 
00168 #endif
00169 
00170 
00171 
00172 
00173