NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
simulation_route_impl.h
Go to the documentation of this file.
1 
9 #ifndef SDK_NAVBOX_SIMULATION_ROUTE_IMPL_H_
10 #define SDK_NAVBOX_SIMULATION_ROUTE_IMPL_H_
11 #pragma once
12 
13 #include <map>
14 #include <base/inc/platform.h>
15 #include <base/inc/exception.h>
17 #include <base/inc/sdk_component_base.h>
19 #include <base/inc/interfaces/properties/properties_impl.h>
21 
22 SDK_NAVBOX_CLIENT_BEGIN_NAMESPACE
23 
26 FWD_DECL_INTERFACE(SimulationRoute)
27 FWD_DECL_INTERFACE(SimulationShipModelParams)
28 
29 class SimulationWaypoint : public SDKComponentBaseI<ISimulationWaypoint> {
30 public:
32  ~SimulationWaypoint() {}
33 
35  virtual SDKResult SDK_CALLTYPE GetPosition(
36  SDKGeoPoint& pos) const throw() {
37  try
38  {
39  if (SDK_FAILED(GetPropertyT(kSimulationWaypointProperty_Lat, pos.lat)) ||
40  SDK_FAILED(GetPropertyT(kSimulationWaypointProperty_Lon, pos.lon))) {
41  return Err_NotExist;
42  }
43  return Ok;
44  } SDK_CATCH_RET(Err_Unexpected)
45  }
46 
48  virtual SDKResult SDK_CALLTYPE GetProperty(
50  SDKAny& value) const throw() {
51  try
52  {
53  std::map<SDKUInt32, ScopedAny >::const_iterator it =
54  m_properties.find(id);
55  if (it == m_properties.end())
56  return Err_NotExist;
57  value = ScopedAny(it->second).Detach();
58  return Ok;
59  } SDK_CATCH_RET(Err_Unexpected)
60  }
61 
62  void SetProperty(SimulationWaypointProperty id, const ScopedAny& value) {
63  m_properties[id] = value;
64  }
65 
66 private:
67  std::map<SDKUInt32, ScopedAny> m_properties;
68 };
69 
70 class SimulationRoute : public SDKComponentBaseI<ISimulationRoute> {
71 public:
72  SimulationRoute() {}
73  ~SimulationRoute() {}
74 
76  virtual SDKResult SDK_CALLTYPE GetWaypointsCount(
77  SDKUInt32& count) const throw() {
78  try
79  {
80  count = m_waypoints.size();
81  return Ok;
82  } SDK_CATCH_RET(Err_Unexpected)
83  }
84 
86  virtual SDKResult SDK_CALLTYPE GetWaypoint(
87  SDKUInt32 index,
88  ISimulationWaypointSP& waypoint) const throw() {
89  try
90  {
91  if (index >= m_waypoints.size())
92  return Err_OutOfRange;
93  waypoint = m_waypoints[index];
94  return Ok;
95  } SDK_CATCH_RET(Err_Unexpected)
96  }
97 
99  virtual SDKResult SDK_CALLTYPE GetDepartureTime(
100  SDKTime& ti) const throw() {
101  try
102  {
103  ISimulationWaypointSP waypoint;
104  if (SDK_FAILED(GetWaypoint(0, waypoint)))
105  return Err_NotExist;
106  return waypoint->GetPropertyT(kSimulationWaypointProperty_Time, ti);
107  } SDK_CATCH_RET(Err_Unexpected)
108  }
109 
110  void PushWaypoint(const ISimulationWaypointSP waypoint) {
111  if (waypoint)
112  m_waypoints.push_back(waypoint);
113  }
114 
115 private:
116  std::vector<ISimulationWaypointSP> m_waypoints;
117 };
118 
119 class SimulationShipModelParams :
120  public PropertiesMap<ISimulationShipModelParams>
121 {
122 public:
123  SimulationShipModelParams() {}
124  ~SimulationShipModelParams() {}
125 
127  virtual SDKResult SDK_CALLTYPE GetDeadweight(
128  double& deadweight) const throw() {
129  return GetProperty(kWNISimulationShipProperty_Deadweight,
130  SDKAnyReturnHelper<double>(deadweight));
131  }
132 
134  virtual SDKResult SDK_CALLTYPE SetDeadweight(
135  double deadweight) throw() {
136  return SetPropertyT(kWNISimulationShipProperty_Deadweight,
137  deadweight);
138  }
139 
141  virtual SDKResult SDK_CALLTYPE GetSummerDraft(
142  double& summer_draft) const throw() {
143  return GetProperty(kWNISimulationShipProperty_SummerDraft,
144  SDKAnyReturnHelper<double>(summer_draft));
145  }
146 
148  virtual SDKResult SDK_CALLTYPE SetSummerDraft(
149  double summer_draft) throw() {
150  return SetPropertyT(kWNISimulationShipProperty_SummerDraft,
151  summer_draft);
152  }
153 };
154 
155 SDK_NAVBOX_CLIENT_END_NAMESPACE
156 
157 #endif // SDK_NAVBOX_SIMULATION_ROUTE_IMPL_H_
sdk::SDKAnyHandler::Detach
SDKAny Detach() noexcept
Detaches the any contents.
Definition: sdk_any_handler.h:392
SimulationWaypointProperty
SimulationWaypointProperty
Definition: navbox_client_interfaces.h:240
navbox_client_interfaces.h
NavBox client interfaces.
sdk::Ok
@ Ok
Operation completed successfully.
Definition: sdk_results_enum.h:22
SDKResult
SDKInt32 SDKResult
Type of all error or return codes which SDK functions can end with.
Definition: sdk_results.h:17
SDKGeoPoint
Geo point in degree units.
Definition: geometry_base_types.h:1727
sdk::Err_Unexpected
@ Err_Unexpected
Not implemented.
Definition: sdk_results_enum.h:29
kSimulationWaypointProperty_Time
@ kSimulationWaypointProperty_Time
ETA/Departure time for first point.
Definition: navbox_client_interfaces.h:247
sdk::Err_OutOfRange
@ Err_OutOfRange
A value is out of range
Definition: sdk_results_enum.h:44
SDK_FAILED
#define SDK_FAILED(res)
Checks failed result.
Definition: sdk_results_enum.h:69
platform.h
Describes the platform constants.
sdk::Err_NotExist
@ Err_NotExist
Not exist.
Definition: sdk_results_enum.h:26
SDKTime
SDK_END_NAMESPACE typedef SDKInt64 SDKTime
Milliseconds from Unix epoch.
Definition: base_types.h:56
sdk_results_enum.h
SDK return values synonyms in the sdk namespace.
FWD_DECL_INTERFACE
FWD_DECL_INTERFACE(ILWEParserWrapper)
Provides a wrapper around the message parser to get, add or remove the.
SimulationWaypoint
Implementation of the IPortInfo interface.
Definition: simulation_route_impl.h:29
sdk_any_handler.h
Wrappers for work with SDKAny instance.