CMS 3D CMS Logo

DDLMap Class Reference

DDLMap handles Map container. More...

#include <DetectorDescription/Parser/src/DDLMap.h>

Inheritance diagram for DDLMap:

DDXMLElement

List of all members.

Public Member Functions

 DDLMap ()
ReadMapType< std::map
< std::string, double > > & 
getMapOfMaps ()
void preProcessElement (const std::string &name, const std::string &nmspace)
 Called by loadAttributes AFTER attributes are loaded.
void processElement (const std::string &name, const std::string &nmspace)
 Processing the element.
 ~DDLMap ()

Private Member Functions

void do_makeDouble (char const *str, char const *end)
void do_makeName (char const *str, char const *end)
void do_pair (char const *str, char const *end)
void errorOut (const char *str)

Private Attributes

double pDouble
dd_map_type pMap
ReadMapType< std::map
< std::string, double > > 
pMapMap
std::string pName
std::string pNameSpace

Friends

class MapMakeDouble
class MapMakeName
class MapPair


Detailed Description

DDLMap handles Map container.

Author:
Michael Case
DDLMap.h - description ------------------- begin: Fri Nov 28, 2003 email: case@ucdhep.ucdavis.edu

This is the Map container. It is a c++ stye std::map <std::string, double> and has a name associated with the Map for the DDD name-reference system.

Definition at line 59 of file DDLMap.h.


Constructor & Destructor Documentation

DDLMap::DDLMap (  ) 

Definition at line 30 of file DDLMap.cc.

00031 {
00032 }

DDLMap::~DDLMap (  ) 

Definition at line 34 of file DDLMap.cc.

00035 {
00036 }


Member Function Documentation

void DDLMap::do_makeDouble ( char const *  str,
char const *  end 
) [private]

Definition at line 162 of file DDLMap.cc.

References DDI::Singleton< I >::instance(), pDouble, and pNameSpace.

Referenced by MapMakeDouble::operator()().

00163 {
00164   std::string ts(str, end);
00165   pDouble = ExprEvalSingleton::instance().eval(pNameSpace, ts);
00166 }

void DDLMap::do_makeName ( char const *  str,
char const *  end 
) [private]

Definition at line 157 of file DDLMap.cc.

References pName.

Referenced by MapMakeName::operator()().

00158 {
00159   pName = std::string(str, end); 
00160 }

void DDLMap::do_pair ( char const *  str,
char const *  end 
) [private]

Definition at line 152 of file DDLMap.cc.

References pDouble, pMap, and pName.

Referenced by MapPair::operator()().

00153 {
00154   pMap[pName] = pDouble;
00155 }

void DDLMap::errorOut ( const char *  str  )  [private]

Definition at line 168 of file DDLMap.cc.

References alivecheck_mergeAndRegister::msg, and DDXMLElement::throwError().

Referenced by processElement().

00169 {
00170      std::string msg("\nDDLMap: Failed to parse the following: \n");
00171      msg+= std::string(str);
00172      msg+="\n as a Map element (comma separated list of name=value).";
00173      throwError(msg);
00174 }

ReadMapType< std::map< std::string, double > > & DDLMap::getMapOfMaps (  ) 

Definition at line 176 of file DDLMap.cc.

References pMapMap.

Referenced by DDLAlgorithm::processElement().

00177 {
00178   return pMapMap;
00179 }

void DDLMap::preProcessElement ( const std::string &  name,
const std::string &  nmspace 
) [virtual]

Called by loadAttributes AFTER attributes are loaded.

The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.

This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.

Reimplemented from DDXMLElement.

Definition at line 87 of file DDLMap.cc.

References pDouble, pMap, pName, and pNameSpace.

00088 {
00089   pName = "";
00090   pMap.clear() ;
00091   //pMapMap.clear(); only the DDLAlgorithm is allowed to clear this guy!
00092   pDouble = 0.0;
00093   pNameSpace = nmspace;
00094 }

void DDLMap::processElement ( const std::string &  name,
const std::string &  nmspace 
) [virtual]

Processing the element.

The processElement method completes any necessary work to process the XML element.

For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.

Reimplemented from DDXMLElement.

Definition at line 96 of file DDLMap.cc.

References DDXMLElement::clear(), DCOUT_V, errorOut(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDXMLElement::getText(), info, DDI::Singleton< I >::instance(), it, m, DDXMLElement::parent(), parse(), pMap, pMapMap, and pNameSpace.

00097 {
00098   DCOUT_V('P', "DDLMap::processElement started");
00099 
00100   std::string tTextToParse = getText();
00101   DDXMLAttribute atts = getAttributeSet();
00102   std::string tName = atts.find("name")->second;
00103 
00104   if (tTextToParse.size() == 0)
00105     {
00106       errorOut("No std::string to parse!");
00107     }
00108 
00109   // NOT IMPLEMENTED YET
00110   if (atts.find("type") != atts.end() && atts.find("type")->second == "string")
00111     {
00112       errorOut("Map of type std::string is not supported yet.");
00113     }
00114 
00115   Mapper mapGrammar;
00116   
00117   pMap.clear();
00118 
00119   parse_info<> info = boost::spirit::parse(tTextToParse.c_str(), mapGrammar >> end_p, space_p);
00120   if (!info.full)
00121     {
00122       errorOut("Does not conform to name=value, name=value... etc. of ddl Map element.");
00123     }
00124 
00125   if (parent() == "Algorithm" || parent() == "SpecPar")
00126     {
00127       pMapMap[tName] = pMap;
00128     }
00129   else if (parent() == "ConstantsSection" || parent() == "DDDefinition") 
00130     {
00131       dd_map_type * tMap = new dd_map_type;
00132       for (std::map<std::string, double>::const_iterator it = pMap.begin(); it != pMap.end(); ++it)
00133         {
00134           (*tMap)[it->first] = it->second;
00135         }
00136       DDMap m ( getDDName(pNameSpace) , tMap);
00137       // clear the map of maps, because in these elements we only have ONE at a time.
00138       pMapMap.clear(); 
00139     }
00140 
00141   std::string nEntries = atts.find("nEntries")->second;
00142   if (pMap.size() != 
00143       size_t(ExprEvalSingleton::instance().eval(pNameSpace, nEntries)))
00144     {
00145       errorOut("Number of entries found in Map text does not match number in attribute nEntries.");
00146     }
00147   clear();
00148   
00149   DCOUT_V('P', "DDLMap::processElement completed");
00150 }


Friends And Related Function Documentation

friend class MapMakeDouble [friend]

Definition at line 63 of file DDLMap.h.

Referenced by Mapper::definition< ScannerT >::definition().

friend class MapMakeName [friend]

Definition at line 62 of file DDLMap.h.

Referenced by Mapper::definition< ScannerT >::definition().

friend class MapPair [friend]

Definition at line 61 of file DDLMap.h.

Referenced by Mapper::definition< ScannerT >::definition().


Member Data Documentation

double DDLMap::pDouble [private]

Definition at line 80 of file DDLMap.h.

Referenced by do_makeDouble(), do_pair(), and preProcessElement().

dd_map_type DDLMap::pMap [private]

Definition at line 78 of file DDLMap.h.

Referenced by do_pair(), preProcessElement(), and processElement().

ReadMapType<std::map<std::string,double> > DDLMap::pMapMap [private]

Definition at line 79 of file DDLMap.h.

Referenced by getMapOfMaps(), and processElement().

std::string DDLMap::pName [private]

Definition at line 81 of file DDLMap.h.

Referenced by do_makeName(), do_pair(), and preProcessElement().

std::string DDLMap::pNameSpace [private]

Definition at line 82 of file DDLMap.h.

Referenced by do_makeDouble(), preProcessElement(), and processElement().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:00 2009 for CMSSW by  doxygen 1.5.4