CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLSAX2ConfigHandler.cc
Go to the documentation of this file.
1 /***************************************************************************
2  DDLSAX2ConfigHandler.cc - description
3  -------------------
4  begin : Mon Oct 22 2001
5  email : case@ucdhep.ucdavis.edu
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * DDDParser sub-component of DDD *
11  * *
12  ***************************************************************************/
13 
17 
21 
22 #include <iostream>
23 
25  : doValidation_(false),
26  files_(),
27  urls_(),
28  schemaLocation_(),
29  cpv_(cpv)
30 {}
31 
33 {}
34 
35 // ---------------------------------------------------------------------------
36 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
37 //
38 // This is kind-of sneaky-cheating. Basically it ignores all elements except
39 // File elements, and displays attributes up to the name attribute because that
40 // is the only one it cares about at this time. Later we would need a mechanism
41 // to exclude and include sections based on the configuration if we proceed with
42 // that level of selectivity.
43 //
44 // The file name is passed back to DDLParser via SetDDLFileName in order to
45 // process this list of files later.
46 // ---------------------------------------------------------------------------
47 void
48 DDLSAX2ConfigHandler::startElement( const XMLCh* const uri,
49  const XMLCh* const localname,
50  const XMLCh* const qname,
51  const Attributes& attrs )
52 {
53 
54  ++elementCount_;
55  attrCount_ += attrs.getLength();
56 
57  std::string myelemname(StrX(qname).localForm());
58  DCOUT_V('P', "DetectorDescription/Parser/interface/DDLSAX2ConfigHandler::startElement" << myelemname << " started...");
59 
60  unsigned int numAtts = attrs.getLength();
61  unsigned int i = 0;
62  if (myelemname == "File")
63  {
64  std::string name="", url="";
65  while ( i < numAtts )
66  {
67  std::string myattname(StrX(attrs.getLocalName(i)).localForm());
68  std::string myvalue(StrX(attrs.getValue(i)).localForm());
69 
70  if (myattname == "name")
71  name=myvalue;
72  if (myattname == "url")
73  url=myvalue;
74  ++i;
75  }
76  DCOUT('P', "file name = " << name << " and url = " << url);
77  files_.push_back(name);
78  urls_.push_back(url);
79  }
80  else if (myelemname == "Root")
81  {
82  std::string fileName="", logicalPartName="";
83  while ( i < numAtts )
84  {
85  std::string myattname(StrX(attrs.getLocalName(i)).localForm());
86  std::string myvalue(StrX(attrs.getValue(i)).localForm());
87 
88  if (myattname == "fileName")
89  fileName = myvalue;
90  if (myattname == "logicalPartName")
91  logicalPartName = myvalue;
92  ++i;
93  }
94 
95  fileName = fileName.substr(0, fileName.find("."));
96  // std::cout << fileName << ":" << logicalPartName << " is the ROOT" << std::endl;
97  DDLogicalPart root(DDName(logicalPartName,fileName));
98  DDRootDef::instance().set(root);//DDName(logicalPartName, fileName));
100  // DDCompactView cpv;
101  //DDName rt(DDName(logicalPartName, fileName));
102  cpv_.setRoot(root);
103  DCOUT_V('P', std::string("DetectorDescription/Parser/interface/DDLSAX2ConfigHandler::startElement. Setting DDRoot LogicalPart=") + logicalPartName + std::string(" in ") + fileName);
104 
105  }
106  else if (myelemname == "Schema")
107  {
108  while ( i < numAtts )
109  {
110  std::string myattname(StrX(attrs.getLocalName(i)).localForm());
111  std::string myvalue(StrX(attrs.getValue(i)).localForm());
112  if (myattname == "schemaLocation")
113  schemaLocation_ = myvalue;
114  else if (myattname == "validation")
115  doValidation_ = (myvalue == "true" ? true : false);
116  ++i;
117  }
118  }
119  // std::cout << "DetectorDescription/Parser/interface/DDLSAX2ConfigHandler::startElement " << myelemname << " completed..." << std::endl;
120 }
121 
122 const std::vector<std::string>&
124 {
125  return files_;
126 }
127 
128 const std::vector<std::string>&
130 {
131  return urls_;
132 }
133 
134 const std::string
136 {
137  return schemaLocation_;
138 }
139 
140 const bool
142 {
143  return doValidation_;
144 }
int i
Definition: DBlmapReader.cc:9
const std::string getSchemaLocation() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
std::vector< std::string > files_
type of data representation of DDCompactView
Definition: DDCompactView.h:81
unsigned int elementCount_
void setRoot(const DDLogicalPart &root)
don&#39;t use : interface not stable ....
static value_type & instance()
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
std::vector< std::string > urls_
def qname
Definition: asciidump.py:315
const std::vector< std::string > & getURLs() const
Definition: StrX.h:32
DDLSAX2ConfigHandler(DDCompactView &cpv)
unsigned int attrCount_
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
const std::vector< std::string > & getFileNames() const
const bool doValidation() const
XERCES_CPP_NAMESPACE::Attributes Attributes
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
string root
initialization
Definition: dbtoconf.py:70