-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMTLSharedMemory.cpp
46 lines (38 loc) · 1.14 KB
/
MTLSharedMemory.cpp
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
#include "MTLSharedMemory.h"
namespace MTL
{
MTLSharedMemory::MTLSharedMemory() : m_sharedObjects()
{
}
MTLSharedMemory::~MTLSharedMemory()
{
}
void MTLSharedMemory::addSharedObject(std::unique_ptr<MTLSharedObject> obj)
{
m_sharedObjects[obj->getObjId()] = std::move(obj);
}
void MTLSharedMemory::removeSharedObject(unsigned int id)
{
m_sharedObjects.erase(id);
}
MTLSharedObject &MTLSharedMemory::getSharedObjectById(unsigned int id)
{
if (m_sharedObjects.find(id) == m_sharedObjects.end())
{
throw std::runtime_error("MTLSharedMemory::getSharedObjectById: object not found");
}
return m_sharedObjects.at(id)->getObj();
}
void MTLSharedMemory::releaseSharedObject(MTLSharedObject &obj)
{
if (m_sharedObjects.find(obj.getObjId()) == m_sharedObjects.end())
{
throw std::runtime_error("MTLSharedMemory::releaseSharedObject: object not found");
}
m_sharedObjects.at(obj.getObjId())->releaseObj();
}
void MTLSharedMemory::clearSharedMemory()
{
m_sharedObjects.clear();
}
}