Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dbTable Class Reference
[OOFILE Database package]

#include <oof1.h>

Inheritance diagram for dbTable:

Inheritance graph
[legend]
Collaboration diagram for dbTable:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for persistent tables.

Must be used in association with a dbConnect subclass to provide persistence. Contains one or more dbField members either by declaration or attachField().


recordwise access

void start ()
void next ()
 Next record in the selection becomes current.

void first ()
 First record in the selection becomes current.

void prev ()
 Previous record in the selection becomes current.

void last ()
 Last record in the selection becomes current.

bool more () const
 When iterating a selection, are there any more records beyond current.

bool atFirst () const
bool atLast () const
bool atRelative (unsigned long) const
unsigned long count ()
 Count records in current selection.

unsigned long countAll () const
 Count records in database regardless of current selection.


sorting

void setSortOrder (const dbField &, bool shouldReverse=false)
void setSortOrder (const dbSorter &)
void setReverseSortOrder (const dbField &)
dbSortersorter () const
void sortNow () const
void unSorted ()
void suspendSorting ()
void resumeSorting ()

change record state

void unloadRecord ()
bool reloadRecord ()
void markDirty ()

state enquiry

bool isRecordLoaded () const
bool isEmpty ()
bool isNewRecord () const
bool isTableValid () const
tableValidT validStatus () const
int validatingDepth () const
bool allSelected () const
 Does the current selection represent all records or just a subset.

bool isDirty () const

change duplicate handling, typically for wrapping import code

void ignoreDuplicateRecords ()
void noticeDuplicateRecords ()

recordNumber operations for temporary direct acccess

unsigned long recordNumber () const
 Ordinal record number of current record in selection.

unsigned long recordNumberOfOID (oidT inOID)
 Find ordinal position in ordered selection of record by OID.

unsigned long recordNumber (const dbQueryClause *qClause, bool *outFoundIt=0) const
unsigned long recordNumber (const dbQueryClause &qClause, bool *outFoundIt=0) const
bool gotoRecord (unsigned long)

keyword searches

dbQueryBinaryNofield hasWord (const char *str) const
dbQueryBinaryNofield hasAnyWordsDelimited (const char *, char delimiter)
dbQueryBinaryNofield hasAllWordsDelimited (const char *, char delimiter)
dbQueryBinaryNofield hasAnyWordsOf (const char **schStrs, unsigned long count)
dbQueryBinaryNofield hasAllWordsOf (const char **schStrs, unsigned long count)
dbQueryBinaryNofield hasAnyWordsOf (oofWordParser *)
dbQueryBinaryNofield hasAllWordsOf (oofWordParser *)
dbQueryBinaryNofield hasWordStartsWith (const char *str) const
dbQueryBinaryNofield hasAnyWordsStartsWithDelimited (const char *, char delimiter)
dbQueryBinaryNofield hasAllWordsStartsWithDelimited (const char *, char delimiter)
dbQueryBinaryNofield hasAnyWordsStartsWithOf (const char **schStrs, unsigned long count)
dbQueryBinaryNofield hasAllWordsStartsWithOf (const char **schStrs, unsigned long count)
dbQueryBinaryNofield hasAnyWordsStartsWithOf (oofWordParser *)
dbQueryBinaryNofield hasAllWordsStartsWithOf (oofWordParser *)

public search functions

bool search (const dbQueryClause &query)
bool searchSelection (const dbQueryClause &query)
bool search (const dbQueryClause *query)
bool searchSelection (const dbQueryClause *query)
bool searchSelContainsAnyDelimited (const dbField &schField, const char *schStr, char delim)
bool searchSelContainsAnyOf (const dbField &schField, const char **schStrs, unsigned long count)
bool searchSelContainsAnyOf (const dbField &schField, oofWordParser *)
bool searchSelContainsAllDelimited (const dbField &schField, const char *schStr, char delim)
bool searchSelContainsAllOf (const dbField &schField, const char **schStrs, unsigned long count)
bool searchSelContainsAllOf (const dbField &schField, oofWordParser *)

set operations

void difference_with (dbTable &)
void difference_with (dbTable *)
void difference_with (const dbSelection &)
void operator-= (dbTable &)
 Operator performing difference_with set operation.

void operator-= (dbTable *)
 Operator performing difference_with set operation.

void operator-= (const dbSelection &)
 Operator performing difference_with set operation.

void operator%= (dbTable &)
 Operator performing difference_with set operation.

void operator%= (dbTable *)
 Operator performing difference_with set operation.

void operator%= (const dbSelection &)
 Operator performing difference_with set operation.

void intersection_with (dbTable &)
void intersection_with (dbTable *)
void intersection_with (const dbSelection &)
void operator &= (dbTable &)
 Operator performing intersection_with set operation.

void operator &= (dbTable *)
 Operator performing intersection_with set operation.

void operator &= (const dbSelection &)
 Operator performing intersection_with set operation.

void union_with (dbTable &)
void union_with (dbTable *)
void union_with (const dbSelection &)
void union_with_no_overlap (dbTable &)
void union_with_no_overlap (dbTable *)
void union_with_no_overlap (const dbSelection &)
void operator+= (dbTable &)
 Operator performing union_with set operation.

void operator+= (dbTable *)
 Operator performing union_with set operation.

void operator+= (const dbSelection &)
 Operator performing union_with set operation.

void operator|= (dbTable &)
 Operator performing union_with set operation.

void operator|= (dbTable *)
 Operator performing union_with set operation.

void operator|= (const dbSelection &)
 Operator performing union_with set operation.

void invert ()
void operator~ ()
 Operator performing invert set operation.

void operator! ()
 Operator performing invert set operation.

bool operator+= (oidT)
 Operator performing addOIDtoSelection set operation like union_with.

bool addOIDtoSelection (oidT)
bool contains (oidT)
 Check if current selection contains an OID.

void dropRecordFromSelection (unsigned long)

getting & saving selections as lightweight objects

dbSelection currentSelection ()
dbSelection makeEmptySelection () const
void setSelection (const dbSelection &)
void setSelection (const OOF_Selection *)
const dbSelectionoperator= (const dbSelection &rhs)

selection changes that broadcast, eg: to update MN relationship links

void appendSelection (const dbSelection &)
void removeSelection (const dbSelection &)
void clearSelection ()

selection of specific contexts

void selectAll ()
 Change the current selection to all records.

void selectNone ()
 Change the current selection to no records.

bool selectJustOID (oidT)
 Try to change the current selection to just the matching record.

void selectJustCurrent ()
 Change the current selection to just the current record.

bool relateSelectionFrom (dbTable *)
bool selectAllRelated (bool broadcastChange=true)

data access

virtual void newRecord ()
virtual void cloneRecord ()
virtual void postCloneRecordCleanup ()
virtual void saveRecord ()
virtual void revertRecord ()
virtual void deleteRecord ()
void deleteSelection ()
void deleteAll ()
void copyAllFrom (dbTable *)
dbTableAssigner operator<< (const char *)
 Create dbTableAssigner as fast way to create and set entire record.

void copyRecFrom (const dbTable *rhs, fieldNumT numFields=0)
dbTableoperator= (const dbTable &)
virtual void extract (std::ostream &)
virtual unsigned long insert (std::istream &)
virtual void import (const char *ansiFileName)
bool allowsShortImports () const
void setShortImports (bool)

reflective schema operators

const oofStringtableName () const
virtual oofString tableSingularName () const
tableNumT tableNumber () const
bool tableCachesDirtyRecords () const
saveOptionsT tableSaveOption () const
virtual void describe (std::ostream &) const
 Provide human-readable information about object.

virtual void describeState (std::ostream &) const
virtual void stats (std::ostream &)
bool isCopyCompatibleWith (const dbTable *) const
fieldNumT numFields () const
dbFieldfield (fieldNumT) const
dbFieldfield (const oofString &)
bool isOpen () const
bool inDeclarativePhase () const
 Has database been opened or are we still potentially declaring tables.


info about relationships

bool isRelatedClone () const
dbRelRefBasecontrollingRelationship () const
dbTablelhsTableInRelationshipSpec () const
dbTablebaseTableOfRelationChain ()

locking

void lockRecord ()
void unlockRecord ()
bool lockedCurrentRecord () const

transactions

void beginTransaction (short tMode=0)
 Start a transaction if not already in one.

void abortTransaction (short rMode=0)
 Forward request to backend to abort transaction, if mInTransaction.

void commitTransaction (short rMode=0)
bool transactionDirty ()

Public Types

enum  { kFieldSep = '\t' }
enum  { kRecSep = '\n' }
enum  selSharingT { selNotShared, selShared, selCopyOnWrite, selNotSharedCacheCopied }
enum  saveOptionsT { requireExplicit, autoOnContextChange, requireExplicitAndBuffer, bufferForever }
enum  tableValidT { eInvalid = 0, eValid, eClosed }

Public Member Functions

 dbTable (const char *name=0)
 dbTable (const dbTable &)
 dbTable (const dbTable &, OOF_tableBackend *)
virtual ~dbTable ()
void stillCurrentlyConstructing ()
dbTableprototype () const
virtual const char * defaultName () const
virtual oofString name () const
void setName (const char *)
virtual dbTablecloneTableSharingSelection () const
virtual dbTablecloneTableWithoutSelection () const
virtual dbTablecloneTbleWithCachNoSelection () const
virtual dbTablecloneTable (selSharingT selSharing=selCopyOnWrite)=0
virtual dbTablecloneTableConst (selSharingT selSharing) const=0
 pure virtual cloneTable is implemented by macro OOFILE_METHODS, in oofmacro.h, for each user subclass.

void postCloneTableCleanup ()
virtual dbViewmakeView ()
bool ensureRecordLoaded (bool autoCreateRelated=false, bool failureAborts=true)
void ensureSelectionLoaded ()
void relateAllDeletables ()
oidT currentOID ()
 Absolute record address of current record.

oidT oidOfRecord (unsigned long)
bool loadRelatedContextJoiningFromTo (const dbField *, const dbField *)
 Change table's current loaded selection and current record to satisfy a join.

oofWordParsergetDefaultWordParser ()
void setDefaultWordParser (oofWordParser *inParser)
void setSaveOption (const saveOptionsT)
void setFileExtensions (const char *dataExt, const char *indexExt)
bool pointsToBackend (const OOF_tableBackend *) const
virtual bool canSaveRecord ()
void attachfield (dbField *)
void buildSchema ()
void addIndices (const char *newIDXname)
void suppressIndices ()
void rebuild ()
void close ()
void deleteStorage ()
void createTableInConnection (const dbConnect *)
bool openTableInConnection (const dbConnect *, const bool createIfMissing=false)
unsigned int numIndexes () const
unsigned int numFiles () const
unsigned long sequenceNumber () const
void setTableValid (bool isValid=true)
 Force current table state to valid.

void pack ()
dbGUIgetGUI ()
virtual void generateTestData (unsigned long numRecords, bool generateRandom=true, unsigned long seedOrCount=0)
bool changeShielded () const
 change shielding, so field changes don't mark the record as dirty.

void changeShielded (bool setShielding=true)
void describeInvariant (std::ostream &os) const
bool hidden () const
void hide (bool hideIt=true)
void broadcast (OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
 Broadcast a message to all anonymous subscribers.

oofReceiveraskAllStoppingAtFirst (bool stopOn, OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
bool askAllReturningAny (bool returnAny, OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
bool isBroadcasting () const
void addReceiver (oofReceiver *)
 Append receiver to end of list.

void removeReceiver (const oofReceiver *)

Protected Member Functions

void BroadcastShutdown ()

Protected Attributes

OOF_tableBackendmBackend
OOF_Dictionary mFields
oofString mTableName
tableNumT mTableNumber
fieldNumT mFieldCount
saveOptionsT mSaveOption
bool mAllowShortImports
tableValidT mTableValid
int mValidatingDepth
dbGUImGUI
bool mHidden
OOF_ExpandableLongArraymReceivers
 owned

unsigned long mNestedBroadcastingDepth
 aid to debugging and removeReceiver

bool mLostReceiversWhileBroadcasting
 simple flag that removeReceiver was called during nested broadcast


Static Protected Attributes

dbTablesCurrentlyConstructing

Friends

class dbField
class dbConnect
class dbConnect_ram
class dbConnect_ramp
class dbRelHalf
class dbRelRefBase
class OOF_tableBackend
class oofE_Table
void dbSelection::difference_with (dbTable &)


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
kFieldSep 

anonymous enum
 

Enumeration values:
kRecSep 

enum dbTable::saveOptionsT
 

Enumeration values:
requireExplicit 
autoOnContextChange 
requireExplicitAndBuffer 
bufferForever 

enum dbTable::selSharingT
 

Enumeration values:
selNotShared 
selShared 
selCopyOnWrite 
selNotSharedCacheCopied 

enum dbTable::tableValidT
 

Enumeration values:
eInvalid 
eValid 
eClosed 


Constructor & Destructor Documentation

dbTable::dbTable const char *  name = 0  ) 
 

dbTable::dbTable const dbTable  ) 
 

dbTable::dbTable const dbTable ,
OOF_tableBackend
 

dbTable::~dbTable  )  [virtual]
 


Member Function Documentation

void dbTable::abortTransaction short  rMode = 0  ) 
 

Forward request to backend to abort transaction, if mInTransaction.

Todo:
Investigate if should use transaction nesting count, not just mInTransaction.

void dbTable::addIndices const char *  newIDXname  ) 
 

bool dbTable::addOIDtoSelection oidT   ) 
 

void oofBroadcaster::addReceiver oofReceiver addingReceiver  )  [inherited]
 

Append receiver to end of list.

Includes assertion to check if already in list.

bool dbTable::allowsShortImports  )  const
 

bool dbTable::allSelected  )  const [inline]
 

Does the current selection represent all records or just a subset.

void dbTable::appendSelection const dbSelection  ) 
 

bool oofBroadcaster::askAllReturningAny bool  returnAny,
OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0
[inherited]
 

oofReceiver * oofBroadcaster::askAllStoppingAtFirst bool  stopOn,
OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0
[inherited]
 

bool dbTable::atFirst  )  const [inline]
 

bool dbTable::atLast  )  const [inline]
 

bool dbTable::atRelative unsigned  long  )  const [inline]
 

void dbTable::attachfield dbField  ) 
 

dbTable * dbTable::baseTableOfRelationChain  ) 
 

void dbTable::beginTransaction short  tMode = 0  ) 
 

Start a transaction if not already in one.

Todo:
Decide if this is robust as ignores nested requests!

void oofBroadcaster::broadcast OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0
[inherited]
 

Broadcast a message to all anonymous subscribers.

Parameters:
msg constant value indicating the action or event that has occurred.
senderDefined additional param for caller to pass through
skipping a receiver to be skipped when broadcasting, to avoid circular messages
Todo:
use void* for senderDefined so can cope with values >32bits eg oidT in HUGE databases or 64bit pointers.

void oofBroadcaster::BroadcastShutdown  )  [protected, inherited]
 

void dbTable::buildSchema  ) 
 

bool dbTable::canSaveRecord  )  [virtual]
 

void dbTable::changeShielded bool  setShielding = true  )  [inline]
 

bool dbTable::changeShielded  )  const [inline]
 

change shielding, so field changes don't mark the record as dirty.

(default is false) Used when we don't want operations to propagate, eg: if updating a field and need to finish some local op before related data updates.

void dbTable::clearSelection  ) 
 

void dbTable::cloneRecord  )  [virtual]
 

virtual dbTable* dbTable::cloneTable selSharingT  selSharing = selCopyOnWrite  )  [pure virtual]
 

virtual dbTable* dbTable::cloneTableConst selSharingT  selSharing  )  const [pure virtual]
 

pure virtual cloneTable is implemented by macro OOFILE_METHODS, in oofmacro.h, for each user subclass.

It is abstract to avoid bugs from people missing their OOFILE_METHODS in table declarations

dbTable * dbTable::cloneTableSharingSelection  )  const [virtual]
 

dbTable * dbTable::cloneTableWithoutSelection  )  const [virtual]
 

dbTable * dbTable::cloneTbleWithCachNoSelection  )  const [virtual]
 

void dbTable::close  ) 
 

void dbTable::commitTransaction short  rMode = 0  ) 
 

bool dbTable::contains oidT  inOID  )  [inline]
 

Check if current selection contains an OID.

Use with selectAll to see if OID is anywhere in database.

dbRelRefBase * dbTable::controllingRelationship  )  const [inline]
 

void dbTable::copyAllFrom dbTable  ) 
 

void dbTable::copyRecFrom const dbTable rhs,
fieldNumT  numFields = 0
 

unsigned long dbTable::count  )  [inline]
 

Count records in current selection.

Includes current record even if new (ie: it has not had a record pointer saved to disk).

unsigned long dbTable::countAll  )  const [inline]
 

Count records in database regardless of current selection.

void dbTable::createTableInConnection const dbConnect  ) 
 

oidT dbTable::currentOID  )  [inline]
 

Absolute record address of current record.

Persistent value can be used between application runs.

dbSelection dbTable::currentSelection  ) 
 

virtual const char* dbTable::defaultName  )  const [inline, virtual]
 

void dbTable::deleteAll  ) 
 

void dbTable::deleteRecord  )  [virtual]
 

void dbTable::deleteSelection  ) 
 

void dbTable::deleteStorage  ) 
 

void dbTable::describe std::ostream &  os  )  const [virtual]
 

Provide human-readable information about object.

Overriden to provide much more detail particularly for dbTable::describe() which provides full schema.

Reimplemented from OOF_PublicBase.

void dbTable::describeInvariant std::ostream &  os  )  const [inline]
 

void dbTable::describeState std::ostream &   )  const [virtual]
 

void dbTable::difference_with const dbSelection  ) 
 

void dbTable::difference_with dbTable  )  [inline]
 

void dbTable::difference_with dbTable  ) 
 

void dbTable::dropRecordFromSelection