All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataObjectHandleBase.cpp
Go to the documentation of this file.
3 #include "GaudiKernel/AlgTool.h"
6 
7 #include <sstream>
8 #include <string>
9 #include <ostream>
10 
12 
13 //---------------------------------------------------------------------------
14 
16  Gaudi::DataHandle(), m_init(false),
17  m_goodType(false), m_optional(false), m_wasRead(false), m_wasWritten(false) {}
18 
19 //---------------------------------------------------------------------------
23  Gaudi::DataHandle(k,a,owner), m_init(false), m_goodType(false),
24  m_optional(false), m_wasRead(false), m_wasWritten(false) {}
25 
26 //---------------------------------------------------------------------------
27 
31  DataObjectHandleBase(DataObjID(k), a, owner){}
32 
33 //---------------------------------------------------------------------------
34 
35 const std::string
38  ost << m_key << "|" << mode() << "|" << isOptional() << "|";
39  for (auto &a : m_altNames) {
40  ost << a << "&";
41  }
42  // ost << ")";
43  return ost.str();
44 }
45 
46 //---------------------------------------------------------------------------
47 const std::string
49  return "DataObjectHandleBase(\"" + toString() + "\")";
50 }
51 
52 //---------------------------------------------------------------------------
53 void
55  Gaudi::Parsers::parse(*this,s).ignore();
56 }
57 
58 //---------------------------------------------------------------------------
59 
60 void
62 
63  if (m_init) return;
64 
65  if (m_owner == 0) return;
66 
67  setRead(false);
68  setWritten(false);
69 
70  Algorithm* algorithm = dynamic_cast<Algorithm*>( m_owner );
71  if (algorithm != 0) {
72  // Fetch the event Data Service from the algorithm
73  m_EDS = algorithm->evtSvc();
74  m_MS = algorithm->msgSvc();
75  } else {
76  AlgTool* tool = dynamic_cast<AlgTool*>( owner() );
77  if (tool != 0) {
78  m_EDS = tool->evtSvc();
79  m_MS = tool->msgSvc();
80  } else {
81  throw GaudiException( "owner is not an AlgTool or Algorithm" ,
82  "Invalid Cast", StatusCode::FAILURE) ;
83  }
84  }
85 
86  m_init = true;
87 
88 }
89 
90 //---------------------------------------------------------------------------
91 
92 bool
94 
95  return ( fullKey() != INVALID_DATAOBJID );
96 
97 }
98 
99 //---------------------------------------------------------------------------
100 
103 
104  str << d.fullKey() << " m: " << d.mode();
105  if (d.owner() != 0) {
106  str << " o: " << d.owner()->name();
107  }
108 
109  str << " opt: " << d.isOptional();
110 
111  if (d.alternativeDataProductNames().size() != 0) {
112  str << " alt: [";
113  for ( auto &n : d.alternativeDataProductNames()) {
114  str << n << ",";
115  }
116  str << "]";
117  }
118 
119  return str;
120 }
void setWritten(bool wasWritten=true)
Define general base for Gaudi exception.
virtual Mode mode() const
Definition: DataHandle.h:47
SmartIF< IDataProviderSvc > m_EDS
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
void setRead(bool wasRead=true)
STL class.
virtual const DataObjID & fullKey() const
Definition: DataHandle.h:53
DataObjID m_key
Definition: DataHandle.h:63
IDataHandleHolder * m_owner
Definition: DataHandle.h:64
const DataObjID INVALID_DATAOBJID
void fromString(const std::string &s)
IDataProviderSvc * evtSvc() const
accessor to event service service
Definition: AlgTool.cpp:93
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
T size(T...args)
const std::string pythonRepr() const override
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:276
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
std::vector< std::string > m_altNames
const std::string toString() const
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:46
string s
Definition: gaudirun.py:245
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
void ignore() const
Definition: StatusCode.h:106
SmartIF< IMessageSvc > m_MS
bool isOptional() const
Check if the data object declared is optional for the algorithm.
STL class.
friend std::ostream & operator<<(std::ostream &str, const DataObjectHandleBase &d)
Helper functions to set/get the application return code.
Definition: __init__.py:1
const std::vector< std::string > & alternativeDataProductNames() const
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:45