PCTypeDefHandler.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <string>
00031 #include <utils/options/OptionsCont.h>
00032 #include <utils/common/MsgHandler.h>
00033 #include <utils/common/StringTokenizer.h>
00034 #include <utils/common/UtilExceptions.h>
00035 #include <utils/xml/SUMOSAXHandler.h>
00036 #include <utils/xml/SUMOXMLDefinitions.h>
00037 #include <utils/common/RGBColor.h>
00038 #include "PCTypeMap.h"
00039 #include "PCTypeDefHandler.h"
00040
00041 #ifdef CHECK_MEMORY_LEAKS
00042 #include <foreign/nvwa/debug_new.h>
00043 #endif // CHECK_MEMORY_LEAKS
00044
00045
00046
00047
00048
00049 PCTypeDefHandler::PCTypeDefHandler(OptionsCont &oc, PCTypeMap &con) throw()
00050 : SUMOSAXHandler("Detector-Defintion"),
00051 myOptions(oc), myContainer(con) {}
00052
00053
00054 PCTypeDefHandler::~PCTypeDefHandler() throw() {}
00055
00056
00057 void
00058 PCTypeDefHandler::myStartElement(SumoXMLTag element,
00059 const SUMOSAXAttributes &attrs) throw(ProcessError) {
00060 if (element==SUMO_TAG_POLYTYPE) {
00061
00062 std::string id;
00063 if (!attrs.setIDFromAttributes("polytype", id)) {
00064 return;
00065 }
00066 bool ok = true;
00067 int layer = attrs.getOptIntReporting(SUMO_ATTR_LAYER, "polytype", id.c_str(), ok, myOptions.getInt("layer"));
00068 bool discard = attrs.getOptBoolReporting(SUMO_ATTR_DISCARD, "polytype", id.c_str(), ok, false);
00069 bool allowFill = attrs.getOptBoolReporting(SUMO_ATTR_FILL, "polytype", id.c_str(), ok, true);
00070 std::string type = attrs.getOptStringReporting(SUMO_ATTR_NAME, "polytype", id.c_str(), ok, myOptions.getString("type"));
00071 std::string prefix = attrs.getOptStringReporting(SUMO_ATTR_PREFIX, "polytype", id.c_str(), ok, myOptions.getString("prefix"));
00072 std::string color = attrs.getOptStringReporting(SUMO_ATTR_COLOR, "polytype", id.c_str(), ok, myOptions.getString("color"));
00073
00074 if (!myContainer.add(id, type, color, prefix, layer, discard, allowFill)) {
00075 MsgHandler::getErrorInstance()->inform("Could not add polygon type '" + id + "' (probably the id is already used).");
00076 }
00077 }
00078 }
00079
00080
00081
00082