WSF
XWsfRouteNetwork.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef XWSFROUTENETWORK_HPP
16#define XWSFROUTENETWORK_HPP
17
18#include "wsf_export.h"
19
20#include <string>
21#include <vector>
22
23#include "UtInput.hpp"
24#include "UtMemory.hpp"
25#include "UtRandom.hpp"
26#include "WsfRouteNetwork.hpp"
27class WsfScenario;
28
34
36{
37public:
38 XWsfRouteNetwork() = default;
39 virtual ~XWsfRouteNetwork() = default;
40
42 virtual bool Initialize(const WsfScenario& aScenario);
43
45 virtual void Update(double /*aSimTime*/) {}
46
50 virtual bool ProcessInput(UtInput& aInput);
51
55 {
56 public:
58 : mRouteNetworkPtr(nullptr)
59 , mNetworkId(aNetworkId)
60 , mVehicleCount(0)
61 , mVehicleDensity(0.0)
62 {
63 }
64
65 virtual ~NetworkInput() = default;
66
67 virtual NetworkInput* Clone() const noexcept { return new NetworkInput{*this}; }
68
69 virtual bool Initialize() { return true; }
70
71 virtual void VerifyData(UtInput& aInput)
72 {
73 if ((mVehicleCount == 0) && (mVehicleDensity == 0.0))
74 {
75 throw UtInput::BadValue(aInput, "XWsfRouteNetwork must specify either 'vehicle_count' or 'vehicle_density'");
76 }
77
78 if ((mVehicleCount != 0) && (mVehicleDensity != 0.0))
79 {
80 throw UtInput::BadValue(aInput, "XWsfRouteNetwork cannot specify both 'vehicle_count' and 'vehicle_density'");
81 }
82 }
83
84 WsfRouteNetwork* mRouteNetworkPtr; // A pointer to the route network that mNetworkId represents.
85 // Note: This is only valid after simulation initialization.
86
87 WsfStringId mNetworkId; // String Id of the name of the road network
88 int mVehicleCount; // Total number of vehicles
89 double mVehicleDensity; // Vehicle density (vehicle / meter)
90
91 protected:
92 NetworkInput(const NetworkInput& aRhs) = default;
93 };
94
95protected:
96 XWsfRouteNetwork(const XWsfRouteNetwork& aSrc) = default;
98
99 virtual bool ProcessCommand(UtInput& aInput, NetworkInput& aNetworkInput);
100
101 using Networks = std::vector<ut::CloneablePtr<NetworkInput>>;
102
103 ut::Random mRandom;
105
106private:
107 bool ProcessNetworkBlock(UtInput& aInput, NetworkInput& aNetworkInput);
108};
109
110#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
A collection of WsfRoute object that represents a connected network (such as a road network).
Definition WsfRouteNetwork.hpp:40
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition XWsfRouteNetwork.hpp:55
WsfStringId mNetworkId
Definition XWsfRouteNetwork.hpp:87
WsfRouteNetwork * mRouteNetworkPtr
Definition XWsfRouteNetwork.hpp:84
NetworkInput(WsfStringId aNetworkId)
Definition XWsfRouteNetwork.hpp:57
virtual NetworkInput * Clone() const noexcept
Definition XWsfRouteNetwork.hpp:67
double mVehicleDensity
Definition XWsfRouteNetwork.hpp:89
int mVehicleCount
Definition XWsfRouteNetwork.hpp:88
virtual bool Initialize()
Definition XWsfRouteNetwork.hpp:69
virtual ~NetworkInput()=default
NetworkInput(const NetworkInput &aRhs)=default
virtual void VerifyData(UtInput &aInput)
Definition XWsfRouteNetwork.hpp:71
virtual bool Initialize(const WsfScenario &aScenario)
If Initialize is redefined, make sure to call XWsfRouteNetwork::Initialize().
Definition XWsfRouteNetwork.cpp:27
XWsfRouteNetwork()=default
XWsfRouteNetwork & operator=(const XWsfRouteNetwork &aRhs)=delete
virtual ~XWsfRouteNetwork()=default
virtual bool ProcessCommand(UtInput &aInput, NetworkInput &aNetworkInput)
Definition XWsfRouteNetwork.cpp:110
Networks mNetworks
Definition XWsfRouteNetwork.hpp:104
std::vector< ut::CloneablePtr< NetworkInput > > Networks
Definition XWsfRouteNetwork.hpp:101
ut::Random mRandom
Definition XWsfRouteNetwork.hpp:103
virtual void Update(double)
An update method for applications that need simulation updates.
Definition XWsfRouteNetwork.hpp:45
XWsfRouteNetwork(const XWsfRouteNetwork &aSrc)=default
Copyrights Multiple, All Rights Reserved