SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDevice_BTsender.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A BT sender
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
34 #include <microsim/MSNet.h>
35 #include <microsim/MSLane.h>
36 #include <microsim/MSEdge.h>
37 #include <microsim/MSVehicle.h>
38 #include "MSDevice_Tripinfo.h"
39 #include "MSDevice_BTsender.h"
40 
41 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 // ---------------------------------------------------------------------------
50 // static initialisation methods
51 // ---------------------------------------------------------------------------
52 void
54  oc.addOptionSubTopic("Communication");
55  insertDefaultAssignmentOptions("btsender", "Communication", oc);
56 }
57 
58 
59 void
60 MSDevice_BTsender::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
62  if (equippedByDefaultAssignmentOptions(oc, "btsender", v)) {
63  MSDevice_BTsender* device = new MSDevice_BTsender(v, "btsender_" + v.getID());
64  into.push_back(device);
65  }
66 }
67 
68 
69 // ---------------------------------------------------------------------------
70 // MSDevice_BTsender-methods
71 // ---------------------------------------------------------------------------
72 MSDevice_BTsender::MSDevice_BTsender(SUMOVehicle& holder, const std::string& id)
73  : MSDevice(holder, id), myReportRoute(false) {
74 }
75 
76 
78 }
79 
80 
81 void
83  if (myReportRoute) {
85  os.openTag("found");
86  os.writeAttr("id", myHolder.getID());
87  os.writeAttr("route", myHolder.getRoute().getEdges());
88  os.closeTag();
89  }
90 }
91 
92 
93 
94 /****************************************************************************/
95 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
void generateOutput() const
Called on writing tripinfo output.
virtual const MSRoute & getRoute() const =0
Returns the current route.
~MSDevice_BTsender()
Destructor.
SUMOVehicle & myHolder
The vehicle that stores the device.
Definition: MSDevice.h:151
const MSEdgeVector & getEdges() const
Definition: MSRoute.h:122
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
Representation of a vehicle.
Definition: SUMOVehicle.h:63
MSDevice_BTsender(SUMOVehicle &holder, const std::string &id)
Constructor.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:76
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTsender-options.
Abstract in-vehicle device.
Definition: MSDevice.h:68
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.cpp:90
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool myReportRoute
Whether the vehicle shall report it&#39;s route.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.