CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DetectorDescription/Core/interface/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   DDValue(const char *);
00039  
00040   void init(const std::string &);
00041  
00043   explicit DDValue(const std::string &, const std::vector<DDValuePair>&);
00044   
00046   explicit DDValue(const std::string &, double);
00047   
00049   explicit DDValue(const std::string &, const std::string &, double);
00050   
00052   explicit DDValue(const std::string & name, const std::string & val);
00053   
00054   explicit DDValue(unsigned int);
00055   //~DDValue() { destroy(); }
00056   //DDValue(const DDValue &);
00057   //DDValue & operator=(const DDValue &);
00058   //const DDValuePair &  
00059   
00060   ~DDValue();
00061   
00063   unsigned int id() const { return id_; }
00064   
00066   operator unsigned int() const { return id_; }
00067   
00069   const std::string & name() const { return names()[id_]; }
00070   
00073   DDValuePair operator[](unsigned int i) const; 
00074    
00076   const std::vector<std::string> & strings() const { return vecPair_->second.first; }
00077   
00079   const std::vector<double> & doubles() const;
00080   //const DDValuePair & operator[](unsigned int i) const { return (*valPairs_)[i]  ; }
00081   
00083   unsigned int size() const { 
00084    return vecPair_ ? vecPair_->second.first.size() : 0 ; 
00085   } 
00086   
00087   static void clear();
00088   
00090   void setEvalState(bool newState); 
00091   
00093 
00095   bool isEvaluated() const;
00096   
00098 
00100   bool operator==(const DDValue & v) const;
00101   /* {
00102     return id()==v.id() 
00103       && ( 
00104           vecPair_ == v.vecPair_ || 
00105           (
00106            vecPair_ && v.vecPair_ &&
00107            ( (vecPair_->first) ? (vecPair_->second.second == v.vecPair_->second.second) 
00108              : (vecPair_->second.first == v.vecPair_->second.first) 
00109              )
00110            )
00111            )
00112   }
00113   */
00114   
00116   bool operator<(const DDValue &) const;
00117   /*{
00118     return id()<v.id() || 
00119       (
00120        id()==v.id() && 
00121        vecPair_ && v.vecPair_ &&
00122        ( (vecPair_->first) ? (vecPair_->second.second < v.vecPair_->second.second) 
00123          : (vecPair_->second.first < v.vecPair_->second.first)
00124          )
00125        )
00126   }
00127   */
00128   
00129 private:  
00130   typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > >vecpair_type;
00131   static std::vector<std::string>& names();
00132   static std::map<std::string,unsigned int>& indexer();
00133   static std::vector<boost::shared_ptr<vecpair_type> >& mem(vecpair_type*);
00134   //DDValue(const DDValue &);
00135   //DDValue & operator=(const DDValue &);
00136   //void destroy() { delete vecPair_;} //delete valPairs_; }
00137   
00138   //static std::vector<std::map<std::string,unsigned int>::const_iterator> names_;
00139   unsigned int id_;
00140   
00141   //Ptr<vecpair_type>  vecPair_;
00142 public:  
00143   vecpair_type* vecPair_;
00144 
00145 public:  
00146   //bool isEvaluated_;
00147   //auto_ptr<vecpair_type> vecPair_;
00148   //std::vector<DDValuePair> * valPairs_;
00149 };
00150 
00151 
00152 std::ostream & operator<<(std::ostream & o, const DDValue & v);
00153 #endif // DDValue_h