9 #ifndef Navigation_UserDataBlobRegistry_H
10 #define Navigation_UserDataBlobRegistry_H
21 class UserDataBlobCategory
26 UserDataBlobCategory(BlobCategory* blobCategory);
28 void SetUserData(
KyUInt32 blobTypeId,
void* userData)
30 KyUInt32 blobEnum = BlobTypeIdUtils::GetBlobEnum(blobTypeId);
31 m_userDatas[blobEnum] = userData;
34 void* GetUserData(
KyUInt32 blobTypeId)
const
36 KyUInt32 blobEnum = BlobTypeIdUtils::GetBlobEnum(blobTypeId);
37 return m_userDatas[blobEnum];
41 BlobCategory* m_blobCategory;
42 KyArray<void*> m_userDatas;
46 class UserDataBlobNameSpace
51 UserDataBlobNameSpace(BlobNameSpace* blobNameSpace);
52 ~UserDataBlobNameSpace();
54 void* GetUserData(
KyUInt32 blobTypeId) const;
57 BlobNameSpace* m_blobNameSpace;
58 KyArray<UserDataBlobCategory*> m_userDataCategories;
62 class UserDataBlobRegistry
67 ~UserDataBlobRegistry();
72 UserDataBlobNameSpace* GetOrCreateUserDataNameSpace(BlobNameSpace* blobNameSpace);
73 UserDataBlobNameSpace* GetUserDataNameSpace(BlobNameSpace* blobNameSpace);
75 KyArray<UserDataBlobNameSpace*> m_userDataNameSpaces;
78 class UserBlobRegistryInternal
81 static KyResult CheckCollisions(UserDataBlobRegistry& current, UserDataBlobRegistry& other);
82 static void TransferContent(UserDataBlobRegistry& current, UserDataBlobRegistry& other);
83 static void Clear(UserDataBlobRegistry& current);
86 class UserBlobRegistryIdx
102 void* GetAndAdvance(
const UserDataBlobRegistry& registry);
112 class UserBlobRegistryRefCountBase :
public RefCountBase<UserBlobRegistryRefCountBase, Stat_Default_Mem>
117 template<
class T,
class TOwned,
bool IsTOwnedAutodelete>
118 class UserBlobRegistryBase :
public UserBlobRegistryRefCountBase
122 typedef UserBlobRegistryBase<T, TOwned, IsTOwnedAutodelete> SelfType;
124 ~UserBlobRegistryBase()
131 if (
KY_FAILED(m_userDatas.Set(blobTypeId,
object)))
133 m_owned.PushBack(
object);
139 return m_userDatas.Set(blobTypeId,
object);
142 template<
class BlobT>
145 return SetVal(BlobT::GetBlobTypeId(),
object);
148 template<
class BlobT>
151 return SetRef(BlobT::GetBlobTypeId(),
object);
156 return (T*)m_userDatas.Get(blobTypeId);
160 KyResult TransferContent(SelfType& fromRegistry)
163 KyResult result = UserBlobRegistryInternal::CheckCollisions(m_userDatas, fromRegistry.m_userDatas);
170 m_owned.Reserve(m_owned.GetCount() + fromRegistry.m_owned.GetCount());
171 m_owned.Append(fromRegistry.m_owned);
172 fromRegistry.m_owned.Clear();
175 UserBlobRegistryInternal::TransferContent(m_userDatas, fromRegistry.m_userDatas);
182 return m_userDatas.m_userDataNameSpaces.IsEmpty();
187 UserBlobRegistryInternal::Clear(m_userDatas);
188 if (IsTOwnedAutodelete ==
false)
190 for (
KyUInt32 i = 0; i < m_owned.GetCount(); ++i)
196 T* GetAndAdvance(UserBlobRegistryIdx& idx)
const
198 return (T*) idx.GetAndAdvance(m_userDatas);
203 UserDataBlobRegistry m_userDatas;
204 KyArray<TOwned> m_owned;
208 class UserBlobRegistry :
public UserBlobRegistryBase<T, T*, false>
214 class UserPtrBlobRegistry :
public UserBlobRegistryBase<T, Ptr<T>, true>
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define KY_FAILED(expression)
Shorthand for Kaim::Result::Fail().
Definition: types.h:274
Definition: gamekitcrowddispersion.h:20
#define KY_SUCCESS
Shorthand for Kaim::Result::Success.
Definition: types.h:273
#define KY_ERROR
Shorthand for Kaim::Result::Failure.
Definition: types.h:272
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226