MCPcopy Create free account
hub / github.com/TUC-ProAut/libRSF / DataSet

Class DataSet

include/DataSet.h:43–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 /** one class as base for all lists of something in time */
42 template<typename KeyType, typename ObjectType>
43 class DataSet
44 {
45 public:
46 DataSet() = default;
47 virtual ~DataSet() = default;
48
49 /** chronological list of arbitrary objects*/
50 typedef DataStream<ObjectType> ObjectStream;
51
52 /** unique ID that identifies one object */
53 struct UniqueID
54 {
55 UniqueID() = default;
56
57 UniqueID(const KeyType &IDNew, const double TimestampNew, const int NumberNew = 0): ID(IDNew), Timestamp(TimestampNew), Number(NumberNew)
58 {}
59
60 /** is required to compare keys */
61 bool operator == (const UniqueID &Other) const
62 {
63 return ID == Other.ID && Timestamp == Other.Timestamp && Number == Other.Number;
64 }
65
66 KeyType ID;
67 double Timestamp;
68 int Number;
69 };
70 typedef UniqueID ID;
71
72 /** add an element according to its ID and Timestamp*/
73 void addElement(const KeyType &ID, const double &Timestamp, const ObjectType &Object)
74 {
75 if (!this->checkID(ID))
76 {
77 ObjectStream TempStream;
78 _DataStreams.emplace(ID, TempStream);
79 }
80
81 _DataStreams.at(ID).emplace(Timestamp, Object);
82 }
83
84 void removeElement(const KeyType &ID, const double Timestamp, const int Number)
85 {
86 if (this->checkElement(ID, Timestamp, Number))
87 {
88 auto It = _DataStreams.at(ID).find(Timestamp);
89 std::advance(It, Number);
90 _DataStreams.at(ID).erase(It);
91
92 /** erase empty IDs */
93 if (_DataStreams.at(ID).empty())
94 {
95 _DataStreams.erase(ID);
96 }
97 }
98 else
99 {
100 PRINT_ERROR("Element doesn't exist at: ", Timestamp, " Type: ", ID, " Number: ", Number);

Callers

nothing calls this directly

Calls 1

findMethod · 0.80

Tested by

no test coverage detected