Rosetta
2016.11
|
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 | |
ResourceManager () | |
virtual | ~ResourceManager () |
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... | |
Public Member Functions inherited from utility::pointer::ReferenceCount | |
ReferenceCount () | |
Default constructor. More... | |
virtual | ~ReferenceCount () |
Static Public Member Functions | |
static ResourceManager * | get_instance () |
Deprecated access to a global (not-quite singleton) ResourceManager instance that should be removed. More... | |
Protected Member Functions | |
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 |
Private Attributes | |
ResourcesMap | resources_ |
Friends | |
std::ostream & | operator<< (std::ostream &out, ResourceManager const &resource_manager) |
Additional Inherited Members | |
Public Types inherited from utility::pointer::ReferenceCount | |
typedef platform::Size | Size |
typedef platform::Size | size_type |
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.)
|
private |
basic::resource_manager::ResourceManager::ResourceManager | ( | ) |
|
virtual |
|
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().
|
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_.
|
virtual |
Get a resource with a given name.
Reimplemented in basic::resource_manager::LazyResourceManager.
References resources_, and utility_exit_with_message.
Referenced by basic::resource_manager::LazyResourceManager::find_resource().
|
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().
|
static |
Deprecated access to a global (not-quite singleton) ResourceManager instance that should be removed.
References basic::resource_manager::ResourceManagerFactory::create_resource_manager_from_options_system(), and utility::SingletonBase< ResourceManagerFactory >::get_instance().
Referenced by basic::resource_manager::get_resource(), and basic::resource_manager::locator::DatabaseResourceLocator::locate_resource_stream().
|
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.
|
pure virtual |
Retrieve the vector of boolean values represented by the given option key.
|
pure virtual |
Retrieve the FileName value represented by the given option key.
|
pure virtual |
Retrieve the vector of FileName values represented by the given option key.
|
pure virtual |
Retrieve the integer value represented by the given option key.
|
pure virtual |
Retrieve the vector of integer values represented by the given option key.
|
pure virtual |
Retrieve the PathName value represented by the given option key.
|
pure virtual |
Retrieve the vector of PathName values represented by the given option key.
|
pure virtual |
Retrieve the Real value represented by the given option key.
|
pure virtual |
Retrieve the vector of Real values represented by the given option key.
|
pure virtual |
Retrieve the string value represented by the given option key.
|
pure virtual |
Retrieve the vector of string values represented by the given option key.
|
pure virtual |
Returns the resource with the given resource_description.
|
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).
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 |
Does a resource with a given name exist?
Reimplemented in basic::resource_manager::LazyResourceManager.
References resources_.
Referenced by basic::resource_manager::LazyResourceManager::find_resource(), free_resource(), and basic::resource_manager::LazyResourceManager::has_resource().
|
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).
|
virtual |
Reimplemented in basic::resource_manager::LazyResourceManager.
References basic::options::OptionKeys::ufv::left, and resources_.
Referenced by basic::resource_manager::operator<<(), and basic::resource_manager::LazyResourceManager::show().
|
friend |
|
private |
Referenced by add_resource(), clear(), find_resource(), free_resource(), has_resource(), and show().