Polyphase Game Engine
Loading...
Searching...
No Matches
AssetRef.h
Go to the documentation of this file.
1#pragma once
2
3#include "PolyphaseAPI.h"
4#include "Asset.h"
5#include "Constants.h"
6#include <vector>
7#include "Assertion.h"
8
9#include <unordered_set>
10
11//class Asset;
12class AssetManager;
13struct AsyncLoadRequest;
14
15POLYPHASE_API MutexObject* GetAssetRefMutex();
16
18{
19public:
20
21 AssetRef();
22 AssetRef(Asset* asset);
23 AssetRef(const AssetRef& src);
24 ~AssetRef();
25 AssetRef& operator=(const AssetRef& src);
26 AssetRef& operator=(const Asset* srcAsset);
27
28 bool operator==(const AssetRef& other) const;
29 bool operator!=(const AssetRef& other) const;
30 bool operator==(const Asset* other) const;
31 bool operator!=(const Asset* other) const;
32
33 Asset* Get() const;
34
35 template<typename T>
36 T* Get() const
37 {
38 OCT_ASSERT(!mAsset || mAsset->GetType() == T::GetStaticType() || mAsset->Is(T::ClassRuntimeId()));
39 return static_cast<T*>(Get());
40 }
41
42 void SetLoadRequest(AsyncLoadRequest* loadRequest);
43 AsyncLoadRequest* GetLoadRequest();
44
45private:
46
47 void EraseAsyncLoadRef();
48
49 Asset* mAsset = nullptr;
50 AsyncLoadRequest* mLoadRequest = nullptr;
51
52#if ASSET_LIVE_REF_TRACKING
53public:
54 static void ReplaceReferencesToAsset(Asset* oldAsset, Asset* newAsset);
55 static void EraseReferencesToAsset(Asset* asset);
56private:
57 static void AddLiveRef(AssetRef* ref);
58 static void RemoveLiveRef(AssetRef* ref);
59#endif
60
61};
62
#define OCT_ASSERT(expr)
Definition Assertion.h:12
POLYPHASE_API MutexObject * GetAssetRefMutex()
Definition AssetRef.cpp:39
AssetRef SoundWaveRef
Definition AssetRef.h:68
AssetRef SpriteAnimationRef
Definition AssetRef.h:73
AssetRef TextureRef
Definition AssetRef.h:63
AssetRef TimelineRef
Definition AssetRef.h:71
AssetRef SceneRef
Definition AssetRef.h:70
AssetRef SkeletalMeshRef
Definition AssetRef.h:66
AssetRef StaticMeshRef
Definition AssetRef.h:64
AssetRef MaterialRef
Definition AssetRef.h:65
AssetRef ParticleSystemRef
Definition AssetRef.h:67
AssetRef DataAssetRef
Definition AssetRef.h:72
AssetRef FontRef
Definition AssetRef.h:69
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition AssetManager.h:120
Definition AssetRef.h:18
T * Get() const
Definition AssetRef.h:36
Definition Asset.h:113
Definition AssetManager.h:19