Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Motorcycle.h
Go to the documentation of this file.
1 #pragma once
2 
8 #include "objtracer/Body.h"
9 #include "objtracer/Engine.h"
10 #include "objtracer/Person.h"
11 #include "objtracer/Wheel.h"
12 #include <array>
13 #include <memory>
14 
15 namespace ODemo {
16 
21 {
22 public:
24  Motorcycle();
25 
27  explicit Motorcycle(std::shared_ptr<Engine> const& enginePtr);
28 
30  Motorcycle(std::shared_ptr<Engine> const& enginePtr, Person const* ownerPtr);
31 
33  Motorcycle(Motorcycle const& ori);
34 
36  Motorcycle(Motorcycle&& ori) noexcept;
37 
39  Motorcycle& operator=(Motorcycle const& rhs);
40 
42  Motorcycle& operator=(Motorcycle&& rhs) noexcept;
43 
45  ~Motorcycle();
46 
48  void startEngine();
49 
51  void stopEngine();
52 
54  void accelerate(double speed);
55 
57  void brake(double speed);
58 
60  void halt();
61 
62  // Turn with given number of degrees.
63  void turn(double degrees);
64 
66  double getSpeed() const;
67 
69  bool is_running() const;
70 
72  std::shared_ptr<Engine> get_engine();
73 
75  Person const* get_owner() const;
76 
78  void set_engine(std::shared_ptr<Engine> const& newEnginePtr);
79 
81  void set_owner(Person* newOwnerPtr);
82 
83 private:
84  std::shared_ptr<Engine> m_engine;
85  std::unique_ptr<Body> m_body;
86  const Person* m_owner;
87  std::array<Wheel, 2> m_wheels;
88  double m_speed;
89  double m_direction;
90 };
91 
92 } // namespace ODemo
~Motorcycle()
Destructor.
Definition: Motorcycle.cpp:103
Header for the Engine class used to demo object aggregation features.
std::shared_ptr< Engine > m_engine
Definition: Motorcycle.h:84
double getSpeed() const
Return current speed.
Definition: Motorcycle.cpp:167
Motorcycle with Engine and Owner.
Definition: Motorcycle.h:20
Header for Bicycle class.
std::unique_ptr< Body > m_body
Definition: Motorcycle.h:85
void stopEngine()
Stop the motorcycle engine.
Definition: Motorcycle.cpp:117
Header for the class Person.
A fairly simple class for Person.
Definition: Person.h:17
void brake(double speed)
Brake until given speed.
Definition: Motorcycle.cpp:142
void halt()
Brake to zero speed, keep engine running.
Definition: Motorcycle.cpp:153
bool is_running() const
Indicates whether engine is running or not.
Definition: Motorcycle.cpp:173
std::shared_ptr< Engine > get_engine()
Returns pointer to the Engine (may be 0).
Definition: Motorcycle.cpp:182
void turn(double degrees)
Definition: Motorcycle.cpp:159
Person const * get_owner() const
Returns pointer to the owner (may be 0).
Definition: Motorcycle.cpp:188
Motorcycle & operator=(Motorcycle const &rhs)
Copy assignment.
Definition: Motorcycle.cpp:64
void set_engine(std::shared_ptr< Engine > const &newEnginePtr)
Resets engine.
Definition: Motorcycle.cpp:194
std::array< Wheel, 2 > m_wheels
Definition: Motorcycle.h:87
void set_owner(Person *newOwnerPtr)
Resets owner.
Definition: Motorcycle.cpp:200
double m_direction
Definition: Motorcycle.h:89
void startEngine()
Start the motorcycle engine.
Definition: Motorcycle.cpp:105
void accelerate(double speed)
Accelerate up to given speed.
Definition: Motorcycle.cpp:131
const Person * m_owner
Definition: Motorcycle.h:86
Header for the Wheel class used to demo object aggregation features.
Motorcycle()
Default constructor does not initialize association with engine and owner.
Definition: Motorcycle.cpp:18