Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:54

0001 #ifndef DDConstant_h
0002 #define DDConstant_h
0003 
0004 #include <iostream>
0005 #include <vector>
0006 #include <memory>
0007 
0008 #include "DetectorDescription/Core/interface/DDBase.h"
0009 #include "DetectorDescription/Core/interface/DDName.h"
0010 
0011 class DDConstant;
0012 class ClhepEvaluator;
0013 
0014 //! output operator for printing ...
0015 std::ostream& operator<<(std::ostream& o, const DDConstant& cons);
0016 
0017 //! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>
0018 class DDConstant : public DDBase<DDName, std::unique_ptr<double> > {
0019 public:
0020   //! an uninitialized constant; one can assign an initialized constant to make it valid
0021   DDConstant();
0022 
0023   //! a refenrence to a constant
0024   DDConstant(const DDName& name);
0025 
0026   //! creation of a new named constant; if it already existed with the given name, it's overwritten with new values
0027   DDConstant(const DDName& name, std::unique_ptr<double> value);
0028 
0029   //! creates all DDConstants from the variables of the ClhepEvaluator
0030   static void createConstantsFromEvaluator(ClhepEvaluator&);
0031 
0032   //! return the first stored value; does not check boundaries!
0033   double value() const { return rep(); }
0034 
0035   //! convert to a double
0036   operator double() const { return rep(); }
0037 };
0038 
0039 //! std::maps the XML naming convention, i.e. <Numeric name='foo' value='4711'/> -> DDNumeric
0040 using DDNumeric = DDConstant;
0041 
0042 #endif