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

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: