RType
Timer.cpp
Go to the documentation of this file.
1 //
2 // Created by talleux on 1/10/24.
3 //
4 
5 #include "Timer.hpp"
6 #include <cstring>
7 #include <iostream>
8 #include <utility>
9 
10 /**
11  * @brief Construct a new Timer:: Timer object
12  */
14 {
15  _startTime = {0, 0};
16  _now = {0, 0};
17  _targetTime = {0, 0};
18  _diff = {0, 0};
19  _attribute = new char[64];
20  _active = true;
21  _direction = 1;
22  std::memset(_attribute, 0, 64);
23 }
24 
25 /**
26  * @brief getAttribute, get the attribute
27  * @return attribute (char *)
28  */
29 char *Timer::getAttribute() const
30 {
31  return _attribute;
32 }
33 
34 /**
35  * @brief setAttribute, set the attribute
36  * @param attribute
37  */
38 void Timer::setAttribute(std::string attribute)
39 {
40  std::memset(_attribute, 0, 64);
41  std::memcpy(_attribute, attribute.c_str(), attribute.size());
42  std::cout << "attribute: " << _attribute << std::endl;
43 }
44 
45 /**
46  * @brief setTarget, set the target
47  * @param target
48  */
49 void Timer::setTarget(std::shared_ptr<Drawable> target)
50 {
51  _target = std::move(target);
52 }
53 
54 /**
55  * @brief setTarget, set the target
56  * @return target
57  */
58 std::shared_ptr<Drawable> Timer::getTarget()
59 {
60  return _target;
61 }
62 
63 /**
64  * @brief setActive, set the timer active
65  * @param active
66  */
67 void Timer::setActive(bool active)
68 {
69  _active = active;
70 }
71 
72 /**
73  * @brief isActive, check if the timer is active
74  * @return active (bool)
75  */
76 bool Timer::isActive() const
77 {
78  return _active;
79 }
80 
81 void Timer::setDirection(int direction) {
82  _direction = direction;
83 }
84 
85 int Timer::getDirection() const {
86  return _direction;
87 }