Nebula
Loading...
Searching...
No Matches
Resources::ResourceServer Class Reference

#include <resourceserver.h>

Inherits Core::RefCounted.

Public Member Functions

 ResourceServer ()
 constructor
 
virtual ~ResourceServer ()
 destructor
 
void Open ()
 open manager
 
void Close ()
 close manager
 
void Update (IndexT frameIndex)
 update resource manager, call each frame
 
Resources::ResourceId CreateResource (const ResourceName &res, std::function< void(const Resources::ResourceId)> success=nullptr, std::function< void(const Resources::ResourceId)> failed=nullptr, bool immediate=false, bool stream=true)
 create a new resource (stream-managed), which will be loaded at some later point, if not already loaded
 
Resources::ResourceId CreateResource (const ResourceName &res, const Util::StringAtom &tag, std::function< void(const Resources::ResourceId)> success=nullptr, std::function< void(const Resources::ResourceId)> failed=nullptr, bool immediate=false, bool stream=true)
 overload which also takes an identifying tag, which is used to group-discard resources
 
template<class METADATA >
Resources::ResourceId CreateResource (const ResourceName &res, const METADATA &metaData, std::function< void(const Resources::ResourceId)> success=nullptr, std::function< void(const Resources::ResourceId)> failed=nullptr, bool immediate=false, bool stream=true)
 create a new resource (stream-managed), which will be loaded at some later point, if not already loaded
 
template<class METADATA >
Resources::ResourceId CreateResource (const ResourceName &res, const METADATA &metaData, const Util::StringAtom &tag, std::function< void(const Resources::ResourceId)> success=nullptr, std::function< void(const Resources::ResourceId)> failed=nullptr, bool immediate=false, bool stream=true)
 overload which also takes an identifying tag, which is used to group-discard resources
 
void DiscardResource (const Resources::ResourceId res)
 discard resource (stream-managed)
 
void DiscardResources (const Util::StringAtom &tag)
 discard all resources by tag (stream-managed)
 
bool HasPendingResources ()
 returns true if there are pending resources in-flight
 
void ReloadResource (const ResourceName &res, std::function< void(const Resources::ResourceId)> success=nullptr, std::function< void(const Resources::ResourceId)> failed=nullptr)
 reload resource
 
void SetMinLod (const ResourceId &id, float lod, bool immediate)
 stream in a new LOD
 
void CreateResourceListener (const ResourceId &id, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed=nullptr)
 Create single-fire listener for resource. When resource is loaded, the callbacks will be invoked and the listener is destroyed.
 
Core::RttiGetType (const Resources::ResourceId id)
 get type of resource pool this resource was allocated with
 
const Resources::ResourceName GetName (const Resources::ResourceId id) const
 get resource name
 
const Util::StringAtom GetTag (const Resources::ResourceId id) const
 get tag resource was first registered with
 
const Resource::State GetState (const Resources::ResourceId id) const
 get resource state
 
const SizeT GetUsage (const Resources::ResourceId id) const
 get usage
 
bool HasResource (const Resources::ResourceId id) const
 check if resource id is valid
 
const Resources::ResourceId GetId (const Resources::ResourceName &name) const
 get id from name
 
void RegisterStreamLoader (const Util::StringAtom &ext, const Core::Rtti &loaderClass)
 register a stream pool, which takes an extension and the RTTI of the resource type to create
 
template<class POOL_TYPE >
POOL_TYPE * GetStreamLoader () const
 get stream pool for later use
 
void WaitForLoaderThread ()
 Wait for all loader threads.
 
void LoadDefaultResources ()
 goes through all pools and sets up their default resources
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Private Member Functions

 __DeclareClass (ResourceServer)
 
 __DeclareInterfaceSingleton (ResourceServer)
 

Private Attributes

bool open
 
Util::Dictionary< Util::StringAtom, IndexTextensionMap
 
Util::Dictionary< const Core::Rtti *, IndexTtypeMap
 
Util::Array< Ptr< ResourceLoader > > loaders
 

Static Private Attributes

static int32_t UniquePoolCounter = 0
 

Friends

class ResourceLoader
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ ResourceServer()

Resources::ResourceServer::ResourceServer ( )

constructor

◆ ~ResourceServer()

Resources::ResourceServer::~ResourceServer ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Resources::ResourceServer::__DeclareClass ( ResourceServer )
private

◆ __DeclareInterfaceSingleton()

Resources::ResourceServer::__DeclareInterfaceSingleton ( ResourceServer )
private

◆ Close()

void Resources::ResourceServer::Close ( )

close manager

◆ CreateResource() [1/4]

template<class METADATA >
Resources::ResourceId Resources::ResourceServer::CreateResource ( const ResourceName & res,
const METADATA & metaData,
const Util::StringAtom & tag,
std::function< void(const Resources::ResourceId)> success = nullptr,
std::function< void(const Resources::ResourceId)> failed = nullptr,
bool immediate = false,
bool stream = true )
inline

overload which also takes an identifying tag, which is used to group-discard resources

◆ CreateResource() [2/4]

template<class METADATA >
Resources::ResourceId Resources::ResourceServer::CreateResource ( const ResourceName & res,
const METADATA & metaData,
std::function< void(const Resources::ResourceId)> success = nullptr,
std::function< void(const Resources::ResourceId)> failed = nullptr,
bool immediate = false,
bool stream = true )
inline

create a new resource (stream-managed), which will be loaded at some later point, if not already loaded

◆ CreateResource() [3/4]

Resources::ResourceId Resources::ResourceServer::CreateResource ( const ResourceName & res,
const Util::StringAtom & tag,
std::function< void(const Resources::ResourceId)> success = nullptr,
std::function< void(const Resources::ResourceId)> failed = nullptr,
bool immediate = false,
bool stream = true )

overload which also takes an identifying tag, which is used to group-discard resources

◆ CreateResource() [4/4]

Resources::ResourceId Resources::ResourceServer::CreateResource ( const ResourceName & res,
std::function< void(const Resources::ResourceId)> success = nullptr,
std::function< void(const Resources::ResourceId)> failed = nullptr,
bool immediate = false,
bool stream = true )

create a new resource (stream-managed), which will be loaded at some later point, if not already loaded

◆ CreateResourceListener()

void Resources::ResourceServer::CreateResourceListener ( const ResourceId & id,
std::function< void(const Resources::ResourceId)> success,
std::function< void(const Resources::ResourceId)> failed = nullptr )
inline

Create single-fire listener for resource. When resource is loaded, the callbacks will be invoked and the listener is destroyed.

◆ DiscardResource()

void Resources::ResourceServer::DiscardResource ( const Resources::ResourceId res)
inline

discard resource (stream-managed)

Discards a single resource, and removes the callbacks to it from.

◆ DiscardResources()

void Resources::ResourceServer::DiscardResources ( const Util::StringAtom & tag)

discard all resources by tag (stream-managed)

◆ GetId()

const Resources::ResourceId Resources::ResourceServer::GetId ( const Resources::ResourceName & name) const
inline

get id from name

◆ GetName()

const Resources::ResourceName Resources::ResourceServer::GetName ( const Resources::ResourceId id) const
inline

get resource name

◆ GetState()

const Resources::Resource::State Resources::ResourceServer::GetState ( const Resources::ResourceId id) const
inline

get resource state

◆ GetStreamLoader()

template<class POOL_TYPE >
POOL_TYPE * Resources::ResourceServer::GetStreamLoader ( ) const
inline

get stream pool for later use

◆ GetTag()

const Util::StringAtom Resources::ResourceServer::GetTag ( const Resources::ResourceId id) const
inline

get tag resource was first registered with

◆ GetType()

Core::Rtti * Resources::ResourceServer::GetType ( const Resources::ResourceId id)

get type of resource pool this resource was allocated with

◆ GetUsage()

const SizeT Resources::ResourceServer::GetUsage ( const Resources::ResourceId id) const
inline

get usage

◆ HasPendingResources()

bool Resources::ResourceServer::HasPendingResources ( )

returns true if there are pending resources in-flight

◆ HasResource()

bool Resources::ResourceServer::HasResource ( const Resources::ResourceId id) const
inline

check if resource id is valid

◆ LoadDefaultResources()

void Resources::ResourceServer::LoadDefaultResources ( )

goes through all pools and sets up their default resources

◆ Open()

void Resources::ResourceServer::Open ( )

open manager

◆ RegisterStreamLoader()

void Resources::ResourceServer::RegisterStreamLoader ( const Util::StringAtom & ext,
const Core::Rtti & loaderClass )

register a stream pool, which takes an extension and the RTTI of the resource type to create

◆ ReloadResource()

void Resources::ResourceServer::ReloadResource ( const ResourceName & res,
std::function< void(const Resources::ResourceId)> success = nullptr,
std::function< void(const Resources::ResourceId)> failed = nullptr )
inline

reload resource

◆ SetMinLod()

void Resources::ResourceServer::SetMinLod ( const ResourceId & id,
float lod,
bool immediate )
inline

stream in a new LOD

◆ Update()

void Resources::ResourceServer::Update ( IndexT frameIndex)

update resource manager, call each frame

◆ WaitForLoaderThread()

void Resources::ResourceServer::WaitForLoaderThread ( )

Wait for all loader threads.

Friends And Related Symbol Documentation

◆ ResourceLoader

friend class ResourceLoader
friend

Member Data Documentation

◆ extensionMap

Util::Dictionary<Util::StringAtom, IndexT> Resources::ResourceServer::extensionMap
private

◆ loaders

Util::Array<Ptr<ResourceLoader> > Resources::ResourceServer::loaders
private

◆ open

bool Resources::ResourceServer::open
private

◆ typeMap

Util::Dictionary<const Core::Rtti*, IndexT> Resources::ResourceServer::typeMap
private

◆ UniquePoolCounter

int32_t Resources::ResourceServer::UniquePoolCounter = 0
staticprivate

The documentation for this class was generated from the following files: