DDConstant

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#ifndef DDConstant_h
#define DDConstant_h

#include <iostream>
#include <vector>
#include <memory>

#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"

class DDConstant;
class ClhepEvaluator;

//! output operator for printing ...
std::ostream& operator<<(std::ostream& o, const DDConstant& cons);

//! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>
class DDConstant : public DDBase<DDName, std::unique_ptr<double> > {
public:
  //! an uninitialized constant; one can assign an initialized constant to make it valid
  DDConstant();

  //! a refenrence to a constant
  DDConstant(const DDName& name);

  //! creation of a new named constant; if it already existed with the given name, it's overwritten with new values
  DDConstant(const DDName& name, std::unique_ptr<double> value);

  //! creates all DDConstants from the variables of the ClhepEvaluator
  static void createConstantsFromEvaluator(ClhepEvaluator&);

  //! return the first stored value; does not check boundaries!
  double value() const { return rep(); }

  //! convert to a double
  operator double() const { return rep(); }
};

//! std::maps the XML naming convention, i.e. <Numeric name='foo' value='4711'/> -> DDNumeric
using DDNumeric = DDConstant;

#endif