SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // A district (origin/destination) 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <vector> 00033 #include <string> 00034 #include <utility> 00035 #include <utils/common/UtilExceptions.h> 00036 #include <utils/common/Named.h> 00037 #include <utils/common/MsgHandler.h> 00038 #include "ODDistrict.h" 00039 00040 #ifdef CHECK_MEMORY_LEAKS 00041 #include <foreign/nvwa/debug_new.h> 00042 #endif // CHECK_MEMORY_LEAKS 00043 00044 00045 // =========================================================================== 00046 // method definitions 00047 // =========================================================================== 00048 ODDistrict::ODDistrict(const std::string& id) 00049 : Named(id) {} 00050 00051 00052 ODDistrict::~ODDistrict() {} 00053 00054 00055 void 00056 ODDistrict::addSource(const std::string& id, SUMOReal weight) { 00057 mySources.add(weight, id); 00058 } 00059 00060 00061 void 00062 ODDistrict::addSink(const std::string& id, SUMOReal weight) { 00063 mySinks.add(weight, id); 00064 } 00065 00066 00067 std::string 00068 ODDistrict::getRandomSource() const throw(OutOfBoundsException) { 00069 return mySources.get(); 00070 } 00071 00072 00073 std::string 00074 ODDistrict::getRandomSink() const throw(OutOfBoundsException) { 00075 return mySinks.get(); 00076 } 00077 00078 00079 unsigned int 00080 ODDistrict::sinkNumber() const { 00081 return (unsigned int) mySinks.getVals().size(); 00082 } 00083 00084 00085 unsigned int 00086 ODDistrict::sourceNumber() const { 00087 return (unsigned int) mySources.getVals().size(); 00088 } 00089 00090 00091 /****************************************************************************/ 00092