Eclipse SUMO - Simulation of Urban MObility
ODDistrict.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A district (origin/destination)
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <vector>
26 #include <string>
27 #include <utility>
29 #include <utils/common/Named.h>
31 #include "ODDistrict.h"
32 
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 ODDistrict::ODDistrict(const std::string& id)
39  : Named(id) {}
40 
41 
43 
44 
45 void
46 ODDistrict::addSource(const std::string& id, double weight) {
47  mySources.add(id, weight);
48 }
49 
50 
51 void
52 ODDistrict::addSink(const std::string& id, double weight) {
53  mySinks.add(id, weight);
54 }
55 
56 
57 std::string
59  return mySources.get();
60 }
61 
62 
63 std::string
65  return mySinks.get();
66 }
67 
68 
69 int
71  return (int) mySinks.getVals().size();
72 }
73 
74 
75 int
77  return (int) mySources.getVals().size();
78 }
79 
80 
81 
82 /****************************************************************************/
83 
RandomDistributor::add
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
Definition: RandomDistributor.h:70
Named
Base class for objects which have an id.
Definition: Named.h:56
ODDistrict::~ODDistrict
~ODDistrict()
Destructor.
Definition: ODDistrict.cpp:42
MsgHandler.h
ODDistrict::mySources
RandomDistributor< std::string > mySources
Container of weighted sources.
Definition: ODDistrict.h:127
ODDistrict::sinkNumber
int sinkNumber() const
Returns the number of sinks.
Definition: ODDistrict.cpp:70
ODDistrict::addSink
void addSink(const std::string &id, double weight)
Adds a sink connection.
Definition: ODDistrict.cpp:52
RandomDistributor::get
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
Definition: RandomDistributor.h:113
Named.h
ODDistrict::addSource
void addSource(const std::string &id, double weight)
Adds a source connection.
Definition: ODDistrict.cpp:46
UtilExceptions.h
ODDistrict::sourceNumber
int sourceNumber() const
Returns the number of sources.
Definition: ODDistrict.cpp:76
ODDistrict::mySinks
RandomDistributor< std::string > mySinks
Container of weighted sinks.
Definition: ODDistrict.h:130
ODDistrict::getRandomSink
std::string getRandomSink() const
Returns the id of a sink to use.
Definition: ODDistrict.cpp:64
ODDistrict::ODDistrict
ODDistrict(const std::string &id)
Constructor.
Definition: ODDistrict.cpp:38
config.h
ODDistrict.h
RandomDistributor::getVals
const std::vector< T > & getVals() const
Returns the members of the distribution.
Definition: RandomDistributor.h:151
ODDistrict::getRandomSource
std::string getRandomSource() const
Returns the id of a source to use.
Definition: ODDistrict.cpp:58