Rosetta Utilities  2014.35
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
basic::resource_manager::ResourceOptionsFactory Class Reference

The ResourceOptionsFactory class is responsible for maintaining the map between the names of the ResourceOptions classes (strings) and the ResourceOptionsCreator classes that are responsible for instantiating the ResourceOption classes. This is a singleton class. It is initialized at load time – or at least after the call to devel::init( argc, argv ) – and populated with the help of ResourceOptionsRegistrator instances. More...

#include <ResourceOptionsFactory.hh>

Public Member Functions

virtual ~ResourceOptionsFactory ()
 
ResourceOptionsOP create_resource_options (std::string const &options_type, utility::tag::TagCOP tag) const
 Create an instance of a ResourceOptions class given the name of the class (options_type) and initialize it from the given tag object. Throws an EXCN_Msg_Exception exception if the options_type string is not recognized. More...
 
void factory_register (ResourceOptionsCreatorOP creator)
 Register the given ResourceOptionsCreator object with the factory. Invoked by an instance of the templated ResourceOptionsRegistrator class. More...
 
void set_throw_on_double_registration ()
 Instruct the ResourceOptionsFactory to throw an exception if two ResourceOptionCreators are registered with the factory that report the same "options_type" string instead of invoking utility_exit_with_message. More...
 

Static Public Member Functions

static ResourceOptionsFactoryget_instance ()
 Singleton accessor function. Return the globally-unique instance of the class. More...
 

Private Types

typedef std::map< std::string,
ResourceOptionsCreatorOP
ResourceOptionsCreatorMap
 

Private Member Functions

 ResourceOptionsFactory ()
 Singleton private constructor. More...
 

Static Private Member Functions

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

Private Attributes

bool throw_on_double_registration_
 
ResourceOptionsCreatorMap creator_map_
 

Static Private Attributes

static ResourceOptionsFactoryinstance_
 

Detailed Description

The ResourceOptionsFactory class is responsible for maintaining the map between the names of the ResourceOptions classes (strings) and the ResourceOptionsCreator classes that are responsible for instantiating the ResourceOption classes. This is a singleton class. It is initialized at load time – or at least after the call to devel::init( argc, argv ) – and populated with the help of ResourceOptionsRegistrator instances.

Member Typedef Documentation

Constructor & Destructor Documentation

basic::resource_manager::ResourceOptionsFactory::~ResourceOptionsFactory ( )
virtual
basic::resource_manager::ResourceOptionsFactory::ResourceOptionsFactory ( )
private

Singleton private constructor.

Referenced by create_singleton_instance().

Member Function Documentation

ResourceOptionsOP basic::resource_manager::ResourceOptionsFactory::create_resource_options ( std::string const &  options_type,
utility::tag::TagCOP  tag 
) const

Create an instance of a ResourceOptions class given the name of the class (options_type) and initialize it from the given tag object. Throws an EXCN_Msg_Exception exception if the options_type string is not recognized.

References creator_map_, and basic::options::OptionKeys::frags::contacts::type.

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

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

References ResourceOptionsFactory().

Referenced by get_instance().

void basic::resource_manager::ResourceOptionsFactory::factory_register ( ResourceOptionsCreatorOP  creator)

Register the given ResourceOptionsCreator object with the factory. Invoked by an instance of the templated ResourceOptionsRegistrator class.

References creator_map_, throw_on_double_registration_, and utility_exit_with_message.

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

Singleton accessor function. Return the globally-unique instance of the class.

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

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

void basic::resource_manager::ResourceOptionsFactory::set_throw_on_double_registration ( )

Instruct the ResourceOptionsFactory to throw an exception if two ResourceOptionCreators are registered with the factory that report the same "options_type" string instead of invoking utility_exit_with_message.

Only useful for unit testing. Since factory registration can happen any time between load time and the call to devel::init, there may be no one to catch a thrown exception in the event of a name collision between two ResourceOptionsCreators that register for the same name, and so the default behavior is to call utility_exit_with_message. For the sake of unit testing, however, it is useful to change the default behavior so that exceptions can be thrown and then caught.

References throw_on_double_registration_.

Member Data Documentation

ResourceOptionsCreatorMap basic::resource_manager::ResourceOptionsFactory::creator_map_
private
ResourceOptionsFactory * basic::resource_manager::ResourceOptionsFactory::instance_
staticprivate

Referenced by get_instance().

bool basic::resource_manager::ResourceOptionsFactory::throw_on_double_registration_
private

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