25 #ifndef LSST_MWI_PERSISTENCE_DBSTORAGE_H
26 #define LSST_MWI_PERSISTENCE_DBSTORAGE_H
57 namespace persistence {
61 class DbStorageLocation;
65 typedef std::shared_ptr<DbStorage>
Ptr;
78 std::string
const& templateName,
79 bool mayAlreadyExist =
false);
80 virtual void dropTable(std::string
const& tableName);
83 virtual void executeSql(std::string
const& sqlStatement);
87 void setColumn(std::string
const& columnName, T
const& value);
94 std::vector<std::string>
const& tableNameList);
95 virtual void outColumn(std::string
const& columnName,
bool isExpr =
false);
96 template <
typename T>
void outParam(std::string
const& columnName,
97 T* location,
bool isExpr =
false);
98 template <
typename T>
void condParam(std::string
const& paramName,
100 virtual void orderBy(std::string
const& expression);
101 virtual void groupBy(std::string
const& expression);
103 virtual void query(
void);
104 virtual bool next(
void);
110 explicit DbStorage(std::type_info
const& type);
113 std::unique_ptr<DbStorageImpl>
_impl;
std::unique_ptr< DbStorageImpl > _impl
Implementation class for isolation.
std::shared_ptr< Policy > Ptr
virtual void setRetrieveLocation(LogicalLocation const &location)
Set the database location to retrieve from.
bool columnIsNull(int pos)
Determine if the value of a column is NULL.
void condParam(std::string const ¶mName, T const &value)
Bind a value to a WHERE condition parameter.
virtual void setPersistLocation(LogicalLocation const &location)
Set the database location to persist to.
virtual void createTableFromTemplate(std::string const &tableName, std::string const &templateName, bool mayAlreadyExist=false)
Create a new table from an existing template table.
virtual void endTransaction(void)
End a transaction.
virtual void startTransaction(void)
Start a transaction.
Class for logical location of a persisted Persistable instance.
virtual void setTableForQuery(std::string const &tableName, bool isExpr=false)
Set the table to query (single-table queries only).
virtual void truncateTable(std::string const &tableName)
Truncate a table.
Interface for Storage abstract base class.
virtual void setQueryWhere(std::string const &whereClause)
Set the condition for the WHERE clause of the query.
virtual void setPolicy(lsst::pex::policy::Policy::Ptr policy)
Allow a policy to be used to configure the DbStorage.
virtual bool next(void)
Move to the next (first) row of the query result.
Class for database storage.
virtual void insertRow(void)
Insert the row.
virtual void setTableForInsert(std::string const &tableName)
Set the table to insert rows into.
virtual void setTableListForQuery(std::vector< std::string > const &tableNameList)
Set a list of tables to query (multiple-table queries).
virtual void dropTable(std::string const &tableName)
Drop a table.
virtual void outColumn(std::string const &columnName, bool isExpr=false)
Request a column in the query output.
virtual void orderBy(std::string const &expression)
Request that the query output be sorted by an expression.
void outParam(std::string const &columnName, T *location, bool isExpr=false)
Request a column in the query output and bind a destination location.
void setColumn(std::string const &columnName, T const &value)
Set the value to insert in a given column.
std::shared_ptr< DbStorage > Ptr
virtual void executeSql(std::string const &sqlStatement)
Execute an arbitrary SQL statement.
virtual void query(void)
Execute the query.
T const & getColumnByPos(int pos)
Get the value of a column of the query result row by position.
virtual void finishQuery(void)
Indicate that query processing is finished.
virtual void setColumnToNull(std::string const &columnName)
Set a given column to NULL.
virtual void groupBy(std::string const &expression)
Request that the query output be grouped by an expression.
~DbStorage(void)
Minimal destructor.
Abstract base class for storage implementations.
DbStorage(void)
Constructor.