Rosetta Utilities  2014.35
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
basic::resource_manager::ResourceManager Class Referenceabstract

The ResourceManager is a singleton class responsible for holding, distributing, and eventually deallocating resources which may be shared between multiple jobs. A protocol may communicate directly with the ResourceManager, requesting resources, but remaining unaware of where those resources came from, or whether the same resource is being used in multiple contexts. More...

#include <ResourceManager.hh>

Public Member Functions

virtual bool has_resource (ResourceTag const &resource_tag) const
 Does a resource with a given name exist? More...
 
virtual ResourceOP find_resource (ResourceTag const &resource_tag)
 Get a resource with a given name. More...
 
virtual void clear ()
 wipe out all data; useful for unit testing, but hard to fathom how it would be useful otherwise. More...
 
virtual void show (std::ostream &out) const
 
virtual bool has_resource_with_description (ResourceDescription const &resource_description)=0
 A protocol may ask whether a resource with a given resource description has been provided. It is possible that some resources are available sometimes when running a protocol, but not always (e.g. when running abinitio, sometimes you don't know what the native structure is). More...
 
virtual ResourceOP get_resource (ResourceDescription const &resource_description)=0
 Returns the resource with the given resource_description. More...
 
virtual bool get_option (utility::options::BooleanOptionKey key) const =0
 Retrieve the boolean value represented by the given option key. More...
 
virtual utility::vector1< bool >
const & 
get_option (utility::options::BooleanVectorOptionKey key) const =0
 Retrieve the vector of boolean values represented by the given option key. More...
 
virtual
utility::file::FileName const & 
get_option (utility::options::FileOptionKey key) const =0
 Retrieve the FileName value represented by the given option key. More...
 
virtual utility::vector1
< utility::file::FileName >
const & 
get_option (utility::options::FileVectorOptionKey key) const =0
 Retrieve the vector of FileName values represented by the given option key. More...
 
virtual int get_option (utility::options::IntegerOptionKey key) const =0
 Retrieve the integer value represented by the given option key. More...
 
virtual utility::vector1< int >
const & 
get_option (utility::options::IntegerVectorOptionKey key) const =0
 Retrieve the vector of integer values represented by the given option key. More...
 
virtual
utility::file::PathName const & 
get_option (utility::options::PathOptionKey key) const =0
 Retrieve the PathName value represented by the given option key. More...
 
virtual utility::vector1
< utility::file::PathName >
const & 
get_option (utility::options::PathVectorOptionKey key) const =0
 Retrieve the vector of PathName values represented by the given option key. More...
 
virtual platform::Real get_option (utility::options::RealOptionKey key) const =0
 Retrieve the Real value represented by the given option key. More...
 
virtual utility::vector1
< platform::Real > const & 
get_option (utility::options::RealVectorOptionKey key) const =0
 Retrieve the vector of Real values represented by the given option key. More...
 
virtual std::string const & get_option (utility::options::StringOptionKey key) const =0
 Retrieve the string value represented by the given option key. More...
 
virtual utility::vector1
< std::string > const & 
get_option (utility::options::StringVectorOptionKey key) const =0
 Retrieve the vector of string values represented by the given option key. More...
 
virtual bool has_option (utility::options::BooleanOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::BooleanVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::FileOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::FileVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::IntegerOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::IntegerVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::PathOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::PathVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::RealOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::RealVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::StringOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 
virtual bool has_option (utility::options::StringVectorOptionKey key) const =0
 Return whether or not a value has been provided for the given option key either on the command line or through for the current job. More...
 

Static Public Member Functions

static ResourceManagerget_instance ()
 Singleton accessor: request access to the resource manager. More...
 

Protected Member Functions

 ResourceManager ()
 singleton, private constructor More...
 
virtual void add_resource (ResourceTag const &resource_tag, ResourceOP resource)
 Derived classes, when they instantiate a resource, should name it and give it to the base class for it to hold. A resource may be later deallocated using the "free_resource" function. More...
 
virtual void free_resource (ResourceTag const &resource_tag)
 Derived classes, when they are ready to deallocate a resource, may do so in this function. More...
 

Private Types

typedef std::map< ResourceTag,
ResourceOP
ResourcesMap
 

Static Private Member Functions

static ResourceManagercreate_singleton_instance ()
 private singleton creation function to be used with utility::thread::threadsafe_singleton Not clear that this is appropriate for the ResourceManager. More...
 

Private Attributes

ResourcesMap resources_
 

Static Private Attributes

static ResourceManagerinstance_
 

Friends

std::ostream & operator<< (std::ostream &out, ResourceManager const &resource_manager)
 

Detailed Description

The ResourceManager is a singleton class responsible for holding, distributing, and eventually deallocating resources which may be shared between multiple jobs. A protocol may communicate directly with the ResourceManager, requesting resources, but remaining unaware of where those resources came from, or whether the same resource is being used in multiple contexts.

A protocol should request a resource using a "resource description" (a string), which is a generic way of referring to a piece of data. For example, a protocol might request the native Pose, by asking for a resource with the description "native". The ResourceManager's job is to return the resource matching that description; when the "native" is requested, it is requested in some context (e.g. in a protocol running under JD2) and the ResourceManager serves as a backbone in which to deliever context-specific data to the protocol, while keeping the protocol ignorant and independent of the surrounding context. That way protocols can run in JD2 just as effectively as the could run in some other job-management environment, without having to assume responsibility for instantiating resources themselves.

NOTE: Because the logic for deciding which of the derived ResourceManager classes should be instantiated depends on the options system, the ResourceManager should not be requested until after core::init::init() has been called (i.e. it should not be requested at load time.)

Member Typedef Documentation

Constructor & Destructor Documentation

basic::resource_manager::ResourceManager::ResourceManager ( )
protected

singleton, private constructor

Member Function Documentation

void basic::resource_manager::ResourceManager::add_resource ( ResourceTag const &  resource_tag,
ResourceOP  resource 
)
protectedvirtual

Derived classes, when they instantiate a resource, should name it and give it to the base class for it to hold. A resource may be later deallocated using the "free_resource" function.

References resources_.

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

void basic::resource_manager::ResourceManager::clear ( )
virtual

wipe out all data; useful for unit testing, but hard to fathom how it would be useful otherwise.

Reimplemented in basic::resource_manager::LazyResourceManager.

References resources_.

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

private singleton creation function to be used with utility::thread::threadsafe_singleton Not clear that this is appropriate for the ResourceManager.

References basic::resource_manager::ResourceManagerFactory::create_resource_manager_from_options_system(), and basic::resource_manager::ResourceManagerFactory::get_instance().

Referenced by get_instance().

ResourceOP basic::resource_manager::ResourceManager::find_resource ( ResourceTag const &  resource_tag)
virtual
void basic::resource_manager::ResourceManager::free_resource ( ResourceTag const &  resource_tag)
protectedvirtual

Derived classes, when they are ready to deallocate a resource, may do so in this function.

References has_resource(), resources_, and utility_exit_with_message.

Referenced by basic::resource_manager::LazyResourceManager::free_resource_by_job_tag(), and basic::resource_manager::LazyResourceManager::free_resource_by_tag().

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

Singleton accessor: request access to the resource manager.

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::get_resource(), and basic::resource_manager::locator::DatabaseResourceLocator::locate_resource_stream().

virtual bool basic::resource_manager::ResourceManager::get_option ( utility::options::BooleanOptionKey  key) const
pure virtual

Retrieve the boolean value represented by the given option key.

The following 12 functions allow protocols to request options that may have been set for the context in which the protocol is being run.

virtual utility::vector1< bool > const& basic::resource_manager::ResourceManager::get_option ( utility::options::BooleanVectorOptionKey  key) const
pure virtual

Retrieve the vector of boolean values represented by the given option key.

virtual utility::file::FileName const& basic::resource_manager::ResourceManager::get_option ( utility::options::FileOptionKey  key) const
pure virtual

Retrieve the FileName value represented by the given option key.

virtual utility::vector1< utility::file::FileName > const& basic::resource_manager::ResourceManager::get_option ( utility::options::FileVectorOptionKey  key) const
pure virtual

Retrieve the vector of FileName values represented by the given option key.

virtual int basic::resource_manager::ResourceManager::get_option ( utility::options::IntegerOptionKey  key) const
pure virtual

Retrieve the integer value represented by the given option key.

virtual utility::vector1< int > const& basic::resource_manager::ResourceManager::get_option ( utility::options::IntegerVectorOptionKey  key) const
pure virtual

Retrieve the vector of integer values represented by the given option key.

virtual utility::file::PathName const& basic::resource_manager::ResourceManager::get_option ( utility::options::PathOptionKey  key) const
pure virtual

Retrieve the PathName value represented by the given option key.

virtual utility::vector1< utility::file::PathName > const& basic::resource_manager::ResourceManager::get_option ( utility::options::PathVectorOptionKey  key) const
pure virtual

Retrieve the vector of PathName values represented by the given option key.

virtual platform::Real basic::resource_manager::ResourceManager::get_option ( utility::options::RealOptionKey  key) const
pure virtual

Retrieve the Real value represented by the given option key.

virtual utility::vector1< platform::Real > const& basic::resource_manager::ResourceManager::get_option ( utility::options::RealVectorOptionKey  key) const
pure virtual

Retrieve the vector of Real values represented by the given option key.

virtual std::string const& basic::resource_manager::ResourceManager::get_option ( utility::options::StringOptionKey  key) const
pure virtual

Retrieve the string value represented by the given option key.

virtual utility::vector1< std::string > const& basic::resource_manager::ResourceManager::get_option ( utility::options::StringVectorOptionKey  key) const
pure virtual

Retrieve the vector of string values represented by the given option key.

virtual ResourceOP basic::resource_manager::ResourceManager::get_resource ( ResourceDescription const &  resource_description)
pure virtual

Returns the resource with the given resource_description.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::BooleanOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

The following 12 functions allow protocols to request if a particular option has been set (e.g. on the command line or for the current job).

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::BooleanVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::FileOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::FileVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::IntegerOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::IntegerVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::PathOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::PathVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::RealOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::RealVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::StringOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

virtual bool basic::resource_manager::ResourceManager::has_option ( utility::options::StringVectorOptionKey  key) const
pure virtual

Return whether or not a value has been provided for the given option key either on the command line or through for the current job.

bool basic::resource_manager::ResourceManager::has_resource ( ResourceTag const &  resource_tag) const
virtual
virtual bool basic::resource_manager::ResourceManager::has_resource_with_description ( ResourceDescription const &  resource_description)
pure virtual

A protocol may ask whether a resource with a given resource description has been provided. It is possible that some resources are available sometimes when running a protocol, but not always (e.g. when running abinitio, sometimes you don't know what the native structure is).

void basic::resource_manager::ResourceManager::show ( std::ostream &  out) const
virtual

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
ResourceManager const &  resource_manager 
)
friend

Member Data Documentation

ResourceManager * basic::resource_manager::ResourceManager::instance_
staticprivate

Referenced by get_instance().

ResourcesMap basic::resource_manager::ResourceManager::resources_
private

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