-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathCANFrame.cpp
More file actions
150 lines (117 loc) · 2.97 KB
/
CANFrame.cpp
File metadata and controls
150 lines (117 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <cpp-can-parser/CANDatabase.h>
#include <utility>
#include <iostream>
using namespace CppCAN;
CANFrame::CANFrame(const std::string& name, unsigned long long can_id,
unsigned int dlc, unsigned int period,
const std::string& comment)
: name_(name), can_id_(can_id), dlc_(dlc), period_(0), comment_(comment) {}
const std::string& CANFrame::name() const {
return name_;
}
unsigned long long CANFrame::can_id() const {
return can_id_;
}
unsigned int CANFrame::dlc() const {
return dlc_;
}
unsigned int CANFrame::period() const {
return period_;
}
const std::string& CANFrame::comment() const {
return comment_;
}
void CANFrame::setPeriod(unsigned int val) {
period_ = val;
}
void CANFrame::setComment(const std::string& comment) {
comment_ = comment;
}
bool CANFrame::contains(const std::string& name) const {
return map_.find(name) != map_.end();
}
const CANSignal& CANFrame::at(const std::string& name) const {
return map_.at(name);
}
CANSignal& CANFrame::at(const std::string& name) {
return map_.at(name);
}
const CANSignal& CANFrame::operator[](const std::string& name) const {
return at(name);
}
CANSignal& CANFrame::operator[](const std::string& name) {
return at(name);
}
void CANFrame::addSignal(const CANSignal& signal) {
map_.insert(std::make_pair(signal.name(), signal));
}
void CANFrame::removeSignal(const std::string& name) {
auto ite = map_.find(name);
if(ite == map_.end()) {
std::string excepText = "Cannot remove signal with name \"" + name +
"\" from frame \"" + this->name() + "\"";
throw std::out_of_range(excepText);
}
map_.erase(ite);
}
CANFrame::iterator CANFrame::begin() {
return map_.begin();
}
CANFrame::const_iterator CANFrame::begin() const {
return map_.begin();
}
CANFrame::const_iterator CANFrame::cbegin() const
{
return map_.cbegin();
}
CANFrame::iterator CANFrame::end()
{
return map_.end();
}
CANFrame::const_iterator CANFrame::end() const
{
return map_.end();
}
CANFrame::const_iterator CANFrame::cend() const
{
return map_.cend();
}
CANFrame::reverse_iterator CANFrame::rbegin()
{
return map_.rbegin();
}
CANFrame::const_reverse_iterator CANFrame::rbegin() const
{
return map_.rbegin();
}
CANFrame::const_reverse_iterator CANFrame::crbegin() const
{
return map_.crbegin();
}
CANFrame::reverse_iterator CANFrame::rend()
{
return map_.rend();
}
CANFrame::const_reverse_iterator CANFrame::rend() const
{
return map_.rend();
}
CANFrame::const_reverse_iterator CANFrame::crend() const
{
return map_.crend();;
}
std::size_t CANFrame::size() const
{
return map_.size();
}
void CANFrame::clear() {
map_.clear();
}
void CppCAN::swap(CANFrame & first, CANFrame & second) {
std::swap(first.name_, second.name_);
std::swap(first.can_id_, second.can_id_);
std::swap(first.dlc_, second.dlc_);
std::swap(first.period_, second.period_);
std::swap(first.map_, second.map_);
std::swap(first.comment_, second.comment_);
}