RWDBMemTable RWDBTable
Member Functions | |||
acquire() column() database() entries() exists() |
index() isValid() name() numberOfColumns() operator=() |
operator[]() populate() reader() release() schema() |
status() tag() |
#include <rw/db/memtable.h> RWDBMemTable myTable = myDbase.memTable("myTable");
RWDBMemTable is a table of data that resides in program memory. After construction, an RWDBMemTable is no longer associated with a table in the database. An application can modify the data in an RWDBMemTable, but the changes are not propagated back to the database.
RWDBMemTable is designed around the Interface/Implementation paradigm. An RWDBMemTable instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.
Because an RWDBMemTable resides in memory, it is possible to provide random access to its data. DBTools.h++ provides operator [] for indexing on RWDBMemTable, the result of which is a reference to RWDBRow. RWDBRow inherits indexing operator [] from the Tools.h++ class RWOrdered. The net result is the ability to access RWDBMemTable data with double indexing, as if it were a two-dimensional C++ array.
There are limitations to using RWDBMemTable, as it lacks some of the functionality of an RWDBTable. The differences in functionality come from the lack of a server in memory for selecting, deleting, inserting, and updating memory tables through SQL constructs. This means that selectors, cursors, deleters, inserters, and updaters cannot be created using memory tables. Instead, the actual table in the database must be referenced.
However, RWDBReader may be produced from RWDBMemTable, allowing access to each row within the memory table, rather than using the overloaded operators[ ] for indexing.
It should also be noted that since memory tables exist within memory, the normal data definition language (DDL) constructs that are associated with tables are also dysfunctional, and return invalid results. These include grant, revoke, addColumn, dropColumn, and so on.
RWDBMemTable (size_t capacity = 0);
Constructs an empty RWDBMemTable with given capacity. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable(const RWDBTable& table, size_t capacity = 0);
Uses a default database connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable(RWDBReader& reader, size_t capacity = 0);
Uses the supplied reader to construct an RWDBMemTable, populating it with a maximum of capacity rows copied from reader. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable(const RWDBTable& table, const RWDBConnection& connection, size_t capacity = 0);
Uses the supplied connection to construct an RWDBMemTable and populate it with a maximum of capacity rows from table. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable(const RWDBMemTable& table);
Copy constructor. Self shares an implementation with table.
RWDBMemTable(const RWDBSelectorBase& sel, const RWDBConnection& conn, size_t capacity=0);
Uses the supplied connection to construct an RWDBMemTable and to populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable(const RWDBSelectorBase& sel, size_t capacity=0);
Uses a default connection to construct an RWDBMemTable and populate it with the maximum of capacity rows from sel. A capacity of zero means there is no limit on the number of rows to be stored.
RWDBMemTable& operator=(const RWDBMemTable& table);
Assignment operator. Self shares an implementation with table.
RWDBRow& operator[](size_t index);
Returns a reference to the RWDBRow in self at position index. No bounds checking is done.
void acquire() const;
Attempts to acquire the internal mutex lock. If the mutex is already locked by another thread, the function blocks until the mutex is released. This function can be called from a const object. Note: in nonmultithreaded builds, this function evaluates to a no-op.
RWDBColumn column(const RWCString& name) const;
Inherited from RWDBTable. Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name. The returned RWDBColumn is associated with self, that is, the table() method of the returned RWDBColumn returns this table. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema.
RWDBColumn column(size_t index) const;
Inherited from RWDBTable. Returns a deep copy of the RWDBColumn in self's schema at the given index. The returned RWDBColumn is associated with self, that is, the table() method of the returned RWDBColumn returns this table. If index is out of range, the function returns an RWDBColumn with status RWDBStatus::invalidPosition. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema.
RWDBColumn column(const RWCString& name, RWCString::caseCompare caseCompare);
Inherited from RWDBTable. Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name, according to caseCompare. The RWDBColumn returned is associated with self, that is, the table()method of the returned RWDBColumn returns this table. If no match is found, the function returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that applications can modify the returned RWDBColumn without modifying self's schema. A deep copy of the column from self at the specified index is made. If index is out of range, the function returns an RWDBColumn whose status is RWDBStatus::invalidPosition.
RWDBDatabase database() const;
Inherited from RWDBTable. An RWDBMemTable is not closely associated with a database, so this method always returns an RWDBDatabase with a status of RWDBStatus::notInitialized.
int entries() const;
Returns the number of rows in self.
RWBoolean exists(RWBoolean forceLookup = False);
Always returns FALSE. Inherited from RWDBTable.
size_t index(const RWCString& name) const;
Inherited from RWDBTable. Returns the index in self's schema of the first column with the given name. Returns RW_NPOS if there is no such column.
size_t index(const RWDBColumn& column) const;
Inherited from RWDBTable. Returns the index in self's schema of the first column whose name matches the name of the given column. Returns RW_NPOS if there is no such column.
size_t index(const RWCString& name, RWCString::caseCompare caseCompare) const;
Inherited from RWDBTable. Returns the index in self's schema of the first column which matches the given name, according to caseCompare. Returns RW_NPOS if there is no such column.
RWBoolean isValid() const;
Inherited from RWDBTable. Returns TRUE if the status of self is RWDBStatus::ok, otherwise returns FALSE.
RWCString& name() const;
Inherited from RWDBTable. Returns self's name. Returns an empty string if self is unnamed.
RWDBTable& name(RWCString& name);
Inherited from RWDBTable. Changes the name of self to name. Returns a reference to self.
size_t numberOfColumns() const;
Inherited from RWDBTable. Returns the number of columns in self's schema.
RWBoolean populate(RWDBReader& reader);
Fills self, up to its capacity, with rows fetched from reader. Rows existing in self before this call are discarded.
RWBoolean populate(RWDBTable& table);
Fills self, up to its capacity, with rows fetched from table. Rows existing in self before this call are discarded.
RWDBReader reader() const;
Inherited from RWDBTable. Produces an RWDBReader which can be used to read data from self one row at a time.
RWDBReader reader(const RWDBConnection& connection) const;
Inherited from RWDBTable. Produces an RWDBReader which can be used to read data from self one row at a time. Since self is a table in memory, connection is unused.
void release() const;
Inherited from RWDBTable. Releases a previously acquired mutex. This function can be called from a const object. Note: in nonmultithreaded builds, this function evaluates to a no-op.
RWDBSchema schema() const;
Inherited from RWDBTable. Returns a deep copy of self's RWDBSchema. A deep copy is made so that an application can modify the returned RWDBSchema without changing self's schema.
RWDBStatus status() const;
Inherited from RWDBTable. Returns the status of self.
RWCString tag() const;
Inherited from RWDBTable. Returns self's tag. A table's tag is an alias generated by DBTools.h++ for use in SQL queries.
RWDBTable& tag(const RWCString& name);
Inherited from RWDBTable. Changes the tag of self to name. Returns a reference to self.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.