Rosetta
2020.11
|
#include <ResourceManager.hh>
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 |
|
private |
|
private |
The set of Locators.
|
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.
|
private |
The instructions on how to create each resource locator that has been declared.
|
private |
|
private |
The instructions on how to create each resource that has been declared.
basic::resource_manager::ResourceManager::ResourceManager | ( | ) |
|
overridedefault |
void basic::resource_manager::ResourceManager::clear | ( | ) |
Delete all stored data, including all information about how to construct not-yet-constructed resources.
References living_resources_dependent_on_a_resource_, locators_for_resources_, resource_declarations_, resource_locator_declarations_, resource_locator_tags_, resource_locators_, resource_tags_, resources_, resources_a_resource_depends_on_, and resources_to_hold_until_deallocation_explicitly_requested_.
Referenced by pyrosetta.bindings.pose.ResidueLabelAccessor::discard().
|
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().
|
private |
Create and store a particular Resource that has been requested and that has not yet been constructed.
References debug_assert, find_resource_locator(), utility::SingletonBase< T >::get_instance(), input_id_from_resource_tag(), loader_type_from_resource_tag(), locator_name_from_resource_tag(), resource_tags_, resources_, and resources_being_constructed_stack_.
Referenced by get_resource().
|
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_.
|
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 | ) |
Get a resource with a given name.
References CREATE_EXCEPTION, create_resource(), has_resource(), living_resources_dependent_on_a_resource_, test.T008_Serialization::oss, resources_, resources_a_resource_depends_on_, and resources_being_constructed_stack_.
bool basic::resource_manager::ResourceManager::has_resource | ( | std::string const & | resource_name | ) | const |
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().
|
private |
Referenced by create_resource().
|
private |
References debug_assert.
Referenced by create_resource().
|
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_.
|
private |
Read the portion of an XML file that declares ResourceLocator objects.
References CREATE_EXCEPTION, test.G202_Module_PythonPDB::filename, test.T008_Serialization::oss, resource_locator_declarations_, and resource_locator_tags_.
Referenced by read_resources_from_xml().
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().
|
private |
Process all of the subtags of the given <Resources> tag.
References CREATE_EXCEPTION, debug_assert, test.G202_Module_PythonPDB::filename, test.T008_Serialization::oss, resource_declarations_, resource_locator_tags_, and resource_tags_.
Referenced by read_resources_from_xml().
|
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_.
|
static |
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).
References utility::tag::XMLSchemaSimpleSubelementList::add_already_defined_subelement(), utility::tag::XMLSchemaComplexTypeGenerator::add_attributes(), basic::resource_manager::ResourceLoaderFactory::complex_type_name_for_loader(), basic::resource_manager::ResourceLocatorFactory::complex_type_name_for_locator(), complex_type_name_for_resource_def(), utility::tag::XMLSchemaComplexTypeGenerator::complex_type_naming_func(), utility::tag::XMLSchemaComplexTypeGenerator::description(), utility::tag::XMLSchemaComplexTypeGenerator::element_name(), utility::SingletonBase< ResourceLocatorFactory >::get_instance(), utility::SingletonBase< T >::get_instance(), utility::tag::XMLSchemaElement::name(), utility::tag::required_name_attribute(), utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_pick_one(), utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_repeatable(), tag, basic::resource_manager::TR, utility::tag::XMLSchemaElement::type_name(), utility::tag::XMLSchemaComplexTypeGenerator::write_complex_type_to_schema(), and utility::tag::xs_string.
Referenced by validate_input_against_xsd().
|
private |
After having loaded a given XML file in from disk, validate its contents against the internally generated XML schema.
References CREATE_EXCEPTION, test.T009_Exceptions::e, utility::tag::XMLValidationOutput::error_messages(), utility::excn::Exception::msg(), test.T008_Serialization::oss, schema_for_resource_definition_file(), basic::resource_manager::TR, utility::tag::XMLValidationOutput::valid(), validator_, and utility::tag::XMLValidationOutput::warning_messages().
Referenced by read_resources_from_xml().
|
private |
Referenced by clear(), deallocate_resource(), and get_resource().
|
private |
Referenced by clear().
|
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().
|
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().
|
private |
Referenced by clear(), create_resource_locator(), read_resource_locators_tags(), and read_resources_tags().
|
private |
Referenced by clear(), and find_resource_locator().
|
private |
Referenced by clear(), create_resource(), has_resource(), n_resources_declared(), read_resources_tags(), and resources_that_have_been_declared().
|
private |
Referenced by clear(), create_resource(), deallocate_resource(), get_resource(), has_resource_in_memory(), and n_resources_in_memory().
|
private |
Referenced by clear(), deallocate_resource(), and get_resource().
|
private |
Referenced by create_resource(), and get_resource().
|
private |
Referenced by clear(), deallocate_resource(), and require_explicit_deallocation_for_resource().
|
private |
The object used to validate XML input files against the schema.
Referenced by validate_input_against_xsd().