CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DetectorDescription/Core/src/DDSpecifics.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/Core/interface/DDSpecifics.h"
00002 #include "Specific.h"
00003 #include "DetectorDescription/Base/interface/DDdebug.h"
00004 #include "DetectorDescription/Base/interface/DDException.h"
00005 
00006 #include <utility>
00007 
00008 // Message logger.
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 
00011 using DDI::Specific;
00012 
00013 //DDBase<DDName,Specific*>::StoreT::pointer_type 
00014 //  DDBase<DDName,Specific*>::StoreT::instance_ = 0;
00015 
00016 DDSpecifics::DDSpecifics() : DDBase<DDName,Specific*>()
00017 { }
00018 
00019 
00020 DDSpecifics::DDSpecifics(const DDName & name) : DDBase<DDName,Specific*>()
00021 {
00022   prep_ = StoreT::instance().create(name);
00023 }
00024 
00025 
00026 DDSpecifics::DDSpecifics(const DDName & name,
00027                          const selectors_type & partSelections,
00028                          const DDsvalues_type & svalues,
00029                          bool doRegex)
00030  : DDBase<DDName,Specific*>()
00031 {
00032   prep_ = StoreT::instance().create(name, new Specific(partSelections,svalues,doRegex));   
00033   typedef std::vector<std::pair<DDLogicalPart,std::pair<DDPartSelection*,DDsvalues_type*> > > strange_type;
00034   strange_type v;
00035   rep().updateLogicalPart(v);
00036   strange_type::iterator it = v.begin();
00037   for(; it != v.end(); ++it) {
00038     if (it->first.isDefined().second) {
00039       it->first.addSpecifics(it->second);
00040       DCOUT('C', "add specifics to LP: partsel=" << *(it->second.first) );
00041     }
00042     else {
00043       std::string serr("Definition of LogicalPart missing! name=");
00044       serr+= it->first.ddname().fullname();
00045       throw DDException(serr);
00046     }
00047   }
00048 } 
00049     
00050 
00051 DDSpecifics::~DDSpecifics() { }
00052 
00053 
00054 const std::vector<DDPartSelection> & DDSpecifics::selection() const //
00055 { 
00056   return rep().selection(); 
00057 }
00058   
00059 
00060 const DDsvalues_type & DDSpecifics::specifics() const
00061 { 
00062   return rep().specifics(); 
00063 }         
00064 
00065 bool DDSpecifics::nodes(DDNodes & result) const 
00066 {
00067    return rep().nodes(result);
00068 }
00069 
00078 std::pair<bool,DDExpandedView> DDSpecifics::node() const
00079 {
00080   return rep().node();
00081 }
00082         
00083 // void DDSpecifics::clear()
00084 // {
00085 //  StoreT::instance().clear();
00086 // }
00087 
00088                                                 
00089 std::ostream & operator<<( std::ostream  & os, const DDSpecifics & sp)
00090 {
00091   DDBase<DDName,DDI::Specific*>::def_type defined(sp.isDefined());
00092   if (defined.first) {
00093     os << *(defined.first) << " ";
00094     if (defined.second) {
00095       sp.rep().stream(os); 
00096     }
00097     else {
00098       os << "* specific not defined * ";  
00099     }
00100   }  
00101   else {
00102     os << "* specific not declared * ";  
00103   }  
00104   return os;
00105 
00106 }
00107 
00108 
00109 std::ostream & operator<<( std::ostream & os, const std::vector<std::string> & v)
00110 {
00111   std::vector<std::string>::const_iterator it = v.begin();
00112   for (; it!=v.end(); ++it) {
00113     os << *it << std::endl;
00114   }
00115   return os;
00116 }