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
10 #include <string>
11 #include <sstream>
12 #include <typeinfo>
13 
14 namespace pool {
15 
23  public:
26  public:
28  Exception( const std::string& message ):
30  "ITechnologySpecificAttributes" )
31  {}
33  virtual ~Exception() throw() {}
34  };
35 
37  template< class T > T attribute( const std::string& attributeName,
38  const std::string& option = "" ) {
39  T data;
40  const std::type_info& typeInfo = typeid(T);
41  if ( ! this->attributeOfType( attributeName,
42  static_cast< void* >( &data ),
43  typeInfo,
44  option ) ) {
45  std::ostringstream error;
46  error << "Failed to retrieve attribute " << attributeName << " of type " << typeInfo.name();
47  throw Exception( error.str() );
48  }
49  return data;
50  }
51 
53  template< class T > bool setAttribute( const std::string& attributeName,
54  const T& atttibuteValue,
55  const std::string& option = "" ) {
56  return this->setAttributeOfType( attributeName,
57  static_cast< const void* >( &atttibuteValue ),
58  typeid(T),
59  option );
60  }
61 
62  protected:
65 
67  virtual bool attributeOfType( const std::string& attributeName,
68  void* data,
69  const std::type_info& typeInfo,
70  const std::string& option ) = 0;
71 
73  virtual bool setAttributeOfType( const std::string& attributeName,
74  const void* data,
75  const std::type_info& typeInfo,
76  const std::string& option ) = 0;
77  };
78 
79 }
80 
81 #endif
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
pool::ITechnologySpecificAttributes::~ITechnologySpecificAttributes
virtual ~ITechnologySpecificAttributes()
Default destructor.
Definition: ITechnologySpecificAttributes.h:64
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:53
ReweightUtils.message
message
Definition: ReweightUtils.py:15
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::Exception::~Exception
virtual ~Exception()
Destructor.
Definition: ITechnologySpecificAttributes.h:33
pool::ITechnologySpecificAttributes::Exception
Exception thrown by the ITechnologySpecificAttributes class.
Definition: ITechnologySpecificAttributes.h:25
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:37
pool::ITechnologySpecificAttributes::Exception::Exception
Exception(const std::string &message)
Constructor.
Definition: ITechnologySpecificAttributes.h:28
pool::PersistencySvcException
Exception class thrown by the classes in the PersistencySvc package.
Definition: PersistencySvcException.h:13
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70
PersistencySvcException.h