Router.h 3.81 KB
Newer Older
1
/**
2
3
 * \file        Router.h
 * \date        Nov 11, 2010
4
5
 * \version     v0.7
 * \copyright   <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
6
 *
7
 * \section License
8
9
10
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Lesser General Public License as published by
12
13
14
15
16
17
18
19
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * JuPedSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
20
21
 * You should have received a copy of the GNU Lesser General Public License
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 * \section Description
24
25
 * virtual base class for all routers.
 * Each router implementation should be derived from this class.
26
 *
27
28
29
 *
 **/

Ulrich Kemloh's avatar
Ulrich Kemloh committed
30

31
#ifndef _ROUTER_H
Mohcine Chraibi's avatar
Mohcine Chraibi committed
32
#define  _ROUTER_H
Ulrich Kemloh's avatar
Ulrich Kemloh committed
33

Ulrich Kemloh's avatar
Ulrich Kemloh committed
34
#include <vector>
Ulrich Kemloh's avatar
Ulrich Kemloh committed
35

Ulrich Kemloh's avatar
Ulrich Kemloh committed
36
#include "../general/Macros.h"
37
#include "../geometry/Trips.h"
Ulrich Kemloh's avatar
Ulrich Kemloh committed
38

Ulrich Kemloh's avatar
Ulrich Kemloh committed
39
40
class Building;
class Pedestrian;
Ulrich Kemloh's avatar
Ulrich Kemloh committed
41

42
class Router {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
43
44
45
46
47
48
     /** @defgroup Router
      * Collection of different router classes
      * [documentation](http://www.jupedsim.org/jpscore/2016-11-03-routing.html)
      *  @{
      */
     /** @} */ // end of group
49

50
private:
51
     /// routing strategy ID as defined in the Macros.h file
52
53
54
55
56
57
58
59
     RoutingStrategy _strategy;

     /// the id as present in the persons.xml file
     int _id;

protected:

     /// Contain the ids of the intermediate destinations
60
     Trips _trips;
61
62
63
64
65

     /// All final destinations of the pedestrians
     std::vector<int> _finalDestinations;

public:
66
67
68
69

     /**
      * Constructor
      */
70
     Router();
71
72
73
74
75
76

     /**
      * Constructor
      * @param id
      * @param s
      */
77
     Router(int id, RoutingStrategy s);
78

79
80
81
     /**
      * Destructor
      */
82
83
84
85
86
87
     virtual ~Router();

     /**
      * Add a new trip to this router
      * @param trip A vector containing the IDs of the intermediate destination
      */
tobias schroedter's avatar
tobias schroedter committed
88
//     void AddTrip(std::vector<int> trip);
89
90
91
92
93
94
95
96
97
98

     /**
      * Add a new final destination to this router
      * @param id of an intermediate destination as presented in the geometry/routing files
      */
     void AddFinalDestinationID(int id);

     /**
      * @return a vector containing the IDs of the intermediate destinations
      */
tobias schroedter's avatar
tobias schroedter committed
99
//     const std::vector<int> GetTrip(int id) const;
100
101
102
103
104
105
106
107
108
109
110
111
112

     /**
      * @return all final destinations
      */
     const std::vector<int> GetFinalDestinations() const;

     /**
      * @return the id of the router as defined in the person file
      */
     int GetID() const;

     /**
      * The strategy is automatically set based on the description in the
Ulrich Kemloh's avatar
Ulrich Kemloh committed
113
      * ini file.
114
      */
115
     void SetStrategy(const RoutingStrategy& strategy);
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

     /**
      * The strategy is automatically set based on the description in the
      * person file.
      */
     RoutingStrategy GetStrategy() const;

     /**
      * Find the next suitable target for Pedestrian p
      * @param p the Pedestrian
      * @return -1 in the case no destination could be found
      */
     virtual int FindExit(Pedestrian* p) = 0;

     /**
      * Each implementation of this virtual class has the possibility to initialize
      * its Routing engine using the supplied building object.
      * @param b the building object
      */
135
     virtual bool Init(Building* b) = 0;
Ulrich Kemloh's avatar
Ulrich Kemloh committed
136

137
138
139
140
141
142
     /**
      * Parse additional parameters provided for the specific router
      * @return
      */
     virtual bool ParseAdditionalParameters(){return true;};

143
144
     void SetTrips(const Trips& trips);

tobias schroedter's avatar
tobias schroedter committed
145
146
147
148
     /**
      * Update the router, when geometry changed due to external changes.
      * Remark: Depends on router if needed!
      */
149
     virtual void Update();
Ulrich Kemloh's avatar
Ulrich Kemloh committed
150
151
};

Mohcine Chraibi's avatar
Mohcine Chraibi committed
152
#endif  /* _ROUTING_H */