RWDBTMemTableBase RWDBTable RWDBTPtrMemTable <T, C> class C
Member Functions | |||
acquire() column() database() entries() |
exists() index() isValid() name() |
numberOfColumns() operator[]() populate() reader() |
release() schema() status() tag() |
#include <rw/db/tpmemtab.h> RWDBTPtrMemTable<T, C> mt;
This class represents a parameterized memory table. Not only can the type of the object inserted into the memory table be parameterized, but also the implementation.
Parameter T represents the type of the object to be stored in the memory table. It can be a class or a built-in type. The class must have:
Well-defined copy semantics (T::T(const T&) or the equivalent)
Well-defined assignment semantics (T::operator=(const T&) or the equivalent)
Any other semantics required by class C. For Rogue Wave collections, this includes a default constructor.
A friend function to map the columns read by an RWDBReader to the elements of T:
friend RWDBReader& operator>>(const RWDBReader&, const T&)
Parameter C represents the pointer- based template collection used as the implementation of the memory table. It must have:
A well-defined void insert(T*) method
A well-defined T* operator[](size_t) method
A well-defined size_t entries() method
Possible choices for C are the Tools.h++ classes RWTPtrSlist and RWTPtrOrderedVector.
The constructors for the class dynamically allocate space for the elements of type T that are placed in the collection. It is the application's responsibility to free this memory when the RWDBTPtrMemTable goes out of scope. An effective way to do this is to have the collection class C call delete on each of the entries in its destructor.
RWDBTPtrMemTable(size_t maxElements = 0);
This constructor builds an empty instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table.
RWDBTPtrMemTable(const RWDBSelectorBase& selector, size_t maxElements = 0);
This constructor builds an instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table. After building the memory table, an RWDBReader instance is created on the selector. From this reader, up to maxElements instances of class T are allocated and inserted into the memory table. It is the application's responsibility to free the memory associated with the table.
RWDBTPtrMemTable(const RWDBSelectorBase& selector, const RWDBConnection& connection, size_t maxElements = 0);
This constructor builds an instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table. After building the memory table, an RWDBReader instance, using the connection specified by connection, is created on the selector. From this reader, up to maxElements instances of class T are allocated and inserted into the memory table. It is the application's responsibility to free the memory associated with the table.
RWDBTPtrMemTable(const RWDBTable& table, size_t maxElements = 0);
This constructor builds an instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table. After building the memory table, an RWDBReader instance is created on the table. From this reader, up to maxElements instances of class T are allocated and inserted into the memory table. It is the application's responsibility to free the memory associated with the table.
RWDBTPtrMemTable(const RWDBTable& table, const RWDBConnection& connection, size_t maxElements = 0);
This constructor builds an instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table. After building the memory table, an RWDBReader instance, using the connection specified by connection, is created on the table. From this reader, up to maxElements instances of class T are allocated and inserted into the memory table. It is the application's responsibility to free the memory associated with the table.
RWDBTPtrMemTable(const RWDBReader& reader, size_t maxElements = 0);
This constructor builds an instance with an upper limit of maxElements. If maxElements is zero, no upper limit is imposed on the number of elements in the memory table. After building the memory table, the RWDBReader instance reader is used to allocate and insert into the memory table up to maxElements instances of class T. It is the application's responsibility to free the memory associated with the table.
T* operator[](size_t index);
Returns a pointer to the T* in self at position index. Uses user-defined operator T* C::operator[](size_t index).
void acquire() const;
Inherited from RWDBTable. 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.
RWDBColumn column(size_t index) const;
Inherited from RWDBTable.
RWDBDatabase database();
Inherited from RWDBTable.
size_t entries();
Returns number of rows in self. Uses user-defined method C::entries().
RWBoolean exists(RWBoolean forceLookup = False);
Inherited from RWDBTable. Always returns TRUE.
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.
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 a self's schema.
void populate(RWDBReader& reader);
Inherited from the base class RWDBTMemTableBase. This routine uses the RWDBReader instance reader to allocate and append to the memory table instances of T. It is the application's responsibility to free the memory associated with the table.
RWDBReader reader() const;
Inherited from RWDBTable. Returns an RWDBReader instance with a status of RWDBStatus::noReader. Instances of RWDBTPtrMemTable cannot support readers.
RWDBReader reader(const RWDBConnection& connection) const;
Inherited from RWDBTable. Returns a RWDBReader instance with a status of RWDBStatus::noReader. Instances of RWDBTPtrMemTable cannot support readers. The supplied connection is ignored, but is held by the reader until the reader is destroyed. This function can behave asynchronously if executed using an asynchronous connection.
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();
Inherited from RWDBTable.
RWDBStatus status() const;
Inherited from RWDBTable. Returns the status of self.
RWCString tag() const;
Inherited from RWDBTable.
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.