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