CMS 3D CMS Logo

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