00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef UserData_UserInt_H
00016 #define UserData_UserInt_H 1
00017
00018
00019 #include "Event/UserData.h"
00020 #include "GaudiKernel/boost_allocator.h"
00021 #include <ostream>
00022
00023
00024
00025 namespace DayaBay
00026 {
00027
00028
00029
00039 class UserInt: public UserData
00040 {
00041 public:
00042
00044 UserInt(const std::string& name,
00045 const int& value) : UserData(name),
00046 m_value(value) {}
00047
00049 UserInt() : m_value(0) {}
00050
00052 virtual ~UserInt();
00053
00055 virtual std::ostream& fillStream(std::ostream& s) const;
00056
00058 virtual UserData::DataType type() const;
00059
00062 int value() const;
00063
00066 void setValue(int value);
00067
00068
00069 #ifndef GOD_NOALLOC
00071 static void* operator new ( size_t size )
00072 {
00073 return ( sizeof(UserInt) == size ?
00074 boost::singleton_pool<UserInt, sizeof(UserInt)>::malloc() :
00075 ::operator new(size) );
00076 }
00077
00081 static void* operator new ( size_t size, void* pObj )
00082 {
00083 return ::operator new (size,pObj);
00084 }
00085
00087 static void operator delete ( void* p )
00088 {
00089 boost::singleton_pool<UserInt, sizeof(UserInt)>::is_from(p) ?
00090 boost::singleton_pool<UserInt, sizeof(UserInt)>::free(p) :
00091 ::operator delete(p);
00092 }
00093
00096 static void operator delete ( void* p, void* pObj )
00097 {
00098 ::operator delete (p, pObj);
00099 }
00100 #endif
00101 protected:
00102
00103 private:
00104
00105 int m_value;
00106
00107 };
00108
00109 inline std::ostream& operator<< (std::ostream& str, const UserInt& obj)
00110 {
00111 return obj.fillStream(str);
00112 }
00113
00114 }
00115
00116
00117
00118
00119
00120
00121
00122 inline std::ostream& DayaBay::UserInt::fillStream(std::ostream& s) const
00123 {
00124 UserData::fillStream(s);
00125 s << "{ " << "value : " << m_value << std::endl << " }";
00126 return s;
00127 }
00128
00129
00130 inline int DayaBay::UserInt::value() const
00131 {
00132 return m_value;
00133 }
00134
00135 inline void DayaBay::UserInt::setValue(int value)
00136 {
00137 m_value = value;
00138 }
00139
00140 inline DayaBay::UserData::DataType DayaBay::UserInt::type() const
00141 {
00142 return DayaBay::UserData::Int;
00143 }
00144
00145
00146 #endif