Warning, /include/Geant4/tools/rroot/named 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_rroot_named
0005 #define tools_rroot_named
0006
0007 #include "object"
0008 #include "../scast"
0009 #include "../vdata"
0010 #include "cids"
0011
0012 namespace tools {
0013 namespace rroot {
0014
0015 inline bool Named_stream(buffer& a_buffer,std::string& a_name,std::string& a_title) {
0016 short v;
0017 unsigned int _s, _c;
0018 if(!a_buffer.read_version(v,_s,_c)) return false;
0019 {uint32 id,bits;
0020 if(!Object_stream(a_buffer,id,bits)) return false;}
0021 if(!a_buffer.read(a_name)) return false;
0022 if(!a_buffer.read(a_title)) return false;
0023 if(!a_buffer.check_byte_count(_s,_c,"TNamed")) return false;
0024 return true;
0025 }
0026
0027 inline bool AttLine_stream(buffer& a_buffer,short& a_color,short& a_style,short& a_width){
0028 short v;
0029 unsigned int _s, _c;
0030 if(!a_buffer.read_version(v,_s,_c)) return false;
0031 if(!a_buffer.read(a_color)) return false;
0032 if(!a_buffer.read(a_style)) return false;
0033 if(!a_buffer.read(a_width)) return false;
0034 if(!a_buffer.check_byte_count(_s,_c,"TAttLine")) return false;
0035 return true;
0036 }
0037
0038 inline bool AttFill_stream(buffer& a_buffer,short& a_color,short& a_style){
0039 short v;
0040 unsigned int _s, _c;
0041 if(!a_buffer.read_version(v,_s,_c)) return false;
0042 if(!a_buffer.read(a_color)) return false;
0043 if(!a_buffer.read(a_style)) return false;
0044 if(!a_buffer.check_byte_count(_s,_c,"TAttFill")) return false;
0045 return true;
0046 }
0047
0048 inline bool AttMarker_stream(buffer& a_buffer) {
0049 short fMarkerColor;
0050 short fMarkerStyle;
0051 float fMarkerWidth;
0052 short v;
0053 unsigned int _s, _c;
0054 if(!a_buffer.read_version(v,_s,_c)) return false;
0055 if(!a_buffer.read(fMarkerColor)) return false;
0056 if(!a_buffer.read(fMarkerStyle)) return false;
0057 if(!a_buffer.read(fMarkerWidth)) return false;
0058 if(!a_buffer.check_byte_count(_s,_c,"TAttMarker")) return false;
0059 return true;
0060 }
0061
0062 inline bool GeoAtt_stream(buffer& a_buffer) {
0063 unsigned int fGeoAtt; // option flags
0064 short v;
0065 unsigned int _s, _c;
0066 if(!a_buffer.read_version(v,_s,_c)) return false;
0067 if(!a_buffer.read(fGeoAtt)) return false;
0068 if(!a_buffer.check_byte_count(_s,_c,"TGeoAtt")) return false;
0069 return true;
0070 }
0071
0072 inline bool Att3D_stream(buffer& a_buffer) {
0073 short v;
0074 unsigned int _s, _c;
0075 if(!a_buffer.read_version(v,_s,_c)) return false;
0076 if(!a_buffer.check_byte_count(_s,_c,"TAtt3D")) return false;
0077 return true;
0078 }
0079
0080 template <class T>
0081 inline bool Array_stream(buffer& a_buffer,std::vector<T>& a_v) {
0082 a_v.clear();
0083 int sz;
0084 if(!a_buffer.read(sz)) return false;
0085 //check sz is not crazy :
0086 if(!a_buffer.check_eob(sz)) return false;
0087 a_v.resize(sz);
0088 if(!a_buffer.read_fast_array<T>(vec_data(a_v),sz)) return false;
0089 return true;
0090 }
0091
0092 template <class T>
0093 inline bool dummy_array_stream(buffer& a_buffer,int a_n){
0094 char is_array;
0095 if(!a_buffer.read(is_array)) return false;
0096 if(!is_array) return true;
0097 if(!a_n) return true;
0098 T* v = new T[a_n];
0099 bool status = a_buffer.read_fast_array<T>(v,a_n);
0100 delete [] v;
0101 return status;
0102 }
0103
0104 class named : public virtual iro {
0105 static const std::string& s_store_class() {
0106 static const std::string s_v("TNamed");
0107 return s_v;
0108 }
0109 public:
0110 static const std::string& s_class() {
0111 static const std::string s_v("tools::rroot::named");
0112 return s_v;
0113 }
0114 public: //iro
0115 virtual void* cast(const std::string& a_class) const {
0116 if(void* p = cmp_cast<named>(this,a_class)) return p;
0117 return 0;
0118 }
0119 virtual const std::string& s_cls() const {return s_class();}
0120 public:
0121 static cid id_class() {return named_cid();}
0122 virtual void* cast(cid a_class) const {
0123 if(void* p = cmp_cast<named>(this,a_class)) {return p;}
0124 else return 0;
0125 }
0126 //virtual void* cast(cid) const {return named_cid();}
0127 public:
0128 virtual iro* copy() const {return new named(*this);}
0129 virtual bool stream(buffer& a_buffer) {
0130 return Named_stream(a_buffer,m_name,m_title);
0131 }
0132 public:
0133 named() {
0134 #ifdef TOOLS_MEM
0135 mem::increment(s_class().c_str());
0136 #endif
0137 }
0138 virtual ~named() {
0139 #ifdef TOOLS_MEM
0140 mem::decrement(s_class().c_str());
0141 #endif
0142 }
0143 protected:
0144 named(const named& a_from):iro(a_from),m_name(a_from.m_name),m_title(a_from.m_title) {
0145 #ifdef TOOLS_MEM
0146 mem::increment(s_class().c_str());
0147 #endif
0148 }
0149 named& operator=(const named& a_from){
0150 m_name = a_from.m_name;
0151 m_title = a_from.m_title;
0152 return *this;
0153 }
0154 protected:
0155 std::string m_name;
0156 std::string m_title;
0157 };
0158
0159 }}
0160
0161 #endif