SUMO - Simulation of Urban MObility
Subscription.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 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 /****************************************************************************/
15 // Subscription representation for libsumo and TraCI
16 /****************************************************************************/
17 #ifndef Subscription_h
18 #define Subscription_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <vector>
25 #include <libsumo/TraCIDefs.h>
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
31 namespace libsumo {
32 
36  // No filters
38  // Filter by list of lanes relative to ego vehicle
40  // Exclude vehicles on opposite (and other) lanes from context subscription result
42  // Specify maximal downstream distance for vehicles in context subscription result
44  // Specify maximal upstream distance for vehicles in context subscription result
46  // Only return leader and follower in context subscription result
48  // Only return leader and follower on ego and neighboring lane in context subscription result
50  // Only return foes on upcoming junction in context subscription result
52  // Only return vehicles of the given vClass in context subscription result
54  // Only return vehicles of the given vType in context subscription result
56 };
57 
58 
59 
63 class Subscription {
64 public:
74  Subscription(int commandIdArg, const std::string& idArg,
75  const std::vector<int>& variablesArg, const std::vector<std::vector<unsigned char> >& paramsArg,
76  SUMOTime beginTimeArg, SUMOTime endTimeArg, int contextDomainArg, double rangeArg)
77  : commandId(commandIdArg), id(idArg), variables(variablesArg), parameters(paramsArg), beginTime(beginTimeArg), endTime(endTimeArg),
78  contextDomain(contextDomainArg), range(rangeArg), activeFilters(SUBS_FILTER_NONE),
80 
82  int commandId;
84  std::string id;
86  std::vector<int> variables;
88  std::vector<std::vector<unsigned char> > parameters;
96  double range;
97 
101  std::vector<int> filterLanes;
107  std::vector<std::string> filterVTypes;
110 };
111 
113 public:
115  typedef bool(*SubscriptionHandler)(const std::string& objID, const int variable, VariableWrapper* wrapper);
116  VariableWrapper(SubscriptionHandler handler = nullptr) : handle(handler) {}
117  SubscriptionHandler handle;
118  virtual void setContext(const std::string& /* refID */) {}
119  virtual bool wrapDouble(const std::string& objID, const int variable, const double value) = 0;
120  virtual bool wrapInt(const std::string& objID, const int variable, const int value) = 0;
121  virtual bool wrapString(const std::string& objID, const int variable, const std::string& value) = 0;
122  virtual bool wrapStringList(const std::string& objID, const int variable, const std::vector<std::string>& value) = 0;
123  virtual bool wrapPosition(const std::string& objID, const int variable, const TraCIPosition& value) = 0;
124  virtual bool wrapColor(const std::string& objID, const int variable, const TraCIColor& value) = 0;
125 };
126 }
127 
128 
129 #endif
Representation of a subscription.
Definition: Subscription.h:63
long long int SUMOTime
Definition: SUMOTime.h:36
double range
The range of the context.
Definition: Subscription.h:96
Subscription(int commandIdArg, const std::string &idArg, const std::vector< int > &variablesArg, const std::vector< std::vector< unsigned char > > &paramsArg, SUMOTime beginTimeArg, SUMOTime endTimeArg, int contextDomainArg, double rangeArg)
Constructor.
Definition: Subscription.h:74
virtual void setContext(const std::string &)
Definition: Subscription.h:118
VariableWrapper(SubscriptionHandler handler=nullptr)
Definition: Subscription.h:116
SUMOTime beginTime
The begin time of the subscription.
Definition: Subscription.h:90
SUMOTime endTime
The end time of the subscription.
Definition: Subscription.h:92
std::string id
The id of the object that is subscribed.
Definition: Subscription.h:84
SubscriptionFilterType
Filter types for context subscriptions.
Definition: Subscription.h:35
int commandId
commandIdArg The command id of the subscription
Definition: Subscription.h:82
int activeFilters
Active filters for the subscription (bitset,.
Definition: Subscription.h:99
int contextDomain
The domain ID of the context.
Definition: Subscription.h:94
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
Definition: Subscription.h:103
int filterVClasses
vClasses specified by the vClasses filter,
Definition: Subscription.h:109
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
Definition: Subscription.h:105
Definition: Edge.cpp:30
std::vector< std::vector< unsigned char > > parameters
The parameters for the subscribed variables.
Definition: Subscription.h:88
SubscriptionHandler handle
Definition: Subscription.h:117
std::vector< int > variables
The subscribed variables.
Definition: Subscription.h:86
A 3D-position.
Definition: TraCIDefs.h:107
std::vector< std::string > filterVTypes
vTypes specified by the vTypes filter
Definition: Subscription.h:107
std::vector< int > filterLanes
lanes specified by the lanes filter
Definition: Subscription.h:101