00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EventBase_IntLink_H
00016 #define EventBase_IntLink_H 1
00017
00018
00019 #include "GaudiKernel/DataObject.h"
00020 #include "GaudiKernel/boost_allocator.h"
00021 #include "GaudiKernel/SerializeSTL.h"
00022 #include <map>
00023 #include <ostream>
00024
00025
00026
00027 namespace LHCb
00028 {
00029
00030
00031 using GaudiUtils::operator<<;
00032
00033
00034
00035 static const CLID CLID_IntLink = 500;
00036
00037
00047 class IntLink: public DataObject
00048 {
00049 public:
00050
00052 IntLink() : m_link() {}
00053
00055 virtual ~IntLink() {}
00056
00057
00058 virtual const CLID& clID() const;
00059 static const CLID& classID();
00060
00062 virtual std::ostream& fillStream(std::ostream& s) const;
00063
00065 void setLink(int key,
00066 int value);
00067
00069 int link(int key) const;
00070
00072 bool hasKey(int key) const;
00073
00076 const std::map<int,int>& link() const;
00077
00080 void setLink(const std::map<int,int>& value);
00081
00082
00083 #ifndef GOD_NOALLOC
00085 static void* operator new ( size_t size )
00086 {
00087 return ( sizeof(IntLink) == size ?
00088 boost::singleton_pool<IntLink, sizeof(IntLink)>::malloc() :
00089 ::operator new(size) );
00090 }
00091
00095 static void* operator new ( size_t size, void* pObj )
00096 {
00097 return ::operator new (size,pObj);
00098 }
00099
00101 static void operator delete ( void* p )
00102 {
00103 boost::singleton_pool<IntLink, sizeof(IntLink)>::is_from(p) ?
00104 boost::singleton_pool<IntLink, sizeof(IntLink)>::free(p) :
00105 ::operator delete(p);
00106 }
00107
00110 static void operator delete ( void* p, void* pObj )
00111 {
00112 ::operator delete (p, pObj);
00113 }
00114 #endif
00115 protected:
00116
00117 private:
00118
00119 std::map<int,int> m_link;
00120
00121 };
00122
00123 inline std::ostream& operator<< (std::ostream& str, const IntLink& obj)
00124 {
00125 return obj.fillStream(str);
00126 }
00127
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 inline const CLID& LHCb::IntLink::clID() const
00137 {
00138 return LHCb::IntLink::classID();
00139 }
00140
00141 inline const CLID& LHCb::IntLink::classID()
00142 {
00143 return CLID_IntLink;
00144 }
00145
00146 inline std::ostream& LHCb::IntLink::fillStream(std::ostream& s) const
00147 {
00148 s << "{ " << "link : " << m_link << std::endl << " }";
00149 return s;
00150 }
00151
00152
00153 inline const std::map<int,int>& LHCb::IntLink::link() const
00154 {
00155 return m_link;
00156 }
00157
00158 inline void LHCb::IntLink::setLink(const std::map<int,int>& value)
00159 {
00160 m_link = value;
00161 }
00162
00163 inline void LHCb::IntLink::setLink(int key,
00164 int value)
00165 {
00166
00167 m_link[key] = value;
00168
00169 }
00170
00171 inline int LHCb::IntLink::link(int key) const
00172 {
00173
00174 if (m_link.find(key) == m_link.end()) return 0;
00175 return m_link.find(key)->second;
00176
00177 }
00178
00179 inline bool LHCb::IntLink::hasKey(int key) const
00180 {
00181
00182 return (m_link.find(key) != m_link.end());
00183
00184 }
00185
00186
00187 #endif