ATLAS Offline Software
LinkObj.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHEXSTOREGATEEXAMPLE_LINKOBJ_H
6 #define ATHEXSTOREGATEEXAMPLE_LINKOBJ_H
7 
8 #include <vector>
9 
10 #include "AthLinks/DataLink.h"
11 #include "AthLinks/ElementLink.h"
12 #include "MyDataObj.h"
13 #include "MyElement.h"
14 
15 //sample data class for the Read/Write example
16 //it just wraps an int. Notice that is does not inherit from Gaudi DataObject
17 
18 namespace SGTutorial {
19 
20  class LinkObj {
21 
22  public:
23 
24  LinkObj() {}
26 
27  // Set links to either an object or a collection
28 
29  // Link to a data object
30  void setObjLink(MyDataObj&);
31 
32  // Link to an element of a collection
33  void setContLink(std::vector<MyElement>&,
34  const MyElement&);
35 
36  // Link to an element of a collection using an index
37  void setContLink(std::vector<MyElement>&,
38  int);
39 
40  // Access linked object/collection
41  const MyDataObj& myLinkedObj();
42  const MyElement& myLinkedElement();
43 
44  template <class OST>
45  friend OST& operator<<(OST& ost, LinkObj& rhs);
46 
47  private:
50 
51  };
52 #include <iostream>
53  template <class OST>
54  inline OST& operator<<(OST& ost, LinkObj& rhs) {
55  ost << "LinkObj: link to MyDataObj -> " << rhs.myLinkedObj()
56  << "\n link to MyElement[" << rhs.m_contLink.index() << "] -> "
57  << *rhs.m_contLink;
58  return ost;
59  }
60 
61 } //end ns SGTutorial
62 //using the macros below we can assign an identifier (and a version)
63 //to the type LinkObj
64 //This is required and checked at compile time when you try to record/retrieve
65 #include "AthenaKernel/CLASS_DEF.h"
67 //class version is not currently used
68 
69 #endif
70 
71 
MyDataObj.h
SGTutorial::LinkObj::m_objLink
DataLink< MyDataObj > m_objLink
Definition: LinkObj.h:48
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
SGTutorial::operator<<
OST & operator<<(OST &ost, LinkObj &rhs)
Definition: LinkObj.h:54
SGTutorial::LinkObj::operator<<
friend OST & operator<<(OST &ost, LinkObj &rhs)
Definition: LinkObj.h:54
SGTutorial::LinkObj::m_contLink
ElementLink< std::vector< MyElement > > m_contLink
Definition: LinkObj.h:49
SGTutorial::MyElement
Definition: MyElement.h:13
MyElement.h
SGTutorial::LinkObj::~LinkObj
~LinkObj()
Definition: LinkObj.h:25
SGTutorial::LinkObj::setContLink
void setContLink(std::vector< MyElement > &, const MyElement &)
Definition: LinkObj.cxx:20
SGTutorial::LinkObj::myLinkedElement
const MyElement & myLinkedElement()
Definition: LinkObj.cxx:46
SGTutorial::MyDataObj
Definition: Tutorial/MyDataObj.h:13
SGTutorial::LinkObj::setObjLink
void setObjLink(MyDataObj &)
Definition: LinkObj.cxx:14
SGTutorial::LinkObj::LinkObj
LinkObj()
Definition: LinkObj.h:24
SGTutorial
Definition: LinkObj.h:18
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
SGTutorial::LinkObj::myLinkedObj
const MyDataObj & myLinkedObj()
Definition: LinkObj.cxx:40
SGTutorial::LinkObj
Definition: LinkObj.h:20
CLASS_DEF.h
macros to associate a CLID to a type