inlib
1.2.0
|
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved. 00002 // See the file inlib.license for terms. 00003 00004 #ifndef inlib_rroot_dummy 00005 #define inlib_rroot_dummy 00006 00007 // dummy class with a generic streamer. 00008 // It is used within the reading of a tree 00009 // to create some generic object when we get 00010 // from the file a class name which is unknown 00011 // from the tree factory. 00012 00013 //inheritance : 00014 #include "iro" 00015 00016 #include "buffer" 00017 #include "../scast" 00018 00019 namespace inlib { 00020 namespace rroot { 00021 00022 class dummy : public virtual iro { 00023 public: 00024 static const std::string& s_class() { 00025 static const std::string s_v("my_space::dummy"); 00026 return s_v; 00027 } 00028 public: //iro 00029 virtual void* cast(const std::string& a_class) const { 00030 if(void* p = cmp_cast<dummy>(this,a_class)) {return p;} 00031 else return 0; 00032 } 00033 virtual bool stream(buffer& a_buffer) { 00034 //the below code skips correctly the data in the file. 00035 uint32 startpos = a_buffer.length(); 00036 short v; 00037 unsigned int s,c; 00038 if(!a_buffer.read_version(v,s,c)) return false; 00039 a_buffer.set_offset(startpos+c+sizeof(unsigned int)); 00040 if(!a_buffer.check_byte_count(s,c,"dummy")) return false; 00041 return true; 00042 } 00043 public: 00044 dummy(){ 00045 #ifdef INLIB_MEM 00046 mem::increment(s_class().c_str()); 00047 #endif 00048 } 00049 virtual ~dummy(){ 00050 #ifdef INLIB_MEM 00051 mem::decrement(s_class().c_str()); 00052 #endif 00053 } 00054 public: 00055 dummy(const dummy& a_from): iro(a_from){ 00056 #ifdef INLIB_MEM 00057 mem::increment(s_class().c_str()); 00058 #endif 00059 } 00060 dummy& operator=(const dummy&){return *this;} 00061 }; 00062 00063 }} 00064 00065 #endif