00001
00002 #ifndef GAUDIKERNEL_GENERICLINK_H
00003 #define GAUDIKERNEL_GENERICLINK_H
00004
00005
00006 #include "GaudiKernel/Kernel.h"
00007 #include "GaudiKernel/ClassID.h"
00008
00009
00010 class ooId;
00011 class GenericLink;
00012 class GenericLinkIO;
00013 class GenericLinkBase;
00014
00022 class GenericLinkBase {
00023 friend class GenericLinkIO;
00024 public:
00028 struct GENERIC {
00029 friend class GenericLink;
00030 friend class GenericLinkIO;
00031 friend class GenericLinkBase;
00032 public:
00034 unsigned long m_info[2];
00036 bool operator ==(const GENERIC& cmp) const {
00037 return m_info[0] == cmp.m_info[0] && m_info[1] == cmp.m_info[1];
00038 }
00039 GENERIC& operator=(const GENERIC& copy) {
00040 m_info[0] = copy.m_info[0];
00041 m_info[1] = copy.m_info[1];
00042 return *this;
00043 }
00044 };
00045 protected:
00047 unsigned char m_svcType;
00049 CLID m_clID;
00051 GENERIC m_gene;
00052 public:
00054 GenericLinkBase(unsigned char type = 0, const CLID& clid = 0)
00055 : m_svcType(type), m_clID(clid)
00056 {
00057 m_gene.m_info[0]=m_gene.m_info[1]=0xffffffff;
00058 }
00060 GenericLinkBase(const GenericLinkBase& copy)
00061 : m_svcType(copy.m_svcType),
00062 m_clID(copy.m_clID),
00063 m_gene(copy.m_gene)
00064 {
00065 }
00067 bool operator == (const GenericLinkBase& cmp) const {
00068 return m_svcType == cmp.m_svcType &&
00069 m_clID == cmp.m_clID &&
00070 m_gene == cmp.m_gene;
00071 }
00073 virtual GenericLinkBase& operator = (const GenericLinkBase& copy) {
00074 m_svcType = copy.m_svcType;
00075 m_clID = copy.m_clID;
00076 m_gene = copy.m_gene;
00077 return *this;
00078 }
00080 const CLID& clID() const {
00081 return m_clID;
00082 }
00084 void setClID(const CLID& clid) {
00085 m_clID = clid;
00086 }
00088 unsigned char svcType() const {
00089 return m_svcType;
00090 }
00092 void setSvcType(unsigned char typ) {
00093 m_svcType = typ;
00094 }
00096 virtual bool isValid() const {
00097 return m_gene.m_info[0] != 0xFFFFFFFF &&
00098 m_gene.m_info[1] != 0xFFFFFFFF;
00099 }
00101 GENERIC* genericInfo() {
00102 return &m_gene;
00103 }
00105 const GENERIC* genericInfo() const {
00106 return &m_gene;
00107 }
00108 };
00109
00110 #ifndef OODDL
00111
00127 class GenericLink : public GenericLinkBase {
00128 public:
00130 class SICB {
00131 public:
00133 unsigned long linkID() const {
00134 return ((GenericLink::GENERIC*)this)->m_info[0];
00135 }
00137 void setLinkID(unsigned long id) {
00138 ((GenericLink::GENERIC*)this)->m_info[0] = id;
00139 }
00141 unsigned long entryID() const {
00142 return ((GenericLink::GENERIC*)this)->m_info[1];
00143 }
00145 void setEntryID(unsigned long id) {
00146 ((GenericLink::GENERIC*)this)->m_info[1] = id;
00147 }
00148 };
00149 class ROOT {
00150 public:
00152 unsigned long linkID() const {
00153 return ((GenericLink::GENERIC*)this)->m_info[0];
00154 }
00156 void setLinkID(unsigned long id) {
00157 ((GenericLink::GENERIC*)this)->m_info[0] = id;
00158 }
00160 unsigned long entryID() const {
00161 return ((GenericLink::GENERIC*)this)->m_info[1];
00162 }
00164 void setEntryID(unsigned long id) {
00165 ((GenericLink::GENERIC*)this)->m_info[1] = id;
00166 }
00167 };
00169 class OBJY {
00170 protected:
00171 unsigned short int m_id[4];
00172 public:
00173 ooId* handle() {
00174 return (ooId*)this->m_id;
00175 }
00176 const ooId* handle() const {
00177 return (ooId*)this->m_id;
00178 }
00179 };
00180 union Generic {
00181 GENERIC* Gene;
00182 ROOT* Root;
00183 OBJY* Objy;
00184 SICB* SicB;
00185 };
00186
00187 protected:
00189 Generic m_generic;
00190 public:
00192 GenericLink() {
00193 m_generic.Gene = &m_gene;
00194 }
00196
00197
00198
00200
00201 m_generic.Gene = &m_gene;
00202 }
00204 GenericLink(const GenericLinkBase* copy) : GenericLinkBase(*copy) {
00205 m_generic.Gene = &m_gene;
00206 }
00208 GenericLink(unsigned char type, const CLID& clsid=0) : GenericLinkBase(type, clsid) {
00209 m_generic.Gene = &m_gene;
00210 }
00212 virtual ~GenericLink() {
00213 }
00215 virtual GenericLink& operator = (const GenericLink& copy) {
00216 GenericLinkBase::operator=(copy);
00217 return *this;
00218 }
00219 #ifndef WIN32
00223 virtual GenericLink& operator = (const GenericLinkBase& copy) {
00224
00225 GenericLinkBase::operator=(copy);
00226 return *this;
00227 }
00228 #endif
00229 Generic& generic() {
00230 return m_generic;
00231 }
00233 const Generic& generic() const {
00234 return m_generic;
00235 }
00237 void setGeneric(Generic& info) {
00238 m_generic.Gene = info.Gene;
00239 }
00241 ROOT* rootInfo() {
00242 return m_generic.Root;
00243 }
00245 const ROOT* rootInfo() const {
00246 return m_generic.Root;
00247 }
00249 OBJY* objyInfo() {
00250 return m_generic.Objy;
00251 }
00253 const OBJY* objyInfo() const {
00254 return m_generic.Objy;
00255 }
00257 SICB* sicbInfo() {
00258 return m_generic.SicB;
00259 }
00261 const SICB* sicbInfo() const {
00262 return m_generic.SicB;
00263 }
00264 };
00265
00266 #endif // OODDL
00267
00268 #endif // GAUDIKERNEL_GENERICLINK_H