forked from xR3b0rn/dbcppp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignalMultiplexerValueImpl.cpp
More file actions
57 lines (49 loc) · 1.61 KB
/
SignalMultiplexerValueImpl.cpp
File metadata and controls
57 lines (49 loc) · 1.61 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
#include "SignalMultiplexerValueImpl.h"
using namespace dbcppp;
std::unique_ptr<ISignalMultiplexerValue> ISignalMultiplexerValue::Create(
std::string&& switch_name
, std::vector<Range>&& value_ranges)
{
return std::make_unique<SignalMultiplexerValueImpl>(
std::move(switch_name)
, std::move(value_ranges));
}
SignalMultiplexerValueImpl::SignalMultiplexerValueImpl(
std::string&& switch_name
, std::vector<Range>&& value_ranges)
: _switch_name(std::move(switch_name))
, _value_ranges(std::move(value_ranges))
{}
std::unique_ptr<ISignalMultiplexerValue> SignalMultiplexerValueImpl::Clone() const
{
return std::make_unique<SignalMultiplexerValueImpl>(*this);
}
const std::string& SignalMultiplexerValueImpl::SwitchName() const
{
return _switch_name;
}
const ISignalMultiplexerValue::Range& SignalMultiplexerValueImpl::ValueRanges_Get(std::size_t i) const
{
return _value_ranges[i];
}
uint64_t SignalMultiplexerValueImpl::ValueRanges_Size() const
{
return _value_ranges.size();
}
bool SignalMultiplexerValueImpl::operator==(const ISignalMultiplexerValue& rhs) const
{
bool equal = true;
equal &= _switch_name == rhs.SwitchName();
for (const auto& range : rhs.ValueRanges())
{
auto beg = _value_ranges.begin();
auto end = _value_ranges.end();
equal &= std::find_if(beg, end,
[&](const auto& other) { return range.from == other.from && range.to == other.to; }) != end;
}
return equal;
}
bool SignalMultiplexerValueImpl::operator!=(const ISignalMultiplexerValue& rhs) const
{
return !(*this == rhs);
}