Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/sf_enum is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_sf_enum
0005 #define tools_sg_sf_enum
0006 
0007 #include "sf"
0008 
0009 namespace tools {
0010 namespace sg {
0011 
0012 class bsf_enum {
0013 public:
0014   TOOLS_SCLASS(tools::sg::bsf_enum);
0015   virtual void* cast(const std::string& a_class) const {
0016     if(void* p = cmp_cast<bsf_enum>(this,a_class)) {return p;}
0017     return 0;
0018   }
0019   virtual const std::string& s_cls() const {return s_class();}
0020 public:
0021   virtual void set_value(int) = 0;
0022 public:
0023   bsf_enum(){}
0024   virtual ~bsf_enum(){}
0025 public:
0026   bsf_enum(const bsf_enum&){}
0027   bsf_enum& operator=(const bsf_enum&){return *this;}
0028 };
0029 
0030 template <class T>
0031 class sf_enum : public bsf<T>, public bsf_enum {
0032   typedef bsf<T> parent;
0033 public:
0034   TOOLS_T_SCLASS(T,tools::sg::sf_enum);
0035   virtual void* cast(const std::string& a_class) const {
0036    {if(void* p = cmp_cast< sf_enum<T> >(this,a_class)) {return p;}}
0037    {if(void* p = bsf_enum::cast(a_class)) {return p;}}
0038     return parent::cast(a_class);
0039   }
0040   virtual const std::string& s_cls() const {return s_class();}
0041 public:
0042   virtual bool write(io::iwbuf& a_buffer) {
0043     return a_buffer.write((int16)parent::m_value);
0044   }
0045   virtual bool read(io::irbuf& a_buffer) {
0046     int16 v;
0047     if(!a_buffer.read(v)) return false;
0048     parent::m_value = (T)v;
0049     return true;
0050   }
0051   virtual bool dump(std::ostream&) {
0052     //a_out << parent::m_value << std::endl;
0053     return true;
0054   }
0055   virtual bool s_value(std::string& a_s) const {a_s.clear();return false;}
0056   virtual bool s2value(const std::string&) {return false;}
0057 public:
0058   virtual void set_value(int a_value) {parent::value(T(a_value));}
0059 public:
0060   sf_enum():parent(),bsf_enum(){}
0061   sf_enum(const T& a_value):parent(a_value),bsf_enum(){}
0062   virtual ~sf_enum(){}
0063 public:
0064   sf_enum(const sf_enum& a_from):parent(a_from),bsf_enum(a_from){}
0065   sf_enum& operator=(const sf_enum& a_from){
0066     parent::operator=(a_from);
0067     return *this;
0068   }
0069 public:
0070   sf_enum& operator=(const T& a_value){
0071     parent::operator=(a_value);
0072     return *this;
0073   }
0074 };
0075 
0076 }}
0077 
0078 #endif