SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ODDistrictCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A container for districts
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include "ODDistrict.h"
35 #include "ODDistrictCont.h"
41 #include <utils/xml/XMLSubSys.h>
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
55 
56 
58 
59 
60 std::string
61 ODDistrictCont::getRandomSourceFromDistrict(const std::string& name) const {
62  ODDistrict* district = get(name);
63  if (district == 0) {
64  throw InvalidArgument("There is no district '" + name + "'.");
65  }
66  return district->getRandomSource();
67 }
68 
69 
70 std::string
71 ODDistrictCont::getRandomSinkFromDistrict(const std::string& name) const {
72  ODDistrict* district = get(name);
73  if (district == 0) {
74  throw InvalidArgument("There is no district '" + name + "'.");
75  }
76  return district->getRandomSink();
77 }
78 
79 void
80 ODDistrictCont::loadDistricts(std::string districtfile) {
81  if (!FileHelpers::isReadable(districtfile)) {
82  throw ProcessError("Could not access network file '" + districtfile + "' to load.");
83  }
84  PROGRESS_BEGIN_MESSAGE("Loading districts from '" + districtfile + "'");
85  // build the xml-parser and handler
86  ODDistrictHandler handler(*this, districtfile);
87  if (!XMLSubSys::runParser(handler, districtfile, true)) {
89  } else {
91  }
92 }
93 
94 /****************************************************************************/
95