5 constexpr
size_t EventIdMapper::maxSizeEventIdMap;
10 if(eventId.to_int() == 0) {
11 return ChimeraTK::VersionNumber{
nullptr};
15 std::lock_guard<decltype(_mapMutex)> lock{_mapMutex};
18 if(_eventIdToVersionMap.find(eventId) != _eventIdToVersionMap.end()) {
19 return _eventIdToVersionMap[eventId];
23 if(_eventIdToVersionMap.size() == 0) {
24 return _eventIdToVersionMap[eventId];
28 if(eventId < _eventIdToVersionMap.begin()->first) {
29 return ChimeraTK::VersionNumber{
nullptr};
33 auto lastEventId = _eventIdToVersionMap.rbegin()->first;
34 size_t nElementsToInsert = std::min((
size_t)(eventId - lastEventId), maxSizeEventIdMap);
37 size_t nElementsToKeep = maxSizeEventIdMap - nElementsToInsert;
38 while(_eventIdToVersionMap.size() > nElementsToKeep) {
39 _eventIdToVersionMap.erase(_eventIdToVersionMap.begin());
43 for(doocs::EventId eid = eventId - (nElementsToInsert - 1); eid <= eventId; eid = eid + 1) {
44 _eventIdToVersionMap[eid] = ChimeraTK::VersionNumber();
46 assert(_eventIdToVersionMap.find(eventId) != _eventIdToVersionMap.end());
49 return _eventIdToVersionMap[eventId];