inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sg/field
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_sg_field
00005 #define inlib_sg_field
00006 
00007 #include <string>
00008 #include <ostream>
00009 
00010 #ifdef INLIB_MEM
00011 #include "../mem"
00012 #endif
00013 
00014 namespace inlib {
00015 namespace io {
00016 class iwbuf;
00017 class irbuf;
00018 }}
00019 
00020 namespace inlib {
00021 namespace sg {
00022 
00023 class field {
00024   static const std::string& s_class() {
00025     static const std::string s_v("inlib::sg::field");
00026     return s_v;
00027   }
00028 /*
00029   virtual void* cast(const std::string& a_class) const {
00030     if(void* p = inlib::cmp_cast<field>(this,a_class)) {return p;}
00031     else return 0;
00032   }
00033   virtual bool equal(const field&) const {return false;}
00034 */
00035 public:
00036   virtual bool write(io::iwbuf&) = 0;
00037   virtual bool read(io::irbuf&) = 0;
00038   virtual bool dump(std::ostream&) = 0;
00039 protected:
00040   field():m_touched(true){
00041 #ifdef INLIB_MEM
00042     mem::increment(s_class().c_str());
00043 #endif
00044   }
00045   virtual ~field(){
00046 #ifdef INLIB_MEM
00047     mem::decrement(s_class().c_str());
00048 #endif
00049   }
00050 protected:
00051   field(const field&):m_touched(true){
00052 #ifdef INLIB_MEM
00053     mem::increment(s_class().c_str());
00054 #endif
00055   }
00056   field& operator=(const field&){m_touched=false;return *this;}
00057 public:
00058   void touch() {m_touched = true;}
00059   bool touched() const {return m_touched;}
00060   void reset_touched() {m_touched = false;}
00061 protected:
00062   bool m_touched;
00063 };
00064 
00065 }}
00066 
00067 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines