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

#include <ResourceManager.hh>

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

Public Member Functions

 ResourceManager ()
 
 ~ResourceManager () override
 
void initialize_from_commandline ()
 Read all of the resource definition files specified on the command line from the "-resource_definitions <fname1> <fname2>... " flag. More...
 
void read_resources_from_xml (std::string const &filename, std::string const &input_xml)
 The ResourceManager will take the input stream and parse it as an XML document. Then it will read the ResourceLocators and Resouces tags out of this stream. Multiple streams may be read this way, though, if two streams try and declare the locators or resources that have the same name, then the ResourceManager will throw an exception. More...
 
platform::Size n_resources_declared () const
 How many resource definitions were read into the ResourceManager? More...
 
platform::Size n_resources_in_memory () const
 How many resources are currently being held by the ResourceManager? More...
 
bool has_resource (std::string const &resource_name) const
 Has a particular resource been declared? More...
 
bool has_resource_in_memory (std::string const &resource_name) const
 
std::list< std::string > resources_that_have_been_declared () const
 Return a list of all of the resources that have been declared. More...
 
void deallocate_resource (std::string const &resource_name)
 When a resource no longer needs to be held in memory, it may be deallocated. If the resource has not been allocated, this function simply returns (without throwing an exception). More...
 
void clear ()
 Delete all stored data, including all information about how to construct not-yet-constructed resources. More...
 
ResourceCOP get_resource (std::string const &resource_name)
 Get a resource with a given name. More...
 
- Public Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
virtual ~ReferenceCount ()
 

Static Public Member Functions

static std::string schema_for_resource_definition_file ()
 Construct the XML Schema for all of the various resource types that can be loaded using the ResourceManager using all of the various input-stream-fetching techniques (i.e. file on disk vs database query). More...
 
static std::string complex_type_name_for_resource_def (std::string const &element_name)
 The name mangling function for the top-level elements of the <ResourceDefinitions> tag in the resource-definition file. More...
 

Private Types

typedef std::map< std::string,
std::string > 
DeclarationMap
 
typedef std::map< std::string,
utility::tag::TagCOP
ResourceLocatorTagMap
 The instructions on how to create each resource locator that has been declared. More...
 
typedef std::map< std::string,
utility::tag::TagCOP
ResourceTagMap
 The instructions on how to create each resource that has been declared. More...
 
typedef std::map< std::string,
std::string > 
LocatorsForResourcesMap
 The locator to use in order to build a particular resource If a resource does not have an entry in this map, then the default FileSysteResoureLocator should be used. More...
 
typedef std::map< std::string,
ResourceLocatorOP
LocatorMap
 The set of Locators. More...
 
typedef std::map< std::string,
ResourceCOP
ResourcesMap
 

Private Member Functions

void validate_input_against_xsd (std::string const &xml_filename, std::string const &input_xml)
 After having loaded a given XML file in from disk, validate its contents against the internally generated XML schema. More...
 
void read_resources_tags (std::string const &filename, utility::tag::TagCOP tags)
 Process all of the subtags of the given <Resources> tag. More...
 
void read_resource_locators_tags (std::string const &filename, utility::tag::TagCOP tags)
 Read the portion of an XML file that declares ResourceLocator objects. More...
 
ResourceCOP create_resource (std::string const &resource_name)
 Create and store a particular Resource that has been requested and that has not yet been constructed. More...
 
ResourceLocatorOP create_resource_locator (std::string const &resource_locator_name) const
 Create and store a particular ResourceLocator that has been requested and that has not yet been constructed. More...
 
ResourceLocatorOP find_resource_locator (std::string const &locator_name)
 Return the ResourceLocator for the given resource, potentially instantiating this locator if it has not been previously instantiated. More...
 
std::string locator_name_from_resource_tag (utility::tag::TagCOP resource_tag) const
 
std::string input_id_from_resource_tag (utility::tag::TagCOP resource_tag) const
 
std::string loader_type_from_resource_tag (utility::tag::TagCOP resource_tag) const
 
void require_explicit_deallocation_for_resource (std::string const &resource_name)
 Do not deallocate the indicated resource until explicitly requested. This is only necessary for resources that are loaded during the course of constructing another resource, and that would be deallocated automatically when the first resource was deallocated. More...
 

Private Attributes

DeclarationMap resource_locator_declarations_
 The file in which a particular resource locator was declared; useful if two resource locators from two different files were given the same name. More...
 
DeclarationMap resource_declarations_
 The file in which a particular resource was declared; useful if two resources from two different files were given the same name. More...
 
ResourceLocatorTagMap resource_locator_tags_
 
ResourceTagMap resource_tags_
 
LocatorsForResourcesMap locators_for_resources_
 
LocatorMap resource_locators_
 
ResourcesMap resources_
 
utility::tag::XMLSchemaValidatorOP validator_
 The object used to validate XML input files against the schema. More...
 
utility::vector1< std::string > resources_being_constructed_stack_
 
std::map< std::string,
std::set< std::string > > 
resources_a_resource_depends_on_
 
std::map< std::string,
std::set< std::string > > 
living_resources_dependent_on_a_resource_
 
std::set< std::string > resources_to_hold_until_deallocation_explicitly_requested_
 

Additional Inherited Members

- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 

Member Typedef Documentation

typedef std::map< std::string, std::string > basic::resource_manager::ResourceManager::DeclarationMap
private

The set of Locators.

typedef std::map< std::string, std::string > basic::resource_manager::ResourceManager::LocatorsForResourcesMap
private

The locator to use in order to build a particular resource If a resource does not have an entry in this map, then the default FileSysteResoureLocator should be used.

The instructions on how to create each resource locator that has been declared.

The instructions on how to create each resource that has been declared.

Constructor & Destructor Documentation

basic::resource_manager::ResourceManager::ResourceManager ( )
basic::resource_manager::ResourceManager::~ResourceManager ( )
overridedefault

Member Function Documentation

void basic::resource_manager::ResourceManager::clear ( )
std::string basic::resource_manager::ResourceManager::complex_type_name_for_resource_def ( std::string const &  element_name)
static

The name mangling function for the top-level elements of the <ResourceDefinitions> tag in the resource-definition file.

Referenced by schema_for_resource_definition_file().

ResourceCOP basic::resource_manager::ResourceManager::create_resource ( std::string const &  resource_name)
private
ResourceLocatorOP basic::resource_manager::ResourceManager::create_resource_locator ( std::string const &  resource_locator_name) const
private

Create and store a particular ResourceLocator that has been requested and that has not yet been constructed.

References utility::SingletonBase< ResourceLocatorFactory >::get_instance(), and resource_locator_tags_.

Referenced by find_resource_locator().

void basic::resource_manager::ResourceManager::deallocate_resource ( std::string const &  resource_name)

When a resource no longer needs to be held in memory, it may be deallocated. If the resource has not been allocated, this function simply returns (without throwing an exception).

References clean_pdb_keep_ligand::count, debug_assert, basic::options::OptionKeys::score::empty, living_resources_dependent_on_a_resource_, resources_, resources_a_resource_depends_on_, and resources_to_hold_until_deallocation_explicitly_requested_.

ResourceLocatorOP basic::resource_manager::ResourceManager::find_resource_locator ( std::string const &  locator_name)
private

Return the ResourceLocator for the given resource, potentially instantiating this locator if it has not been previously instantiated.

References create_resource_locator(), and resource_locators_.

Referenced by create_resource().

ResourceCOP basic::resource_manager::ResourceManager::get_resource ( std::string const &  resource_name)
bool basic::resource_manager::ResourceManager::has_resource ( std::string const &  resource_name) const

Has a particular resource been declared?

References resource_tags_.

Referenced by get_resource().

bool basic::resource_manager::ResourceManager::has_resource_in_memory ( std::string const &  resource_name) const

Does a particular resource currently reside in memory? Mostly this function is for testing purposes.

References resources_.

void basic::resource_manager::ResourceManager::initialize_from_commandline ( )

Read all of the resource definition files specified on the command line from the "-resource_definitions <fname1> <fname2>... " flag.

References CREATE_EXCEPTION, utility::file_contents(), assign_charges::ifs, basic::options::option, test.T008_Serialization::oss, read_resources_from_xml(), basic::options::OptionKeys::jd3::resource_definition_files, and utility::slurp().

std::string basic::resource_manager::ResourceManager::input_id_from_resource_tag ( utility::tag::TagCOP  resource_tag) const
private

Referenced by create_resource().

std::string basic::resource_manager::ResourceManager::loader_type_from_resource_tag ( utility::tag::TagCOP  resource_tag) const
private

References debug_assert.

Referenced by create_resource().

std::string basic::resource_manager::ResourceManager::locator_name_from_resource_tag ( utility::tag::TagCOP  resource_tag) const
private

Referenced by create_resource().

platform::Size basic::resource_manager::ResourceManager::n_resources_declared ( ) const

How many resource definitions were read into the ResourceManager?

References resource_tags_.

platform::Size basic::resource_manager::ResourceManager::n_resources_in_memory ( ) const

How many resources are currently being held by the ResourceManager?

References resources_.

void basic::resource_manager::ResourceManager::read_resource_locators_tags ( std::string const &  filename,
utility::tag::TagCOP  tags 
)
private
void basic::resource_manager::ResourceManager::read_resources_from_xml ( std::string const &  filename,
std::string const &  input_xml 
)

The ResourceManager will take the input stream and parse it as an XML document. Then it will read the ResourceLocators and Resouces tags out of this stream. Multiple streams may be read this way, though, if two streams try and declare the locators or resources that have the same name, then the ResourceManager will throw an exception.

References utility::tag::Tag::create(), debug_assert, read_resource_locators_tags(), read_resources_tags(), basic::options::OptionKeys::in::file::tags, and validate_input_against_xsd().

Referenced by initialize_from_commandline().

void basic::resource_manager::ResourceManager::read_resources_tags ( std::string const &  filename,
utility::tag::TagCOP  tags 
)
private
void basic::resource_manager::ResourceManager::require_explicit_deallocation_for_resource ( std::string const &  resource_name)
private

Do not deallocate the indicated resource until explicitly requested. This is only necessary for resources that are loaded during the course of constructing another resource, and that would be deallocated automatically when the first resource was deallocated.

References resources_to_hold_until_deallocation_explicitly_requested_.

std::list< std::string > basic::resource_manager::ResourceManager::resources_that_have_been_declared ( ) const

Return a list of all of the resources that have been declared.

References resource_tags_.

std::string basic::resource_manager::ResourceManager::schema_for_resource_definition_file ( )
static
void basic::resource_manager::ResourceManager::validate_input_against_xsd ( std::string const &  xml_filename,
std::string const &  input_xml 
)
private

Member Data Documentation

std::map< std::string, std::set< std::string > > basic::resource_manager::ResourceManager::living_resources_dependent_on_a_resource_
private
LocatorsForResourcesMap basic::resource_manager::ResourceManager::locators_for_resources_
private

Referenced by clear().

DeclarationMap basic::resource_manager::ResourceManager::resource_declarations_
private

The file in which a particular resource was declared; useful if two resources from two different files were given the same name.

Referenced by clear(), and read_resources_tags().

DeclarationMap basic::resource_manager::ResourceManager::resource_locator_declarations_
private

The file in which a particular resource locator was declared; useful if two resource locators from two different files were given the same name.

Referenced by clear(), and read_resource_locators_tags().

ResourceLocatorTagMap basic::resource_manager::ResourceManager::resource_locator_tags_
private
LocatorMap basic::resource_manager::ResourceManager::resource_locators_
private

Referenced by clear(), and find_resource_locator().

ResourceTagMap basic::resource_manager::ResourceManager::resource_tags_
private
ResourcesMap basic::resource_manager::ResourceManager::resources_
private
std::map< std::string, std::set< std::string > > basic::resource_manager::ResourceManager::resources_a_resource_depends_on_
private
utility::vector1< std::string > basic::resource_manager::ResourceManager::resources_being_constructed_stack_
private

Referenced by create_resource(), and get_resource().

std::set< std::string > basic::resource_manager::ResourceManager::resources_to_hold_until_deallocation_explicitly_requested_
private
utility::tag::XMLSchemaValidatorOP basic::resource_manager::ResourceManager::validator_
private

The object used to validate XML input files against the schema.

Referenced by validate_input_against_xsd().


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