-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathmsPropertyManager.cpp
63 lines (46 loc) · 1.48 KB
/
msPropertyManager.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "MeshSyncClient/msPropertyManager.h"
#include "pch.h"
#include "MeshSync/SceneGraph/msPropertyInfo.h"
using namespace std;
namespace ms {
vector<PropertyInfoPtr> ms::PropertyManager::getAllProperties()
{
std::unique_lock<std::mutex> lock(m_mutex);
vector<PropertyInfoPtr> ret;
ret.reserve(m_records.size());
for (const auto& [key, propertyInfo] : m_records) {
ret.push_back(propertyInfo);
}
return ret;
}
void PropertyManager::add(PropertyInfoPtr propertyInfo)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_records[propertyInfo->hash()] = propertyInfo;
}
void PropertyManager::clear()
{
std::unique_lock<std::mutex> lock(m_mutex);
m_records.clear();
}
void PropertyManager::updateFromServer(std::vector<PropertyInfo> properties, std::vector<EntityPtr> entities)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_receivedProperties.insert(m_receivedProperties.end(), properties.begin(), properties.end());
m_receivedEntities.insert(m_receivedEntities.end(), entities.begin(), entities.end());
}
std::vector<PropertyInfo> PropertyManager::getReceivedProperties()
{
std::unique_lock<std::mutex> lock(m_mutex);
return m_receivedProperties;
}
std::vector<EntityPtr> PropertyManager::getReceivedEntities() {
std::unique_lock<std::mutex> lock(m_mutex);
return m_receivedEntities;
}
void PropertyManager::clearReceivedData() {
std::unique_lock<std::mutex> lock(m_mutex);
m_receivedProperties.clear();
m_receivedEntities.clear();
}
}