DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConditionsData.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_CONDITIONS_CONDITIONSDATA_H
14 #define DD4HEP_CONDITIONS_CONDITIONSDATA_H
15 
16 // Framework include files
17 #include "DD4hep/Objects.h"
18 #include "DD4hep/Conditions.h"
20 
21 // C/C++ include files
22 #include <vector>
23 #include <stdexcept>
24 
26 namespace DD4hep {
27 
29  namespace Conditions {
30 
32 
38  struct ClientData {
39  virtual ~ClientData();
40  virtual void release() = 0;
41  };
42 
44 
50  class AbstractMap {
51  private:
52  public:
53  enum {
54  REGULAR = 0,
56  };
57  typedef std::map<std::string, OpaqueDataBlock> Params;
60  int classID;
62  AbstractMap();
64  AbstractMap(const AbstractMap& c);
66  virtual ~AbstractMap();
70  template <typename T> T* option() const {
71  return static_cast<T*>(clientData);
72  }
74  const Params::value_type& firstParam() const {
75  Params::const_iterator i=params.begin();
76  if ( i != params.end() ) return (*i);
77  throw std::runtime_error("AbstractMap: Failed to access non-existing first parameter");
78  }
80  Params::value_type& firstParam() {
81  Params::iterator i=params.begin();
82  if ( i != params.end() ) return (*i);
83  throw std::runtime_error("AbstractMap: Failed to access non-existing first parameter");
84  }
86  template <typename T> const T& first() const {
87  Params::const_iterator i=params.begin();
88  if ( i != params.end() ) return (*i).second.get<T>();
89  throw std::runtime_error("AbstractMap: Failed to access non-existing first item");
90  }
92  template <typename T> T& first() {
93  Params::iterator i=params.begin();
94  if ( i != params.end() ) return (*i).second.get<T>();
95  throw std::runtime_error("AbstractMap: Failed to access non-existing first item");
96  }
98  template <typename T> const T& operator[](const std::string& item) const {
99  Params::const_iterator i=params.find(item);
100  if ( i != params.end() ) return (*i).second.get<T>();
101  throw std::runtime_error("AbstractMap: Failed to access non-existing item:"+item);
102  }
104  template <typename T> T& operator[](const std::string& item) {
105  Params::iterator i=params.find(item);
106  if ( i != params.end() ) return (*i).second.get<T>();
107  throw std::runtime_error("AbstractMap: Failed to access non-existing item:"+item);
108  }
109  };
110 
111  } /* End namespace Conditions */
112 } /* End namespace DD4hep */
113 #endif /* DD4HEP_CONDITIONS_CONDITIONSDATA_H */
const Params::value_type & firstParam() const
Simplify access to first item of the parameter list (const access)
Params::value_type & firstParam()
Simplify access to first item of the parameter list.
virtual ~ClientData()
Default destructor.
const T & operator[](const std::string &item) const
Simplify access to mapped item of the parameter list (const access)
Client data addition.
T * option() const
Simplify access to client data.
const T & first() const
Simplify access to first item of the parameter list (const access)
AbstractMap & operator=(const AbstractMap &c)
Assignment operator.
virtual ~AbstractMap()
Default destructor.
Conditions data block. Internally maps other objects to abstract data blocks.
T & first()
Simplify access to first item of the parameter list.
std::map< std::string, OpaqueDataBlock > Params
T & operator[](const std::string &item)
Simplify access to mapped item of the parameter list.
AbstractMap()
Default constructor.