Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:50

0001 //==============================================================================
0002 //  AIDA Detector description implementation for LHCb
0003 //------------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //  \author   Markus Frank
0011 //  \date     2018-03-08
0012 //  \version  1.0
0013 //
0014 //==============================================================================
0015 #ifndef DETECTOR_PARAMETERMAP_H 
0016 #define DETECTOR_PARAMETERMAP_H 1
0017 
0018 // Framework include files
0019 
0020 // C/C++ include files
0021 #include <string>
0022 #include <map>
0023 
0024 /// Gaudi namespace declaration
0025 namespace gaudi   {
0026 
0027   /// Generic detector element parameter map to specialize detector elements
0028   /**
0029    *  Concurrentcy notice:
0030    *  Except during filling, which is performed by the framework code,
0031    *  instances of this class are assumed to the read-only! 
0032    *  Thread safety hence is no issue.
0033    *
0034    *  \author  Markus Frank
0035    *  \date    2018-03-08
0036    *  \version  1.0
0037    */
0038   class ParameterMap  final  {
0039   public:
0040     /// Defintiion of a single parameter
0041     /**
0042      *  \author  Markus Frank
0043      *  \date    2018-03-08
0044      *  \version  1.0
0045      */
0046     class Parameter final {
0047     public:
0048       std::string value;
0049       std::string type;
0050     public:
0051       Parameter() = default;
0052       Parameter(Parameter&& copy) = default;
0053       Parameter(const Parameter& copy) = default;
0054       Parameter(const std::string& v, const std::string& t)
0055         : value(v), type(t) {}
0056       Parameter& operator=(const Parameter& copy) = default;
0057       bool operator==(const Parameter& copy) const
0058       { return value == copy.value && type == copy.type; }
0059       /// Type dependent accessor to a named parameter
0060       template <typename T> T get()   const;
0061     };
0062 
0063     typedef std::map<std::string,Parameter> Parameters;
0064 
0065   protected:
0066     /// The parameter map
0067     Parameters m_params;
0068 
0069     /// Access single parameter
0070     const Parameter& _param(const std::string& nam)   const;
0071   public:
0072     /// Defautl constructor
0073     ParameterMap() = default;
0074     /// Copy constructor
0075     ParameterMap(const ParameterMap& copy) = default;
0076     /// Default destructor
0077     ~ParameterMap() = default;
0078     /// Assignment opererator
0079     ParameterMap& operator=(const ParameterMap& copy) = default;
0080     /// Check the parameter existence
0081     bool exists(const std::string& nam)  const
0082     {  return m_params.find(nam) != m_params.end();    }
0083     /// Add/update a parameter value
0084     bool set(const std::string& nam, const std::string& val, const std::string& type);
0085     /// Access parameters set
0086     const Parameters& params()  const   {  return m_params; }
0087     /// Access single parameter
0088     const Parameter& parameter(const std::string& nam, bool throw_if_not_present=true)   const;
0089     /// Type dependent accessor to a named parameter
0090     template <typename T> T param(const std::string& nam, bool throw_if_not_present=true)   const;
0091   };
0092 }      // End namespace gaudi
0093 #endif // DETECTOR_PARAMETERMAP_H