Rosetta Utilities  2014.35
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>

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)
 
virtual ~DatabaseResourceLocator ()
 
virtual void show (std::ostream &out) const
 Describe the DatabaseResourceLocator instance to the given output stream. More...
 
virtual std::string type () const
 Return the typename for this class: "DatabaseResourceLocator". More...
 
virtual ResourceStreamOP locate_resource_stream (std::string const &locator_tag) const
 Create a ResourceStream object from the given resource source, so that its stream can be passed to the ResourceLoader using the input "locator_tag" which is bound to the partially formed SQL select statement that was provided at construction or in parse_my_tag. More...
 
virtual void parse_my_tag (utility::tag::TagCOP tag)
 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...
 
virtual ~ResourceLocator ()
 
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::pointer::ReferenceCount
void ctor ()
 
virtual ~ReferenceCount ()
 Destructor. More...
 
Size ref_count () const
 Reference count. More...
 

Private Attributes

std::string database_session_resource_tag_
 
std::string sql_command_
 
std::string column_separator_
 

Additional Inherited Members

- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 
- Protected Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
 ReferenceCount (ReferenceCount const &)
 Copy constructor. More...
 
ReferenceCountoperator= (ReferenceCount const &)
 Copy assignment. More...
 

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 ( )
virtual

Member Function Documentation

ResourceStreamOP basic::resource_manager::locator::DatabaseResourceLocator::locate_resource_stream ( std::string const &  locator_tag) const
virtual

Create a ResourceStream object from the given resource source, so that its stream can be passed to the ResourceLoader using the input "locator_tag" 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_, database_session_resource_tag_, basic::resource_manager::ResourceManager::get_instance(), basic::resource_manager::ResourceLocator::locator_tag(), 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)
virtual

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_, database_session_resource_tag_, and sql_command_.

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

Describe the DatabaseResourceLocator instance to the given output stream.

Implements basic::resource_manager::ResourceLocator.

References column_separator_, database_session_resource_tag_, and sql_command_.

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

Return the typename for this class: "DatabaseResourceLocator".

Implements basic::resource_manager::ResourceLocator.

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
std::string basic::resource_manager::locator::DatabaseResourceLocator::sql_command_
private

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