CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DetectorDescription/Core/interface/DDValue.h

Go to the documentation of this file.
00001 #ifndef DDValue_h
00002 #define DDValue_h
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <vector>
00007 #include <map>
00008 #include <memory>
00009 
00010 #include "DetectorDescription/Core/interface/DDValuePair.h"
00011 
00012 #include "boost/shared_ptr.hpp"
00013 
00014 class DDValue;
00015 class DDSpecifics;
00016 class DDLSpecPar;
00017 
00025 class DDValue
00026 {
00027   friend class DDSpecifics;
00028   friend class DDLSpecPar;
00029 public:
00031   DDValue( void ) : id_(0), vecPair_(0) { }
00032   
00034   DDValue( const std::string & );
00035 
00037   DDValue( const char * );
00038  
00039   void init( const std::string & );
00040  
00042   explicit DDValue( const std::string &, const std::vector<DDValuePair>& );
00043   
00045   explicit DDValue( const std::string &, double );
00046   
00048   explicit DDValue( const std::string &, const std::string &, double );
00049   
00051   explicit DDValue( const std::string & name, const std::string & val );
00052   
00053   explicit DDValue( unsigned int );
00054   
00055   ~DDValue( void );
00056   
00058   unsigned int id( void ) const { return id_; }
00059   
00061   operator unsigned int( void ) const { return id_; }
00062   
00064   const std::string & name( void ) 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( void );
00083   
00085   void setEvalState( bool newState ); 
00086   
00088 
00090   bool isEvaluated( void ) const;
00091   
00093 
00095   bool operator==( const DDValue & v ) const;
00096   
00098   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 
00106   unsigned int id_;
00107   
00108 public:  
00109   vecpair_type* vecPair_;
00110 };
00111 
00112 std::ostream & operator<<(std::ostream & o, const DDValue & v);
00113 
00114 #endif // DDValue_h