ATLAS Offline Software
ITechnologySpecificAttributes.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef INCLUDE_PERSISTENCYSVC_ITECHNOLOGYSPECIFICATTRIBUTES_H
6 #define INCLUDE_PERSISTENCYSVC_ITECHNOLOGYSPECIFICATTRIBUTES_H
7 
8 // includes
9 #include <exception>
10 #include <string>
11 #include <sstream>
12 #include <typeinfo>
13 
14 namespace pool {
15 
23  public:
25  template< class T > T attribute( const std::string& attributeName,
26  const std::string& option = "" ) {
27  T data;
28  const std::type_info& typeInfo = typeid(T);
29  if ( ! this->attributeOfType( attributeName,
30  static_cast< void* >( &data ),
31  typeInfo,
32  option ) ) {
33  std::ostringstream error;
34  error << "Failed to retrieve attribute " << attributeName << " of type " << typeInfo.name();
35  throw std::runtime_error( error.str() + " (APR: \" ITechnologySpecificAttributes \" from \" PersistencySvc \")");
36  }
37  return data;
38  }
39 
41  template< class T > bool setAttribute( const std::string& attributeName,
42  const T& atttibuteValue,
43  const std::string& option = "" ) {
44  return this->setAttributeOfType( attributeName,
45  static_cast< const void* >( &atttibuteValue ),
46  typeid(T),
47  option );
48  }
49 
50  protected:
53 
55  virtual bool attributeOfType( const std::string& attributeName,
56  void* data,
57  const std::type_info& typeInfo,
58  const std::string& option ) = 0;
59 
61  virtual bool setAttributeOfType( const std::string& attributeName,
62  const void* data,
63  const std::type_info& typeInfo,
64  const std::string& option ) = 0;
65  };
66 
67 }
68 
69 #endif
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
pool::ITechnologySpecificAttributes::~ITechnologySpecificAttributes
virtual ~ITechnologySpecificAttributes()
Default destructor.
Definition: ITechnologySpecificAttributes.h:52
pool
pool namespace
Definition: libname.h:15
pool::ITechnologySpecificAttributes::setAttribute
bool setAttribute(const std::string &attributeName, const T &atttibuteValue, const std::string &option="")
Templated method to set an attribute.
Definition: ITechnologySpecificAttributes.h:41
pool::ITechnologySpecificAttributes::setAttributeOfType
virtual bool setAttributeOfType(const std::string &attributeName, const void *data, const std::type_info &typeInfo, const std::string &option)=0
The actual method setting the attribute data given a name.
pool::ITechnologySpecificAttributes::attributeOfType
virtual bool attributeOfType(const std::string &attributeName, void *data, const std::type_info &typeInfo, const std::string &option)=0
The actual method returning the attribute data given a name.
pool::ITechnologySpecificAttributes
Definition: ITechnologySpecificAttributes.h:22
pool::ITechnologySpecificAttributes::attribute
T attribute(const std::string &attributeName, const std::string &option="")
Templated method to retrieve an attribute.
Definition: ITechnologySpecificAttributes.h:25
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70