The Vish Visualization Shell 0.3
Vish
Static Public Member Functions | List of all members
MemCore::LoaderRegistry< X > Class Template Reference

Database for routines that may create objects of type X. More...

#include <elementary/memcore/Loader.hpp>

Inheritance diagram for MemCore::LoaderRegistry< X >:
MemCore::LoaderRegistryBase

Static Public Member Functions

static void getSupportedExtensions (list< string > &SupportedExtensions)
 Extend the given list of possible extensions.
 
static bool isloadable (const RefPtr< LoaderParameters > &LP)
 Check whether some loader parameters might be handable here.
 
static RefPtr< Xload (bool &success, const RefPtr< LoaderParameters > &LP, const RefPtr< X > &xptr=NullPtr())
 Actually load some object from the input source.
 
static RefPtr< LoaderRequestrequest (const RefPtr< LoaderParameters > &LP, const RefPtr< X > &xptr=NullPtr())
 Actually load some object from the input source.
 

Additional Inherited Members

- Static Protected Member Functions inherited from MemCore::LoaderRegistryBase
static void domain_append (const type_info &id, const RefPtr< LoaderBase > &ldr, const type_info &Domain)
 

Detailed Description

template<class X>
class MemCore::LoaderRegistry< X >

Database for routines that may create objects of type X.

The LoaderRegistry class allows to actually create objects of type X from a certain input source. The input source is specified through the LoaderParameters class, which may carry arbitrary additional interfaces.

bool success;
RefPtr<LoaderParameters> LP = new LoaderParameters("FileName.txt");
LP->addInterface( new ProgressDisplay() );
RefPtr<X> object = LoaderRegistry<X>::load(success, LP);
Parameters for the loading process.
Definition Loader.hpp:82
static RefPtr< X > load(bool &success, const RefPtr< LoaderParameters > &LP, const RefPtr< X > &xptr=NullPtr())
Actually load some object from the input source.
Definition Loader.hpp:410
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405
    Implementation of a new Loader:
    Consider a type Bundle to be created from some input source.
    We introduce an artificial type, here called HDF5
struct HDF5 {};

with no other purpose as to provide a unique typeid in C++. We implement a loader by deriving from the Loader<Bundle> base class:

struct myHDF5Loader : Loader<Bundle>
{
{}
} override;
Abstract base class for object loaders, which are used by the LoaderRegistry.
Definition Loader.hpp:261
std::nullptr_t NullPtr
A type indicating an invalid pointer, similar to the NULL pointer in C, but type-safe.
Definition DynPtr.hpp:368

The name of this class is not of relevance. We now add an instance of this loader to the LoaderRegistry for the Bundle type:

MemCore::LoaderRegistry<Bundle>::append( typeid(HDF5), new myHDF5Loader() );
Database for routines that may create objects of type X.
Definition Loader.hpp:402

Now we have the means to iterate over all loaders which have been registered for the type Bundle. This iteration is implemented in function LoaderRegistryBase::domain_load() as a static function, or easier as LoaderRegistry<Bundle>::load();