00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef UserData_UserDataHeader_H
00016 #define UserData_UserDataHeader_H 1
00017
00018
00019 #include "Event/HeaderObject.h"
00020 #include "Event/UserData.h"
00021 #include "Event/UserFloat.h"
00022 #include "Event/UserFloatArray.h"
00023 #include "Event/UserInt.h"
00024 #include "Event/UserIntArray.h"
00025 #include "GaudiKernel/boost_allocator.h"
00026 #include <string>
00027 #include <vector>
00028 #include <ostream>
00029
00030
00031
00032 namespace DayaBay
00033 {
00034
00035
00036
00037
00038 static const CLID CLID_UserDataHeader = 51803;
00039
00040
00041 namespace UserDataHeaderLocation {
00042 static const std::string& Default = "/Event/UserData/Default";
00043 }
00044
00045
00055 class UserDataHeader: public HeaderObject
00056 {
00057 public:
00058
00060 static const std::string& defaultLocation() { return UserDataHeaderLocation::Default; }
00061 virtual const std::string& defLoc() const { return UserDataHeaderLocation::Default; }
00062
00064 typedef std::vector<DayaBay::UserData*> UserDataList;
00065
00067 UserDataHeader() : m_data() {}
00068
00070 virtual ~UserDataHeader();
00071
00072
00073 virtual const CLID& clID() const;
00074 static const CLID& classID();
00075
00077 static UserDataHeader* create();
00078
00080 void clearData();
00081
00083 void setInt(const std::string& name,
00084 const int& value);
00085
00087 void setIntArray(const std::string& name,
00088 const std::vector<int>& value);
00089
00091 void setFloat(const std::string& name,
00092 const float& value);
00093
00095 void setFloatArray(const std::string& name,
00096 const std::vector<float>& value);
00097
00099 int getInt(const std::string& name,
00100 int def=0);
00101
00103 std::vector<int> getIntArray(const std::string& name);
00104
00106 float getFloat(const std::string& name,
00107 float def=0.0);
00108
00110 std::vector<float> getFloatArray(const std::string& name);
00111
00113 void set(const std::string& name,
00114 const int& value);
00115
00117 void set(const std::string& name,
00118 const float& value);
00119
00121 void set(const std::string& name,
00122 const std::vector<int>& value);
00123
00125 void set(const std::string& name,
00126 const std::vector<float>& value);
00127
00129 UserData* get(const std::string& name);
00130
00132 std::ostream& fillStream(std::ostream& s) const;
00133
00136 const UserDataList& data() const;
00137
00140 UserDataList& data();
00141
00144 void setData(const UserDataList& value);
00145
00146
00147 #ifndef GOD_NOALLOC
00149 static void* operator new ( size_t size )
00150 {
00151 return ( sizeof(UserDataHeader) == size ?
00152 boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::malloc() :
00153 ::operator new(size) );
00154 }
00155
00159 static void* operator new ( size_t size, void* pObj )
00160 {
00161 return ::operator new (size,pObj);
00162 }
00163
00165 static void operator delete ( void* p )
00166 {
00167 boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::is_from(p) ?
00168 boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::free(p) :
00169 ::operator delete(p);
00170 }
00171
00174 static void operator delete ( void* p, void* pObj )
00175 {
00176 ::operator delete (p, pObj);
00177 }
00178 #endif
00179 protected:
00180
00181 private:
00182
00183 UserDataList m_data;
00184
00185 };
00186
00187 inline std::ostream& operator<< (std::ostream& str, const UserDataHeader& obj)
00188 {
00189 return obj.fillStream(str);
00190 }
00191
00192 }
00193
00194
00195
00196
00197
00198
00199
00200 inline const CLID& DayaBay::UserDataHeader::clID() const
00201 {
00202 return DayaBay::UserDataHeader::classID();
00203 }
00204
00205 inline const CLID& DayaBay::UserDataHeader::classID()
00206 {
00207 return CLID_UserDataHeader;
00208 }
00209
00210 inline const DayaBay::UserDataHeader::UserDataList& DayaBay::UserDataHeader::data() const
00211 {
00212 return m_data;
00213 }
00214
00215 inline DayaBay::UserDataHeader::UserDataList& DayaBay::UserDataHeader::data()
00216 {
00217 return m_data;
00218 }
00219
00220 inline void DayaBay::UserDataHeader::setData(const UserDataList& value)
00221 {
00222 m_data = value;
00223 }
00224
00225 inline void DayaBay::UserDataHeader::set(const std::string& name,
00226 const int& value)
00227 {
00228 this->setInt(name,value);
00229 }
00230
00231 inline void DayaBay::UserDataHeader::set(const std::string& name,
00232 const float& value)
00233 {
00234 this->setFloat(name, value);
00235 }
00236
00237 inline void DayaBay::UserDataHeader::set(const std::string& name,
00238 const std::vector<int>& value)
00239 {
00240 this->setIntArray(name, value);
00241 }
00242
00243 inline void DayaBay::UserDataHeader::set(const std::string& name,
00244 const std::vector<float>& value)
00245 {
00246 this->setFloatArray(name, value);
00247 }
00248
00249 inline DayaBay::UserData* DayaBay::UserDataHeader::get(const std::string& name)
00250 {
00251
00252 DayaBay::UserDataHeader::UserDataList::iterator dataIter,
00253 dataEnd = m_data.end();
00254 for(dataIter=m_data.begin(); dataIter!=dataEnd; dataIter++){
00255 if( (*dataIter)->name() == name ) return (*dataIter);
00256 }
00257 return 0;
00258
00259 }
00260
00261
00262 #endif