Rosetta Utilities  2014.35
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | 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>

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 two FallbackConfigurationCreators that register for the same. More...
 

Static Public Member Functions

static ResourceLoaderFactoryget_instance ()
 Singleton accessor: ask for the one global instance of the ResourceLoaderFactory. More...
 

Private Member Functions

 ResourceLoaderFactory ()
 singleton has a private constructor More...
 

Static Private Member Functions

static ResourceLoaderFactorycreate_singleton_instance ()
 private singleton creation function to be used with utility::thread::threadsafe_singleton More...
 

Private Attributes

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

Static Private Attributes

static ResourceLoaderFactoryinstance_
 

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

Referenced by create_singleton_instance().

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_.

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 creator_map_.

ResourceLoaderFactory * basic::resource_manager::ResourceLoaderFactory::create_singleton_instance ( )
staticprivate

private singleton creation function to be used with utility::thread::threadsafe_singleton

References ResourceLoaderFactory().

Referenced by get_instance().

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 creator_map_, throw_on_double_registration_, and utility_exit_with_message.

ResourceLoaderFactory * basic::resource_manager::ResourceLoaderFactory::get_instance ( )
static

Singleton accessor: ask for the one global instance of the ResourceLoaderFactory.

static function to get the instance of ( pointer to) this singleton class

References create_singleton_instance(), instance_, and utility::thread::safely_create_singleton().

Referenced by basic::resource_manager::LazyResourceManager::create_resource().

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_.

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 two FallbackConfigurationCreators that register for the same.

References throw_on_double_registration_.

Member Data Documentation

std::map< std::string, ResourceLoaderCreatorOP > basic::resource_manager::ResourceLoaderFactory::creator_map_
private
ResourceLoaderFactory * basic::resource_manager::ResourceLoaderFactory::instance_
staticprivate

Referenced by get_instance().

bool basic::resource_manager::ResourceLoaderFactory::throw_on_double_registration_
private

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