blob: 4c40b8027b89351ac280600153d28c5eb1baaf20 (
plain) (
blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#include "ApexSDKCachedDataImpl.h"
#include "nvparameterized/NvParameterized.h"
namespace nvidia
{
namespace apex
{
bool ApexSDKCachedDataImpl::registerModuleDataCache(ModuleCachedDataIntl* cache)
{
if (cache == NULL)
{
return false;
}
for (uint32_t i = 0; i < mModuleCaches.size(); ++i)
{
if (cache == mModuleCaches[i])
{
return false;
}
}
mModuleCaches.pushBack(cache);
return true;
}
bool ApexSDKCachedDataImpl::unregisterModuleDataCache(ModuleCachedDataIntl* cache)
{
if (cache == NULL)
{
return false;
}
for (uint32_t i = mModuleCaches.size(); i--;)
{
if (cache == mModuleCaches[i])
{
mModuleCaches.replaceWithLast(i);
break;
}
}
return false;
}
ApexSDKCachedDataImpl::ApexSDKCachedDataImpl()
{
}
ApexSDKCachedDataImpl::~ApexSDKCachedDataImpl()
{
}
ModuleCachedData* ApexSDKCachedDataImpl::getCacheForModule(AuthObjTypeID moduleID)
{
for (uint32_t i = 0; i < mModuleCaches.size(); ++i)
{
if (moduleID == mModuleCaches[i]->getModuleID())
{
return mModuleCaches[i];
}
}
return NULL;
}
PxFileBuf& ApexSDKCachedDataImpl::serialize(PxFileBuf& stream) const
{
stream.storeDword((uint32_t)Version::Current);
for (uint32_t i = 0; i < mModuleCaches.size(); ++i)
{
mModuleCaches[i]->serialize(stream);
}
return stream;
}
PxFileBuf& ApexSDKCachedDataImpl::deserialize(PxFileBuf& stream)
{
clear(false); // false => don't delete cached data for referenced sets
/*const uint32_t version =*/
stream.readDword(); // Original version
for (uint32_t i = 0; i < mModuleCaches.size(); ++i)
{
mModuleCaches[i]->deserialize(stream);
}
return stream;
}
void ApexSDKCachedDataImpl::clear(bool force)
{
for (uint32_t i = mModuleCaches.size(); i--;)
{
mModuleCaches[i]->clear(force);
}
}
}
} // end namespace nvidia::apex
|