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