rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWDBMemTable Class Reference
[Utilities and Diagnostics]

Represents a table of data that resides in program memory. More...

#include <rw/db/memtable.h>

Inheritance diagram for RWDBMemTable:
RWDBTable

List of all members.

Public Member Functions

 RWDBMemTable (size_t capacity=0)
 RWDBMemTable (const RWDBTable &table, size_t capacity=0)
 RWDBMemTable (const RWDBTable &table, const RWDBConnection &connection, size_t capacity=0)
 RWDBMemTable (const RWDBSelectorBase &sel, size_t capacity=0)
 RWDBMemTable (const RWDBSelectorBase &sel, const RWDBConnection &connection, size_t capacity=0)
 RWDBMemTable (RWDBReader &reader, size_t capacity=0)
 RWDBMemTable (const RWDBMemTable &table)
RWDBMemTableoperator= (const RWDBMemTable &table)
size_t entries () const
RWDBRowoperator[] (size_t index)
bool populate (RWDBReader &reader)
bool populate (const RWDBTable &table)

Protected Member Functions

RWDBColumn operator[] (const RWCString &name) const
RWDBColumn operator[] (size_t idx) const

Detailed Description

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. The DB Interface Module provides operator[] for indexing on RWDBMemTable, the result of which is a reference to RWDBRow. RWDBRow inherits indexing operator operator[] from the Essential Tools Module 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, an RWDBReader may be produced from RWDBMemTable, allowing access to each row within the memory table, rather than using the overloaded operator operator[] 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.

Synopsis

 #include <rw/db/memtable.h>

 RWDBMemTable myTable = myDbase.memTable("myTable");

Constructor & Destructor Documentation

RWDBMemTable::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::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::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::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::RWDBMemTable ( const RWDBSelectorBase sel,
const RWDBConnection connection,
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::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::RWDBMemTable ( const RWDBMemTable table  ) 

Copy constructor. Self shares an implementation with table.


Member Function Documentation

size_t RWDBMemTable::entries (  )  const

Returns the number of rows in self.

RWDBMemTable& RWDBMemTable::operator= ( const RWDBMemTable table  ) 

Assignment operator. Self shares an implementation with table.

RWDBColumn RWDBMemTable::operator[] ( size_t  position  )  const [protected]

Returns a deep copy of the RWDBColumn in self's schema at the given position. The RWDBColumn returned is associated with self. If no matching column is found, returns an RWDBColumn whose status is RWDBStatus::columnNotFound. A deep copy is made so that the application can modify the returned RWDBColumn without modifying self's schema.

Reimplemented from RWDBTable.

RWDBColumn RWDBMemTable::operator[] ( const RWCString name  )  const [protected]

Returns a deep copy of the first RWDBColumn in self's schema whose name matches the given name. The RWDBColumn returned 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::ok. This is used with RWDBSelector to build up selectors and criteria without requiring an application to fetch the schema of a table. For example:

 myselector << table["name"]
See also:
RWDBSelector

Reimplemented from RWDBTable.

RWDBRow& RWDBMemTable::operator[] ( size_t  index  ) 

Returns a reference to the RWDBRow in self at position index. No bounds checking is done.

bool RWDBMemTable::populate ( const RWDBTable table  ) 

Fills self to capacity, with rows fetched from table. Rows existing in self before this call are discarded.

bool RWDBMemTable::populate ( RWDBReader reader  ) 

Fills self to capacity, with rows fetched from reader. Rows existing in self before this call are discarded.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.