Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
basic::resource_manager::ResourceLoaderFactory Class Reference

Instantiates ResourceLoaders. Creators may be registered with the Factory at any point, though it is recommended they be registered at load time. If two Creators are registered and they both give the same name for the ResourceLoader they say they will instantiate, then the Factory will exit with an error message. More...

#include <ResourceLoaderFactory.hh>

Inheritance diagram for basic::resource_manager::ResourceLoaderFactory:
Inheritance graph
[legend]

Public Member Functions

ResourceLoaderOP create_resource_loader (std::string const &loader_type) const
 Instantiates a resource loader ofa given type; throws an exception if no loader with this type has been previously registered. More...
 
bool has_resource_loader (std::string const &loader_type) const
 Returns true if a resource loader of the given type has been registered with the factory. More...
 
std::list< std::string > available_resource_loaders () const
 Return a list of all the resource loaders available. More...
 
void factory_register (ResourceLoaderCreatorOP creator)
 Register a ResourceLoaderCreator with the factory. The factory asks the Creator for the name of the ResourceLoader that it will create; if another Creator has already registered with the factory that proports to instantiate another ResourceLoader with the same name, then it will exit with an error message, or, if set_throw_on_double_registration() has previously been called, throw an exception. More...
 
void set_throw_on_double_registration ()
 Only useful for unit testing. Since factory registration happens (sometimes) at load time, there may be no one to catch a thrown exception in the event of a name collision. More...
 
std::map< std::string,
ResourceLoaderCreatorOP >
const & 
loader_map () const
 Read access to the set of creators that the factry holds; used to create the schema definition for the ResourceManager. More...
 
- Public Member Functions inherited from utility::SingletonBase< T >
 SingletonBase ()
 public constructor (the derived class must have a private constructor, of course). More...
 

Static Public Member Functions

static std::string complex_type_name_for_loader (std::string const &loader_name)
 The name mangling function used by ResourceLoaders when they define their complexTypes in the XML Schema. More...
 
- Static Public Member Functions inherited from utility::SingletonBase< T >
static Tget_instance ()
 Safely instantiate a singleton class in a (possibly) multithreaded context. More...
 

Private Member Functions

 ResourceLoaderFactory ()
 singleton has a private constructor More...
 
 ResourceLoaderFactory (ResourceLoaderFactory const &)=delete
 
ResourceLoaderFactoryoperator= (ResourceLoaderFactory const &)=delete
 

Private Attributes

bool throw_on_double_registration_
 
std::map< std::string,
ResourceLoaderCreatorOP
creator_map_
 

Friends

class utility::SingletonBase< ResourceLoaderFactory >
 

Detailed Description

Instantiates ResourceLoaders. Creators may be registered with the Factory at any point, though it is recommended they be registered at load time. If two Creators are registered and they both give the same name for the ResourceLoader they say they will instantiate, then the Factory will exit with an error message.

Constructor & Destructor Documentation

basic::resource_manager::ResourceLoaderFactory::ResourceLoaderFactory ( )
private

singleton has a private constructor

basic::resource_manager::ResourceLoaderFactory::ResourceLoaderFactory ( ResourceLoaderFactory const &  )
privatedelete

Member Function Documentation

std::list< std::string > basic::resource_manager::ResourceLoaderFactory::available_resource_loaders ( ) const

Return a list of all the resource loaders available.

References creator_map_.

std::string basic::resource_manager::ResourceLoaderFactory::complex_type_name_for_loader ( std::string const &  loader_name)
static
ResourceLoaderOP basic::resource_manager::ResourceLoaderFactory::create_resource_loader ( std::string const &  loader_type) const

Instantiates a resource loader ofa given type; throws an exception if no loader with this type has been previously registered.

References CREATE_EXCEPTION, and creator_map_.

void basic::resource_manager::ResourceLoaderFactory::factory_register ( ResourceLoaderCreatorOP  creator)

Register a ResourceLoaderCreator with the factory. The factory asks the Creator for the name of the ResourceLoader that it will create; if another Creator has already registered with the factory that proports to instantiate another ResourceLoader with the same name, then it will exit with an error message, or, if set_throw_on_double_registration() has previously been called, throw an exception.

References CREATE_EXCEPTION, creator_map_, errmsg(), throw_on_double_registration_, and utility_exit_with_message.

bool basic::resource_manager::ResourceLoaderFactory::has_resource_loader ( std::string const &  loader_type) const

Returns true if a resource loader of the given type has been registered with the factory.

References creator_map_.

std::map< std::string, ResourceLoaderCreatorOP > const & basic::resource_manager::ResourceLoaderFactory::loader_map ( ) const

Read access to the set of creators that the factry holds; used to create the schema definition for the ResourceManager.

References creator_map_.

ResourceLoaderFactory& basic::resource_manager::ResourceLoaderFactory::operator= ( ResourceLoaderFactory const &  )
privatedelete
void basic::resource_manager::ResourceLoaderFactory::set_throw_on_double_registration ( )

Only useful for unit testing. Since factory registration happens (sometimes) at load time, there may be no one to catch a thrown exception in the event of a name collision.

References throw_on_double_registration_.

Friends And Related Function Documentation

Member Data Documentation

std::map< std::string, ResourceLoaderCreatorOP > basic::resource_manager::ResourceLoaderFactory::creator_map_
private
bool basic::resource_manager::ResourceLoaderFactory::throw_on_double_registration_
private

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