MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/systemic/ResourceHolder.cpp
2024-06-07 11:12:56 +03:00

34 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ResourceHolder.cpp
*
* Created on: 22 нояб. 2018 г.
* Author: titov
*/
#include "ResourceHolder.hpp"
systemic::ResourceHolder::ResourceHolder( std::size_t max_size,
std::pmr::memory_resource* record_allocator,
std::pmr::memory_resource* record_guard_allocator,
NotificationInterface & herald )
: size_limit(max_size),
record_allocator(record_allocator),
record_guard_allocator(record_guard_allocator ? record_guard_allocator : record_allocator),
records( std::less< ResourceRecord::Info >(),
std::pmr::polymorphic_allocator< ResourceRecord::Data >(record_allocator) ),
herald(herald) {}
void * systemic::ResourceHolder::getRecord( const std::type_info & obj_type, Id id, Tag tag ) {
ResourceRecord::Info record_info(&obj_type, id, tag);
ResourceRecordMap::iterator iter = records.find(record_info);
if( iter != records.end() )
return iter->second;
else
return nullptr;
}