Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
PassengerRoadVehicle.cpp
Go to the documentation of this file.
1 
8 #include "tracer/tracer.h"
9 #include "util/StringUtils.h"
10 #include <iostream>
11 #include <sstream>
12 
13 namespace ODemo {
14 
15 using namespace std;
16 using namespace UA_CoMP::Util;
17 
18 PassengerRoadVehicle::PassengerRoadVehicle(int numSeats) : RoadVehicle(), m_capacity(numSeats), m_free(numSeats)
19 {
21 }
22 
24  : RoadVehicle(ori), m_capacity(ori.m_capacity), m_free(ori.m_free)
25 {
27 }
28 
30  : RoadVehicle(std::move(ori)), m_capacity(ori.m_capacity), m_free(ori.m_free)
31 {
33 }
34 
36 {
38  if (this != &rhs) {
40  m_capacity = rhs.m_capacity;
41  m_free = rhs.m_free;
42  }
43  return *this;
44 }
45 
47 {
49  if (this != &rhs) {
51  m_capacity = rhs.m_capacity;
52  m_free = rhs.m_free;
53  }
54  return *this;
55 }
56 
58 
60 {
62  bool added = false;
63  if (m_free > 0) {
64  m_free--;
65  added = true;
66  }
67  return added;
68 }
69 
71 {
73  bool removed = false;
74  if (m_free < m_capacity) {
75  m_free++;
76  removed = true;
77  }
78  return removed;
79 }
80 
82 {
84  return m_capacity;
85 }
86 
88 {
90  return m_free;
91 }
92 
94 {
96  const string s{"I'm a PassengerRoadVehicle: #seats = " + StringUtils::ToString(m_capacity) +
97  ", #free seats = " + StringUtils::ToString(m_free)};
99 }
100 
101 } // namespace ODemo
Comprehensive include file for all tracer classes.
A RoadVehicle is any kind of vehicle that moves on the road.
Definition: RoadVehicle.h:16
PassengerRoadVehicle & operator=(PassengerRoadVehicle const &rhs)
Copy assignment.
bool remove_passenger()
Remove a passenger, if possible.
int get_free() const
Return the number of seats still free.
#define COMP_MISC_MEMBER_TRACER
Macro for tracking member scope.
Definition: MemberTracer.h:21
~PassengerRoadVehicle() override
Destructor.
A PassengerRoadVehicle transports one or more passengers.
void info() const override
Return identification info.
static std::string ToString(T const &value)
Builds a string representation of a value of type T.
Definition: StringUtils.h:48
#define COMP_MISC_LOG_TRACER(MSG)
Macro for inserting log message into tracker output at current severity level.
Definition: TracerOutput.h:17
PassengerRoadVehicle(int numSeats)
Parametrized constructor, initializes number of seats.
Conversion from or to string.
int get_capacity() const
Return the number of seats on the vehicle.
bool add_passenger()
Take an additional passenger on board, if possible.
Header for PassengerRoadVehicle class.
RoadVehicle & operator=(const RoadVehicle &rhs)
Copy assignment operator.
Definition: RoadVehicle.cpp:20