CMS 3D CMS Logo

DDValue.h

Go to the documentation of this file.
00001 #ifndef DDValue_h
00002 #define DDValue_h
00003 #include <iostream>
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <memory>
00008 
00009 #include "DetectorDescription/Core/interface/DDValuePair.h"
00010 #include "DetectorDescription/Base/interface/Ptr.h"
00011 
00012 #include "boost/shared_ptr.hpp"
00013 
00014 class DDValue;
00015 class DDSpecifics;
00016 class DDLSpecPar;
00017 
00018 //std::ostream & operator<< ( std::ostream &, const DDValue &);
00026 class DDValue //: public std::vector<DDValuePair>
00027 {
00028   friend class DDSpecifics;
00029   friend class DDLSpecPar;
00030 public:
00032   DDValue() : id_(0), vecPair_(0) { }
00033   
00035   DDValue(const std::string &);
00036   
00038   explicit DDValue(const std::string &, const std::vector<DDValuePair>&);
00039   
00041   explicit DDValue(const std::string &, double);
00042   
00044   explicit DDValue(const std::string &, const std::string &, double);
00045   
00047   explicit DDValue(const std::string & name, const std::string & val);
00048   
00049   explicit DDValue(unsigned int);
00050   //~DDValue() { destroy(); }
00051   //DDValue(const DDValue &);
00052   //DDValue & operator=(const DDValue &);
00053   //const DDValuePair &  
00054   
00055   ~DDValue();
00056   
00058   unsigned int id() const { return id_; }
00059   
00061   operator unsigned int() const { return id_; }
00062   
00064   const std::string & name() const { return names()[id_]; }
00065   
00068   DDValuePair operator[](unsigned int i) const; 
00069    
00071   const std::vector<std::string> & strings() const { return vecPair_->second.first; }
00072   
00074   const std::vector<double> & doubles() const;
00075   //const DDValuePair & operator[](unsigned int i) const { return (*valPairs_)[i]  ; }
00076   
00078   unsigned int size() const { 
00079    return vecPair_ ? vecPair_->second.first.size() : 0 ; 
00080   } 
00081   
00082   static void clear();
00083   
00085   void setEvalState(bool newState); 
00086   
00088 
00090   bool isEvaluated() const;
00091   
00093 
00095   inline bool operator==(const DDValue &) const;
00096   
00098   inline bool operator<(const DDValue &) const;
00099   
00100 private:  
00101   typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > >vecpair_type;
00102   static std::vector<std::string>& names();
00103   static std::map<std::string,unsigned int>& indexer();
00104   static std::vector<boost::shared_ptr<vecpair_type> >& mem(vecpair_type*);
00105   //DDValue(const DDValue &);
00106   //DDValue & operator=(const DDValue &);
00107   //void destroy() { delete vecPair_;} //delete valPairs_; }
00108   
00109   //static std::vector<std::map<std::string,unsigned int>::const_iterator> names_;
00110   unsigned int id_;
00111   
00112   //Ptr<vecpair_type>  vecPair_;
00113 public:  
00114   vecpair_type* vecPair_;
00115 
00116 public:  
00117   //bool isEvaluated_;
00118   //auto_ptr<vecpair_type> vecPair_;
00119   //std::vector<DDValuePair> * valPairs_;
00120 };
00121 
00122 
00123 std::ostream & operator<<(std::ostream & o, const DDValue & v);
00124 #endif // DDValue_h

Generated on Tue Jun 9 17:32:07 2009 for CMSSW by  doxygen 1.5.4