-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathCANInterfaceIDTranslator.h
60 lines (52 loc) · 1.22 KB
/
CANInterfaceIDTranslator.h
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "CollectionInspectionAPITypes.h"
#include "SignalTypes.h"
namespace Aws
{
namespace IoTFleetWise
{
/**
* @brief Translate the internal used Id to the Id used in config file and decoder manifest
* Adding new items is not thread safe
*/
class CANInterfaceIDTranslator
{
public:
void
add( InterfaceID iid )
{
mLookup.emplace_back( mCounter, iid );
mCounter++;
}
CANChannelNumericID
getChannelNumericID( const InterfaceID &iid ) const
{
for ( auto l : mLookup )
{
if ( l.second == iid )
{
return l.first;
}
}
return INVALID_CAN_SOURCE_NUMERIC_ID;
};
InterfaceID
getInterfaceID( CANChannelNumericID cid ) const
{
for ( auto l : mLookup )
{
if ( l.first == cid )
{
return l.second;
}
}
return INVALID_INTERFACE_ID;
};
private:
std::vector<std::pair<CANChannelNumericID, InterfaceID>> mLookup;
CANChannelNumericID mCounter{ 0 };
};
} // namespace IoTFleetWise
} // namespace Aws