CMS 3D CMS Logo

DDName.h

Go to the documentation of this file.
00001 #ifndef DDName_h
00002 #define DDName_h
00003 
00004 #include <utility>
00005 #include <string>
00006 #include <iostream>
00007 #include <map>
00008 #include <vector>
00009 #include <stdexcept>
00010 //#include "DetectorDescription/Base/interface/Singleton.h"
00011 
00012 class DDCurrentNamespace;
00013 class DDStreamer;
00014 
00016 
00018 class DDName // : public std::pair<std::string,std::string>
00019 {
00020   friend class DStreamer; // intrusive!
00021   
00022 public:
00023   
00024   typedef DDCurrentNamespace CNS;
00025   typedef int id_type;
00026   typedef std::map<std::pair<std::string,std::string>,id_type> Registry;
00027   typedef std::vector<Registry::const_iterator> IdToName;
00028 
00029   
00031   DDName( const std::string & name,
00032           const std::string & ns);
00033 
00035   DDName( const std::string & name );
00036   DDName( const char* name ); 
00037   DDName( const char* name, const char* ns );
00038   // DDName(pair<int,int>);
00039   DDName(id_type);
00041   static void defineId( const std::pair<std::string,std::string> &, id_type id);
00042 
00043   explicit DDName();
00044   
00046   static bool exists(const std::string & name, const std::string & ns);
00048   const std::string & name() const;
00049   
00051   const std::string & ns() const;
00052   
00053   operator std::string() const { return ns() + ":" + name(); }
00054   
00055   id_type id() const { return id_;}
00056     
00057   bool operator<(const DDName & rhs) const { return id_ < rhs.id_; }
00058   bool operator==(const DDName & rhs) const { return id_ == rhs.id_; }
00059 
00060 private:
00061   id_type id_;
00062     
00063   static Registry::iterator registerName(const std::pair<std::string,std::string> & s);  
00064 };
00065 
00067 
00071 struct DDNameInterface
00072 {
00073   virtual ~DDNameInterface() {}
00074   //virtual const DDName & ddName() const=0; // qualified Name
00075   
00077   virtual const std::string & name() const=0;   // name without namespace
00078   
00080   virtual const std::string & ns() const=0; // only the namespace 
00081   
00083   DDName ddname() const { return DDName(name(),ns()); } 
00084   
00085   virtual operator bool() const=0;
00086   
00088   virtual int id() const=0; // dont't know if usefull ...
00089 };
00090 
00091 std::ostream & operator<<(std::ostream & os, const DDName & n); 
00092 
00093 #endif

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