Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DETECTOR_DESCRIPTION_CORE_DDSTRVECTOR_H
0002 #define DETECTOR_DESCRIPTION_CORE_DDSTRVECTOR_H
0003 
0004 #include <iostream>
0005 #include <memory>
0006 #include <string>
0007 #include <vector>
0008 
0009 #include "DetectorDescription/Core/interface/DDBase.h"
0010 #include "DetectorDescription/Core/interface/DDName.h"
0011 
0012 class DDStrVector;
0013 
0014 //! output operator for printing ...
0015 std::ostream& operator<<(std::ostream& o, const DDStrVector& cons);
0016 
0017 //! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsStrVector>
0018 class DDStrVector : public DDBase<DDName, std::unique_ptr<std::vector<std::string>>> {
0019 public:
0020   //! size type for the size of the stored values
0021   using size_t = std::vector<std::string>::size_type;
0022 
0023   //! value type of the managed object
0024   using value_type = std::vector<std::string>;
0025 
0026   //! an uninitialized constant; one can assign an initialized constant to make it valid
0027   DDStrVector();
0028 
0029   //! a refenrence to a constant
0030   DDStrVector(const DDName& name);
0031 
0032   //! creation of a new named constant; if it already existed with the given name, it's overwritten with new values
0033   DDStrVector(const DDName& name, std::unique_ptr<std::vector<std::string>> value);
0034 
0035   //! the size of the array of values
0036   size_t size() const { return rep().size(); }
0037 
0038   //! the stored values
0039   const value_type& values() const { return rep(); }
0040 
0041   //! returns the value on position pos; does not check boundaries!
0042   std::string operator[](size_t pos) const { return rep()[pos]; }
0043 
0044   //! return the first stored value; does not check boundaries!
0045   std::string value() const { return rep()[0]; }
0046 
0047   //! read-only iterator pointing to the begin of the stored values
0048   value_type::const_iterator vectorBegin() const { return rep().begin(); }
0049 
0050   //! read-only iterator poining one place after the stored values
0051   value_type::const_iterator vectorEnd() const { return rep().end(); }
0052 
0053   //! convert to a double
0054   operator std::string() const { return rep()[0]; }
0055 
0056   //! convert to a std::vector<double>
0057   operator std::vector<std::string>() const { return rep(); }
0058 };
0059 
0060 #endif