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

The DatabaseResourceLocator class is responsible for retreiving data from a Database so that that data can then be used to construct a Resource. More...

#include <DatabaseResourceLocator.hh>

Inheritance diagram for basic::resource_manager::locator::DatabaseResourceLocator:
Inheritance graph
[legend]

Public Member Functions

 DatabaseResourceLocator ()
 The default constructor sets empty strings for both the database session and for the SQL command; using this constructor requires initializing those two pieces of data using the parse-my-tag method. More...
 
 DatabaseResourceLocator (std::string const &database_session_resource_tag, std::string const &sql_command)
 Constructor that takes in both the name of the database session resource as well as the SQL command. More...
 
 DatabaseResourceLocator (DatabaseResourceLocator const &src)
 
 ~DatabaseResourceLocator () override
 
void show (std::ostream &out) const override
 Describe the DatabaseResourceLocator instance to the given output stream. More...
 
std::string type () const override
 Return the typename for this class: "DatabaseResourceLocator". More...
 
ResourceStreamOP locate_resource_stream (std::string const &input_id) const override
 Create a ResourceStream object from the given resource source, so that its stream can be passed to the ResourceLoader using the input "input_id" which is bound to the partially formed SQL select statement that was provided at construction or in parse_my_tag. More...
 
void parse_my_tag (utility::tag::TagCOP tag) override
 Initialize the DatabaseResourceLoader from the input set of tags which should contain both the name of the database session resource that will be used to talk to the database, and the partially formed SQL select statement that will be used to query the database. More...
 
- Public Member Functions inherited from basic::resource_manager::ResourceLocator
 ResourceLocator ()
 Construct a ResourceLocator and initialize its name (its locator_tag) to the empty string. More...
 
 ResourceLocator (std::string const &locator_tag)
 Construct a ResourceLocator while setting its name to the input locater_tag. More...
 
 ResourceLocator (ResourceLocator const &src)
 Copy construct a ResourceLocator from an example locator. More...
 
 ~ResourceLocator () override
 
virtual void locator_tag (std::string const &locator_tag)
 Set the name for this ResourceLocator. More...
 
virtual std::string locator_tag () const
 Return the name for this ResourceLocator. More...
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Static Public Member Functions

static void provide_xml_schema (utility::tag::XMLSchemaDefinition &xsd)
 Describe the schema for this resource locator to the XSD. More...
 
static std::string classname ()
 

Private Attributes

std::string database_session_resource_tag_
 
std::string sql_command_
 
std::string column_separator_
 
utility::sql_database::sessionOP db_session_
 

Detailed Description

The DatabaseResourceLocator class is responsible for retreiving data from a Database so that that data can then be used to construct a Resource.

Upon construction or in its parse_my_tag method, the DatabaseResourceLocator needs to be given the name of the database-session resource that it will use to communicate with the database and a partially formatted SQL command (a SELECT statement) that will be used to query the database for the resource that it will be pulling from the database. This SQL command should have a single question mark ("?") for the variable that will be replaced by the locator_id that will be given to the DatabaseResourceLocator when its locate_resource_stream method is invoked. In that method, the DatabaseResourceLocator will ask the ResourceManager for the database session object and then bind the input "locator_id" to the previously provided SQL command, and finally will query the database with that statement. The resulting output is packaged in a string stream and returned to the code that called locate_resource_stream (e.g. the ResourceManager) and then can be used to construct a resource.

Constructor & Destructor Documentation

basic::resource_manager::locator::DatabaseResourceLocator::DatabaseResourceLocator ( )

The default constructor sets empty strings for both the database session and for the SQL command; using this constructor requires initializing those two pieces of data using the parse-my-tag method.

basic::resource_manager::locator::DatabaseResourceLocator::DatabaseResourceLocator ( std::string const &  database_session_resource_tag,
std::string const &  sql_command 
)

Constructor that takes in both the name of the database session resource as well as the SQL command.

basic::resource_manager::locator::DatabaseResourceLocator::DatabaseResourceLocator ( DatabaseResourceLocator const &  src)
basic::resource_manager::locator::DatabaseResourceLocator::~DatabaseResourceLocator ( )
overridedefault

Member Function Documentation

std::string basic::resource_manager::locator::DatabaseResourceLocator::classname ( )
static
ResourceStreamOP basic::resource_manager::locator::DatabaseResourceLocator::locate_resource_stream ( std::string const &  input_id) const
overridevirtual

Create a ResourceStream object from the given resource source, so that its stream can be passed to the ResourceLoader using the input "input_id" which is bound to the partially formed SQL select statement that was provided at construction or in parse_my_tag.

Create a ResourceStream object from the given resource source, so that its stream can be passed to the ResourceLoader.

Implements basic::resource_manager::ResourceLocator.

References column_separator_, CREATE_EXCEPTION, db_session_, basic::resource_manager::ResourceLocator::locator_tag(), res, pyrosetta.tests.__main__::result, basic::database::safely_prepare_statement(), basic::database::safely_read_from_database(), and sql_command_.

void basic::resource_manager::locator::DatabaseResourceLocator::parse_my_tag ( utility::tag::TagCOP  tag)
overridevirtual

Initialize the DatabaseResourceLoader from the input set of tags which should contain both the name of the database session resource that will be used to talk to the database, and the partially formed SQL select statement that will be used to query the database.

Implements basic::resource_manager::ResourceLocator.

References basic::database::check_statement_sanity(), column_separator_, CREATE_EXCEPTION, db_session_, basic::database::parse_database_connection(), and sql_command_.

void basic::resource_manager::locator::DatabaseResourceLocator::provide_xml_schema ( utility::tag::XMLSchemaDefinition xsd)
static
void basic::resource_manager::locator::DatabaseResourceLocator::show ( std::ostream &  out) const
overridevirtual

Describe the DatabaseResourceLocator instance to the given output stream.

Implements basic::resource_manager::ResourceLocator.

References column_separator_, database_session_resource_tag_, and sql_command_.

Referenced by pyrosetta.distributed.viewer.core.Viewer::__call__().

std::string basic::resource_manager::locator::DatabaseResourceLocator::type ( ) const
overridevirtual

Return the typename for this class: "DatabaseResourceLocator".

Implements basic::resource_manager::ResourceLocator.

References classname().

Member Data Documentation

std::string basic::resource_manager::locator::DatabaseResourceLocator::column_separator_
private
std::string basic::resource_manager::locator::DatabaseResourceLocator::database_session_resource_tag_
private

Referenced by show().

utility::sql_database::sessionOP basic::resource_manager::locator::DatabaseResourceLocator::db_session_
private
std::string basic::resource_manager::locator::DatabaseResourceLocator::sql_command_
private

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