LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
lsst::daf::persistence::DbStorageLocation Class Reference

Location of a persisted Persistable instance in a database. More...

#include <DbStorageLocation.h>

Inheritance diagram for lsst::daf::persistence::DbStorageLocation:
lsst::daf::base::Citizen

Public Types

typedef boost::shared_ptr
< DbStorageLocation
Ptr
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 DbStorageLocation (void)
 
 DbStorageLocation (std::string const &url)
 
virtual ~DbStorageLocation (void)
 
virtual std::string toString (void) const
 
virtual std::string getConnString (void) const
 
virtual std::string const & getDbType (void) const
 
virtual std::string const & getHostname (void) const
 
virtual std::string const & getPort (void) const
 
virtual std::string const & getUsername (void) const
 
virtual std::string const & getPassword (void) const
 
virtual std::string const & getDbName (void) const
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Private Attributes

std::string _dbType
 Database type (e.g. "mysql"). More...
 
std::string _hostname
 
std::string _port
 
std::string _username
 
std::string _password
 
std::string _dbName
 Database (not server) name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Detailed Description

Location of a persisted Persistable instance in a database.

Provides database connection information for DbStorage. Can be initialized with either an all-in-one URL containing username and password information or a CORAL-style connection string URL with separate username and password.

Definition at line 58 of file DbStorageLocation.h.

Member Typedef Documentation

Definition at line 60 of file DbStorageLocation.h.

Constructor & Destructor Documentation

lsst::daf::persistence::DbStorageLocation::DbStorageLocation ( void  )

Default constructor.

Definition at line 55 of file DbStorageLocation.cc.

55  :
56  lsst::daf::base::Citizen(typeid(*this)),
58 }
std::string _dbType
Database type (e.g. &quot;mysql&quot;).
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
std::string _dbName
Database (not server) name.
lsst::daf::persistence::DbStorageLocation::DbStorageLocation ( std::string const &  url)

Constructor from CORAL-style URL.

Parameters
[in]urlCORAL-style connection string (database type, hostname, port, database name)

Definition at line 64 of file DbStorageLocation.cc.

64  :
65  lsst::daf::base::Citizen(typeid(*this)) {
66  boost::smatch what;
67  boost::regex
68  expression("(\\w+)://(\\S+):(\\d+)/(\\S+)");
69  if (boost::regex_match(url, what, expression)) {
70  _dbType = what[1];
71  _hostname = what[2];
72  _port = what[3];
73  _dbName = what[4];
76  }
77  else {
78  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
79  "Unparseable connection string passed to DbStorageLocation: " +
80  url);
81  }
82 }
std::string _dbType
Database type (e.g. &quot;mysql&quot;).
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
static std::string username(std::string const &host, std::string const &port)
Definition: DbAuth.cc:158
static std::string password(std::string const &host, std::string const &port)
Definition: DbAuth.cc:169
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
std::string _dbName
Database (not server) name.
lsst::daf::persistence::DbStorageLocation::~DbStorageLocation ( void  )
virtual

Destructor.

Definition at line 86 of file DbStorageLocation.cc.

86  {
87 }

Member Function Documentation

std::string lsst::daf::persistence::DbStorageLocation::getConnString ( void  ) const
virtual

Produce a CORAL-style connection string representation of the DbStorageLocation.

Returns
String suitable for passing to CORAL functions

Definition at line 101 of file DbStorageLocation.cc.

101  {
102  return _dbType + "://" + _hostname + ":" + _port + "/" + _dbName;
103 }
std::string _dbType
Database type (e.g. &quot;mysql&quot;).
std::string _dbName
Database (not server) name.
std::string const & lsst::daf::persistence::DbStorageLocation::getDbName ( void  ) const
virtual

Accessor for database name.

Returns
Reference to database name string.

Definition at line 143 of file DbStorageLocation.cc.

143  {
144  return _dbName;
145 }
std::string _dbName
Database (not server) name.
std::string const & lsst::daf::persistence::DbStorageLocation::getDbType ( void  ) const
virtual

Accessor for database type.

Returns
Reference to database type string.

Definition at line 108 of file DbStorageLocation.cc.

108  {
109  return _dbType;
110 }
std::string _dbType
Database type (e.g. &quot;mysql&quot;).
std::string const & lsst::daf::persistence::DbStorageLocation::getHostname ( void  ) const
virtual

Accessor for database hostname.

Returns
Reference to database hostname string.

Definition at line 115 of file DbStorageLocation.cc.

115  {
116  return _hostname;
117 }
std::string const & lsst::daf::persistence::DbStorageLocation::getPassword ( void  ) const
virtual

Accessor for password.

Returns
Reference to password string.

Definition at line 136 of file DbStorageLocation.cc.

136  {
137  return _password;
138 }
std::string const & lsst::daf::persistence::DbStorageLocation::getPort ( void  ) const
virtual

Accessor for database port number.

Returns
Reference to database port number string.

Definition at line 122 of file DbStorageLocation.cc.

122  {
123  return _port;
124 }
std::string const & lsst::daf::persistence::DbStorageLocation::getUsername ( void  ) const
virtual

Accessor for username.

Returns
Reference to username string.

Definition at line 129 of file DbStorageLocation.cc.

129  {
130  return _username;
131 }
std::string lsst::daf::persistence::DbStorageLocation::toString ( void  ) const
virtual

Produce a string (URL) representation of the DbStorageLocation.

Returns
String suitable for constructing another DbStorageLocation

Definition at line 92 of file DbStorageLocation.cc.

92  {
93  return _dbType + "://" + _username + ":" + _password + "@" +
94  _hostname + ":" + _port + "/" + _dbName;
95 }
std::string _dbType
Database type (e.g. &quot;mysql&quot;).
std::string _dbName
Database (not server) name.

Member Data Documentation

std::string lsst::daf::persistence::DbStorageLocation::_dbName
private

Database (not server) name.

Definition at line 81 of file DbStorageLocation.h.

std::string lsst::daf::persistence::DbStorageLocation::_dbType
private

Database type (e.g. "mysql").

Definition at line 76 of file DbStorageLocation.h.

std::string lsst::daf::persistence::DbStorageLocation::_hostname
private

Definition at line 77 of file DbStorageLocation.h.

std::string lsst::daf::persistence::DbStorageLocation::_password
private

Definition at line 80 of file DbStorageLocation.h.

std::string lsst::daf::persistence::DbStorageLocation::_port
private

Definition at line 78 of file DbStorageLocation.h.

std::string lsst::daf::persistence::DbStorageLocation::_username
private

Definition at line 79 of file DbStorageLocation.h.


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