Kanzi Framework  3.9.0
Kanzi Engine API
kanzi::ResourceLoaderFactory Class Reference

Factory for resource loader tasks. More...

#include <kanzi/core.ui/resource/resource_loader_factory.hpp>

Public Types

typedef ResourceSharedPtr(* LoaderCallback) (Domain *, string_view, KzbFile *, ReadOnlyMemoryFilePtr)
 
typedef map< const Metaclass *, LoaderCallbackLoaderCallbackDictionary
 
typedef map< const Metaclass *, LoadTaskFactoryFunctionLoadTaskFactoryDictionary
 
typedef ResourceManager::LoadTaskSharedPtr(* LoadTaskFactoryFunction) (string_view, KzbFile *, ReadOnlyMemoryFilePtr)
 

Public Member Functions

LoaderCallback getLoaderCallback (const Metaclass *metaclass) const
 Get loader callback for given metaclass. More...
 
LoadTaskFactoryFunction getLoadTaskFactoryFunction (const Metaclass *metaclass) const
 Get load task factory function for given metaclass. More...
 
bool hasLoaderCallback (const Metaclass *metaclass) const
 Check if loader callback has been registered. More...
 
bool hasLoadTaskFactoryFunction (const Metaclass *metaclass) const
 Check if load task factory function has been registered. More...
 
void registerLoaderCallback (const Metaclass *metaclass, LoaderCallback callback)
 Register loader callback for a metaclass. More...
 
template<typename T >
void registerLoaderCallback ()
 Shorthand for registering loader callback for given type. More...
 
template<typename T >
void registerLoadTask ()
 Shorthand for registering a generic load task factory function. More...
 
void registerLoadTaskFactoryFunction (const Metaclass *metaclass, LoadTaskFactoryFunction func)
 Register load task factory function for given metaclass. More...
 
template<typename T >
void registerResourceLoadTask ()
 Shorthand for registering load task factory function for a resource. More...
 
 ResourceLoaderFactory ()
 Constructor. More...
 
LoaderCallback tryGetLoaderCallback (const Metaclass *metaclass) const
 Get loader callback for given metaclass. More...
 
LoadTaskFactoryFunction tryGetLoadTaskFactoryFunction (const Metaclass *metaclass) const
 Get load task factory function for given metaclass. More...
 

Detailed Description

Factory for resource loader tasks.

Tasks for resource loading are registered to the factory, that creates them as needed.

Existing resources can use the default tasks and they can override loadFromKZB() method of the resource. New types of resources with new base classes require a new load task.

Member Typedef Documentation

◆ LoaderCallback

typedef ResourceSharedPtr(* kanzi::ResourceLoaderFactory::LoaderCallback) (Domain *, string_view, KzbFile *, ReadOnlyMemoryFilePtr)

◆ LoaderCallbackDictionary

◆ LoadTaskFactoryFunction

typedef ResourceManager::LoadTaskSharedPtr(* kanzi::ResourceLoaderFactory::LoadTaskFactoryFunction) (string_view, KzbFile *, ReadOnlyMemoryFilePtr)

◆ LoadTaskFactoryDictionary

Constructor & Destructor Documentation

◆ ResourceLoaderFactory()

kanzi::ResourceLoaderFactory::ResourceLoaderFactory ( )
explicit

Constructor.

Member Function Documentation

◆ tryGetLoaderCallback()

LoaderCallback kanzi::ResourceLoaderFactory::tryGetLoaderCallback ( const Metaclass metaclass) const
inline

Get loader callback for given metaclass.

Returns empty function pointer (0) if metaclass has not been registered.

Parameters
metaclassMetaclass to get callback for.
Returns
Loader callback.

◆ getLoaderCallback()

LoaderCallback kanzi::ResourceLoaderFactory::getLoaderCallback ( const Metaclass metaclass) const
inline

Get loader callback for given metaclass.

Throws an error if metaclass has not been registered.

Parameters
metaclassMetaclass to get callback for.
Returns
Loader callback.

◆ hasLoaderCallback()

bool kanzi::ResourceLoaderFactory::hasLoaderCallback ( const Metaclass metaclass) const
inline

Check if loader callback has been registered.

Parameters
metaclassMetaclass to check.
Returns
True if registered, false if not.

◆ registerLoaderCallback() [1/2]

void kanzi::ResourceLoaderFactory::registerLoaderCallback ( const Metaclass metaclass,
LoaderCallback  callback 
)
inline

Register loader callback for a metaclass.

Parameters
metaclassMetaclass to register for.
callbackLoader callback.

◆ registerLoaderCallback() [2/2]

template<typename T >
void kanzi::ResourceLoaderFactory::registerLoaderCallback ( )
inline

Shorthand for registering loader callback for given type.

◆ tryGetLoadTaskFactoryFunction()

LoadTaskFactoryFunction kanzi::ResourceLoaderFactory::tryGetLoadTaskFactoryFunction ( const Metaclass metaclass) const
inline

Get load task factory function for given metaclass.

Returns empty function pointer (0) if metaclass has not been registered.

Parameters
metaclassMetaclass for which to get the load task factory function.
Returns
Load task factory function.

◆ getLoadTaskFactoryFunction()

LoadTaskFactoryFunction kanzi::ResourceLoaderFactory::getLoadTaskFactoryFunction ( const Metaclass metaclass) const
inline

Get load task factory function for given metaclass.

Throws an error if metaclass has not been registered.

Parameters
metaclassMetaclass for which to get the load task factory function.
Returns
Load task factory function.

◆ hasLoadTaskFactoryFunction()

bool kanzi::ResourceLoaderFactory::hasLoadTaskFactoryFunction ( const Metaclass metaclass) const
inline

Check if load task factory function has been registered.

Parameters
metaclassMetaclass to check.
Returns
True if registered, false if not.

◆ registerLoadTaskFactoryFunction()

void kanzi::ResourceLoaderFactory::registerLoadTaskFactoryFunction ( const Metaclass metaclass,
LoadTaskFactoryFunction  func 
)
inline

Register load task factory function for given metaclass.

Parameters
metaclassMetaclass to register for.
funcLoad task factory function.

◆ registerLoadTask()

template<typename T >
void kanzi::ResourceLoaderFactory::registerLoadTask ( )
inline

Shorthand for registering a generic load task factory function.

◆ registerResourceLoadTask()

template<typename T >
void kanzi::ResourceLoaderFactory::registerResourceLoadTask ( )
inline

Shorthand for registering load task factory function for a resource.


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