DDLMap handles Map container. More...
#include <DDLMap.h>
Public Member Functions | |
DDLMap (DDLElementRegistry *myreg) | |
ReadMapType< std::map < std::string, double > > & | getMapOfMaps (void) |
void | preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. | |
virtual | ~DDLMap (void) |
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 |
DDLMap handles Map container.
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.
DDLMap::DDLMap | ( | DDLElementRegistry * | myreg | ) |
Definition at line 18 of file DDLMap.cc.
: DDXMLElement( myreg ) {}
void DDLMap::do_makeDouble | ( | char const * | str, |
char const * | end | ||
) | [private] |
Definition at line 155 of file DDLMap.cc.
References instance, pDouble, pNameSpace, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by MapMakeDouble::operator()().
{ std::string ts(str, end); pDouble = ExprEvalSingleton::instance().eval(pNameSpace, ts); }
void DDLMap::do_makeName | ( | char const * | str, |
char const * | end | ||
) | [private] |
Definition at line 149 of file DDLMap.cc.
References pName, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by MapMakeName::operator()().
{ pName = std::string(str, end); }
void DDLMap::do_pair | ( | char const * | str, |
char const * | end | ||
) | [private] |
void DDLMap::errorOut | ( | const char * | str | ) | [private] |
Definition at line 162 of file DDLMap.cc.
References lumiQueryAPI::msg, AlCaHLTBitMon_QueryRunRegistry::string, and DDXMLElement::throwError().
Referenced by processElement().
{ std::string msg("\nDDLMap: Failed to parse the following: \n"); msg+= std::string(str); msg+="\n as a Map element (comma separated list of name=value)."; throwError(msg); }
ReadMapType< std::map< std::string, double > > & DDLMap::getMapOfMaps | ( | void | ) |
Definition at line 171 of file DDLMap.cc.
References pMapMap.
Referenced by DDLAlgorithm::processElement().
{ return pMapMap; }
void DDLMap::preProcessElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [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 76 of file DDLMap.cc.
References pDouble, pMap, pName, and pNameSpace.
{ pName = ""; pMap.clear() ; //pMapMap.clear(); only the DDLAlgorithm is allowed to clear this guy! pDouble = 0.0; pNameSpace = nmspace; }
void DDLMap::processElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [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 86 of file DDLMap.cc.
References DDXMLElement::clear(), DCOUT_V, errorOut(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDXMLElement::getText(), info, DDI::Singleton< I >::instance(), m, DDXMLElement::parent(), triggerExpression::parse(), pMap, pMapMap, pNameSpace, and AlCaHLTBitMon_QueryRunRegistry::string.
{ DCOUT_V('P', "DDLMap::processElement started"); std::string tTextToParse = getText(); DDXMLAttribute atts = getAttributeSet(); std::string tName = atts.find("name")->second; if (tTextToParse.size() == 0) { errorOut("No std::string to parse!"); } // NOT IMPLEMENTED YET if (atts.find("type") != atts.end() && atts.find("type")->second == "string") { errorOut("Map of type std::string is not supported yet."); } Mapper mapGrammar; pMap.clear(); parse_info<> info = boost::spirit::classic::parse(tTextToParse.c_str(), mapGrammar >> end_p, space_p); if (!info.full) { errorOut("Does not conform to name=value, name=value... etc. of ddl Map element."); } if (parent() == "Algorithm" || parent() == "SpecPar") { pMapMap[tName] = pMap; } else if (parent() == "ConstantsSection" || parent() == "DDDefinition") { dd_map_type * tMap = new dd_map_type; for (std::map<std::string, double>::const_iterator it = pMap.begin(); it != pMap.end(); ++it) { (*tMap)[it->first] = it->second; } DDMap m ( getDDName(pNameSpace) , tMap); // clear the map of maps, because in these elements we only have ONE at a time. pMapMap.clear(); } std::string nEntries = atts.find("nEntries")->second; if (pMap.size() != size_t(ExprEvalSingleton::instance().eval(pNameSpace, nEntries))) { errorOut("Number of entries found in Map text does not match number in attribute nEntries."); } clear(); DCOUT_V('P', "DDLMap::processElement completed"); }
friend class MapMakeDouble [friend] |
friend class MapMakeName [friend] |
double DDLMap::pDouble [private] |
Definition at line 79 of file DDLMap.h.
Referenced by do_makeDouble(), do_pair(), and preProcessElement().
dd_map_type DDLMap::pMap [private] |
Definition at line 77 of file DDLMap.h.
Referenced by do_pair(), preProcessElement(), and processElement().
ReadMapType<std::map<std::string,double> > DDLMap::pMapMap [private] |
Definition at line 78 of file DDLMap.h.
Referenced by getMapOfMaps(), and processElement().
std::string DDLMap::pName [private] |
Definition at line 80 of file DDLMap.h.
Referenced by do_makeName(), do_pair(), and preProcessElement().
std::string DDLMap::pNameSpace [private] |
Definition at line 81 of file DDLMap.h.
Referenced by do_makeDouble(), preProcessElement(), and processElement().