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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/rroot/named (Version 11.3.0) and /externals/g4tools/include/tools/rroot/named (Version 11.1.1)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_rroot_named                           4 #ifndef tools_rroot_named
  5 #define tools_rroot_named                           5 #define tools_rroot_named
  6                                                     6 
  7 #include "object"                                   7 #include "object"
  8 #include "../scast"                                 8 #include "../scast"
  9 #include "../vdata"                                 9 #include "../vdata"
 10 #include "cids"                                    10 #include "cids"
 11                                                    11 
 12 namespace tools {                                  12 namespace tools {
 13 namespace rroot {                                  13 namespace rroot {
 14                                                    14 
 15 inline bool Named_stream(buffer& a_buffer,std:     15 inline bool Named_stream(buffer& a_buffer,std::string& a_name,std::string& a_title) {
 16   short v;                                         16   short v;
 17   unsigned int _s, _c;                             17   unsigned int _s, _c;
 18   if(!a_buffer.read_version(v,_s,_c)) return f     18   if(!a_buffer.read_version(v,_s,_c)) return false;
 19  {uint32 id,bits;                                  19  {uint32 id,bits;
 20   if(!Object_stream(a_buffer,id,bits)) return      20   if(!Object_stream(a_buffer,id,bits)) return false;}
 21   if(!a_buffer.read(a_name)) return false;         21   if(!a_buffer.read(a_name)) return false;
 22   if(!a_buffer.read(a_title)) return false;        22   if(!a_buffer.read(a_title)) return false;
 23   if(!a_buffer.check_byte_count(_s,_c,"TNamed"     23   if(!a_buffer.check_byte_count(_s,_c,"TNamed")) return false;
 24   return true;                                     24   return true;
 25 }                                                  25 }
 26                                                    26 
 27 inline bool AttLine_stream(buffer& a_buffer,sh     27 inline bool AttLine_stream(buffer& a_buffer,short& a_color,short& a_style,short& a_width){
 28   short v;                                         28   short v;
 29   unsigned int _s, _c;                             29   unsigned int _s, _c;
 30   if(!a_buffer.read_version(v,_s,_c)) return f     30   if(!a_buffer.read_version(v,_s,_c)) return false;
 31   if(!a_buffer.read(a_color)) return false;        31   if(!a_buffer.read(a_color)) return false;
 32   if(!a_buffer.read(a_style)) return false;        32   if(!a_buffer.read(a_style)) return false;
 33   if(!a_buffer.read(a_width)) return false;        33   if(!a_buffer.read(a_width)) return false;
 34   if(!a_buffer.check_byte_count(_s,_c,"TAttLin     34   if(!a_buffer.check_byte_count(_s,_c,"TAttLine")) return false;
 35   return true;                                     35   return true;
 36 }                                                  36 }
 37                                                    37 
 38 inline bool AttFill_stream(buffer& a_buffer,sh     38 inline bool AttFill_stream(buffer& a_buffer,short& a_color,short& a_style){
 39   short v;                                         39   short v;
 40   unsigned int _s, _c;                             40   unsigned int _s, _c;
 41   if(!a_buffer.read_version(v,_s,_c)) return f     41   if(!a_buffer.read_version(v,_s,_c)) return false;
 42   if(!a_buffer.read(a_color)) return false;        42   if(!a_buffer.read(a_color)) return false;
 43   if(!a_buffer.read(a_style)) return false;        43   if(!a_buffer.read(a_style)) return false;
 44   if(!a_buffer.check_byte_count(_s,_c,"TAttFil     44   if(!a_buffer.check_byte_count(_s,_c,"TAttFill")) return false;
 45   return true;                                     45   return true;
 46 }                                                  46 }
 47                                                    47 
 48 inline bool AttMarker_stream(buffer& a_buffer)     48 inline bool AttMarker_stream(buffer& a_buffer) {
 49   short fMarkerColor;                              49   short fMarkerColor;
 50   short fMarkerStyle;                              50   short fMarkerStyle;
 51   float fMarkerWidth;                              51   float fMarkerWidth;
 52   short v;                                         52   short v;
 53   unsigned int _s, _c;                             53   unsigned int _s, _c;
 54   if(!a_buffer.read_version(v,_s,_c)) return f     54   if(!a_buffer.read_version(v,_s,_c)) return false;
 55   if(!a_buffer.read(fMarkerColor)) return fals     55   if(!a_buffer.read(fMarkerColor)) return false;
 56   if(!a_buffer.read(fMarkerStyle)) return fals     56   if(!a_buffer.read(fMarkerStyle)) return false;
 57   if(!a_buffer.read(fMarkerWidth)) return fals     57   if(!a_buffer.read(fMarkerWidth)) return false;
 58   if(!a_buffer.check_byte_count(_s,_c,"TAttMar     58   if(!a_buffer.check_byte_count(_s,_c,"TAttMarker")) return false;
 59   return true;                                     59   return true;
 60 }                                                  60 }
 61                                                    61 
 62 inline bool GeoAtt_stream(buffer& a_buffer) {      62 inline bool GeoAtt_stream(buffer& a_buffer) {
 63   unsigned int fGeoAtt;            // option f     63   unsigned int fGeoAtt;            // option flags
 64   short v;                                         64   short v;
 65   unsigned int _s, _c;                             65   unsigned int _s, _c;
 66   if(!a_buffer.read_version(v,_s,_c)) return f     66   if(!a_buffer.read_version(v,_s,_c)) return false;
 67   if(!a_buffer.read(fGeoAtt)) return false;        67   if(!a_buffer.read(fGeoAtt)) return false;
 68   if(!a_buffer.check_byte_count(_s,_c,"TGeoAtt     68   if(!a_buffer.check_byte_count(_s,_c,"TGeoAtt")) return false;
 69   return true;                                     69   return true;
 70 }                                                  70 }
 71                                                    71 
 72 inline bool Att3D_stream(buffer& a_buffer) {       72 inline bool Att3D_stream(buffer& a_buffer) {
 73   short v;                                         73   short v;
 74   unsigned int _s, _c;                             74   unsigned int _s, _c;
 75   if(!a_buffer.read_version(v,_s,_c)) return f     75   if(!a_buffer.read_version(v,_s,_c)) return false;
 76   if(!a_buffer.check_byte_count(_s,_c,"TAtt3D"     76   if(!a_buffer.check_byte_count(_s,_c,"TAtt3D")) return false;
 77   return true;                                     77   return true;
 78 }                                                  78 }
 79                                                    79 
 80 template <class T>                                 80 template <class T>
 81 inline bool Array_stream(buffer& a_buffer,std:     81 inline bool Array_stream(buffer& a_buffer,std::vector<T>& a_v) {
 82   a_v.clear();                                     82   a_v.clear();
 83   int sz;                                          83   int sz;
 84   if(!a_buffer.read(sz)) return false;             84   if(!a_buffer.read(sz)) return false;
 85   //check sz is not crazy :                        85   //check sz is not crazy :
 86   if(!a_buffer.check_eob(sz)) return false;        86   if(!a_buffer.check_eob(sz)) return false;
 87   a_v.resize(sz);                                  87   a_v.resize(sz);
 88   if(!a_buffer.read_fast_array<T>(vec_data(a_v     88   if(!a_buffer.read_fast_array<T>(vec_data(a_v),sz)) return false;
 89   return true;                                     89   return true;
 90 }                                                  90 }
 91                                                    91 
 92 template <class T>                                 92 template <class T>
 93 inline bool dummy_array_stream(buffer& a_buffe     93 inline bool dummy_array_stream(buffer& a_buffer,int a_n){
 94   char is_array;                                   94   char is_array;
 95   if(!a_buffer.read(is_array)) return false;       95   if(!a_buffer.read(is_array)) return false;
 96   if(!is_array) return true;                       96   if(!is_array) return true;
 97   if(!a_n) return true;                            97   if(!a_n) return true;
 98   T* v = new T[a_n];                               98   T* v = new T[a_n];
 99   bool status = a_buffer.read_fast_array<T>(v,     99   bool status = a_buffer.read_fast_array<T>(v,a_n);
100   delete [] v;                                    100   delete [] v;
101   return status;                                  101   return status;
102 }                                                 102 }
103                                                   103 
104 class named : public virtual iro {                104 class named : public virtual iro {
105   static const std::string& s_store_class() {     105   static const std::string& s_store_class() {
106     static const std::string s_v("TNamed");       106     static const std::string s_v("TNamed");
107     return s_v;                                   107     return s_v;
108   }                                               108   }
109 public:                                           109 public:
110   static const std::string& s_class() {           110   static const std::string& s_class() {
111     static const std::string s_v("tools::rroot    111     static const std::string s_v("tools::rroot::named");
112     return s_v;                                   112     return s_v;
113   }                                               113   }
114 public: //iro                                     114 public: //iro
115   virtual void* cast(const std::string& a_clas    115   virtual void* cast(const std::string& a_class) const {
116     if(void* p = cmp_cast<named>(this,a_class)    116     if(void* p = cmp_cast<named>(this,a_class)) return p;
117     return 0;                                     117     return 0;
118   }                                               118   }
119   virtual const std::string& s_cls() const {re    119   virtual const std::string& s_cls() const {return s_class();}
120 public:                                           120 public:
121   static cid id_class() {return named_cid();}     121   static cid id_class() {return named_cid();}
122   virtual void* cast(cid a_class) const {         122   virtual void* cast(cid a_class) const {
123     if(void* p = cmp_cast<named>(this,a_class)    123     if(void* p = cmp_cast<named>(this,a_class)) {return p;}
124     else return 0;                                124     else return 0;
125   }                                               125   }
126   //virtual void* cast(cid) const {return name    126   //virtual void* cast(cid) const {return named_cid();}
127 public:                                           127 public:
128   virtual iro* copy() const {return new named(    128   virtual iro* copy() const {return new named(*this);}
129   virtual bool stream(buffer& a_buffer) {         129   virtual bool stream(buffer& a_buffer) {
130     return Named_stream(a_buffer,m_name,m_titl    130     return Named_stream(a_buffer,m_name,m_title);
131   }                                               131   }
132 public:                                           132 public:
133   named() {                                       133   named() {
134 #ifdef TOOLS_MEM                                  134 #ifdef TOOLS_MEM
135     mem::increment(s_class().c_str());            135     mem::increment(s_class().c_str());
136 #endif                                            136 #endif
137   }                                               137   }
138   virtual ~named() {                              138   virtual ~named() {
139 #ifdef TOOLS_MEM                                  139 #ifdef TOOLS_MEM
140     mem::decrement(s_class().c_str());            140     mem::decrement(s_class().c_str());
141 #endif                                            141 #endif
142   }                                               142   }
143 protected:                                        143 protected:
144   named(const named& a_from):iro(a_from),m_nam    144   named(const named& a_from):iro(a_from),m_name(a_from.m_name),m_title(a_from.m_title) {
145 #ifdef TOOLS_MEM                                  145 #ifdef TOOLS_MEM
146     mem::increment(s_class().c_str());            146     mem::increment(s_class().c_str());
147 #endif                                            147 #endif
148   }                                               148   }
149   named& operator=(const named& a_from){          149   named& operator=(const named& a_from){
150     m_name = a_from.m_name;                       150     m_name = a_from.m_name;
151     m_title = a_from.m_title;                     151     m_title = a_from.m_title;
152     return *this;                                 152     return *this;
153   }                                               153   }
154 protected:                                        154 protected:
155   std::string m_name;                             155   std::string m_name;
156   std::string m_title;                            156   std::string m_title;
157 };                                                157 };
158                                                   158 
159 }}                                                159 }}
160                                                   160 
161 #endif                                            161 #endif