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

dbConnect Class Reference
[OOFILE Database package]

#include <oof1.h>

Inheritance diagram for dbConnect:

Inheritance graph
[legend]
Collaboration diagram for dbConnect:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstract interface for database.

Subclassed to indicate type of database backend to use.


Public Member Functions

 dbConnect (bool isTemporary=false)
virtual ~dbConnect ()
 Destroys tables if any are left that we own, allowing for dynamic database creation.

virtual oofString name () const
virtual void newConnection (const char *connectionName)=0
virtual void openConnection (const char *connectionName)=0
virtual void newConnection (const FSSpec &)=0
virtual void openConnection (const FSSpec &)=0
virtual void close ()=0
virtual void deleteStorage ()
virtual bool usesSeparateStorageFiles () const
void gotoDatabaseDir () const
oofDirectorydatabaseDirectory () const
const oofStringconnectionName () const
void attachTable (dbTable *)
dbTabletable (unsigned int) const
dbTabletable (const char *)
unsigned int numTables () const
bool isOpen () const
bool inDeclarativePhase () const
 Connection has been declared but not opened or created.

virtual void exitLocking ()=0
virtual void enterWriteLocking ()=0
virtual void enterReadLocking ()=0
virtual void describe (std::ostream &) const
 Provide human-readable information about object.

virtual void writeOOFSchema ()
virtual void readOOFSchema (const oofString &schemaFileName)
 Reads & parses oofSchema from the file schemaFileName.

virtual void stats (std::ostream &)
void dumpData (std::ostream &)
void extract (std::ostream &os)
void copyAllFrom (dbConnect *)
void deleteAll ()
void generateTestData (unsigned long maxRecs=10000, bool generateRandom=true, unsigned long seedOrCount=0)
void schemaFileExt (const oofString &)
void suspendSorting () const
void resumeSorting () const
oofWordParsergetDefaultWordParser ()
void setDefaultWordParser (oofWordParser *inParser)
bool hidden () const
void hide (bool hideIt=true)

Static Public Member Functions

dbConnectcurrentlyConstructing ()
bool fileExists (const char *fName)
bool underConstruction ()
void raise (std::ostream &, bool terminateAfterMsg=true)
void raise (const char *, bool terminateAfterMsg=true)
void truncateTrailingSpaces (bool willTruncate=true)
bool willTruncateTrailingSpaces ()

Protected Types

enum  connectionFileStateT {
  eIdle = 0, eStart = 1, eOpenedFile = 2, eCreatedFile = 4,
  eInvalidlyOpenInCreation = 8, eInvalidlyCreationInOpen = 16
}

Protected Member Functions

void MakeAllTablesValid () const
 Final step in construction, can use tables against database after this.

void InitOpenOrCreateState ()
void OpenOrCreateStateTransition (bool inOpenedOrCreated)
 Manage state transitions for FinishOpenOrCreateConnection.

virtual void WriteOOFSchemaFile ()
 Write the oofschema out to the schema file.

virtual oofString MakeSchemaFileName ()
 produce a file name for schema file.

oofString MakeOOFSchemaString ()
 Produce a string containing the oofschema with the length of the schema string aphended to the end.


Protected Attributes

OOF_Dictionary mTables
oofString mConnectionName
oofString mSchemaFileName
bool mOpen
bool mTempDatabase
bool mInDeclarativePhase
oofWordParsermDefaultPrototypeParser
oofDirectorymDatabaseDir
connectionFileStateT mFileState
bool mHidden

Static Protected Attributes

dbConnectsCurrentlyConstructing
 this static gets zeroed in dbTable::postCloneTableCleanup() this is how we avoid passing dbTable pointers around all the time when creating fields particularly in user constructors when it would clutter things up a LOT!

bool sTruncateTrailingSpaces = false
oofString sSchemaFileExt = "osc"


Member Enumeration Documentation

enum dbConnect::connectionFileStateT [protected]
 

Enumeration values:
eIdle 
eStart 
eOpenedFile 
eCreatedFile 
eInvalidlyOpenInCreation 
eInvalidlyCreationInOpen 


Constructor & Destructor Documentation

dbConnect::dbConnect bool  isTemporary = false  ) 
 

dbConnect::~dbConnect  )  [virtual]
 

Destroys tables if any are left that we own, allowing for dynamic database creation.

Note:
assume we own our tables (if they are deleted before us they call close() if you have dbTables as concrete members of a subclass of dbConnect they will have been deleted before reaching this base dtor, so this is safe


Member Function Documentation

void dbConnect::attachTable dbTable  ) 
 

virtual void dbConnect::close  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, dbConnect_ram, and dbConnect_ramp.

const oofString & dbConnect::connectionName  )  const [inline]
 

void dbConnect::copyAllFrom dbConnect  ) 
 

dbConnect * dbConnect::currentlyConstructing  )  [inline, static]
 

oofDirectory * dbConnect::databaseDirectory  )  const [inline]
 

void dbConnect::deleteAll  ) 
 

void dbConnect::deleteStorage  )  [virtual]
 

Reimplemented in dbConnect_ctree, dbConnect_FServ, and dbConnect_ramp.

void dbConnect::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 dbConnect::dumpData std::ostream &   ) 
 

virtual void dbConnect::enterReadLocking  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, and dbConnect_ram.

virtual void dbConnect::enterWriteLocking  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, and dbConnect_ram.

virtual void dbConnect::exitLocking  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, and dbConnect_ram.

void dbConnect::extract std::ostream &  os  )  [inline]
 

bool dbConnect::fileExists const char *  fName  )  [static]
 

void dbConnect::generateTestData unsigned long  maxRecs = 10000,
bool  generateRandom = true,
unsigned long  seedOrCount = 0
 

oofWordParser * dbConnect::getDefaultWordParser  ) 
 

void dbConnect::gotoDatabaseDir  )  const
 

bool OOF_PublicBase::hidden  )  const [inline, inherited]
 

void OOF_PublicBase::hide bool  hideIt = true  )  [inline, inherited]
 

bool dbConnect::inDeclarativePhase  )  const [inline]
 

Connection has been declared but not opened or created.

Only one connection at a time can be in this state.

Todo:
cope if declare 2nd connections before opening either, which is legal.

void dbConnect::InitOpenOrCreateState  )  [protected]
 

bool dbConnect::isOpen  )  const [inline]
 

void dbConnect::MakeAllTablesValid  )  const [protected]
 

Final step in construction, can use tables against database after this.

Note:
resets dbTable::sCurrentlyConstructing to detect fields declared outside tables

oofString dbConnect::MakeOOFSchemaString  )  [protected]
 

Produce a string containing the oofschema with the length of the schema string aphended to the end.

The length is used as an offset in dbConnect_rampBackend to find the schema beginning

oofString dbConnect::MakeSchemaFileName  )  [protected, virtual]
 

produce a file name for schema file.

If a file name exists for the data base use it with the extension sSchemaFileExt (default "osc") else use the connection name with sSchemaFileExt appended.

Todo:
rewrite

oofString dbConnect::name  )  const [virtual]
 

Reimplemented from OOF_PublicBase.

virtual void dbConnect::newConnection const FSSpec &   )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, dbConnect_ram, and dbConnect_ramp.

virtual void dbConnect::newConnection const char *  connectionName  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, dbConnect_ram, and dbConnect_ramp.

unsigned int dbConnect::numTables  )  const [inline]
 

virtual void dbConnect::openConnection const FSSpec &   )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, dbConnect_ram, and dbConnect_ramp.

virtual void dbConnect::openConnection const char *  connectionName  )  [pure virtual]
 

Implemented in dbConnect_ctree, dbConnect_dbase, dbConnect_FServ, dbConnect_ram, and dbConnect_ramp.

void dbConnect::OpenOrCreateStateTransition bool  inOpenedVSCreated  )  [protected]
 

Manage state transitions for FinishOpenOrCreateConnection.

Parameters:
inOpenedVSCreated is true if just created file, false if opened

void dbConnect::raise const char *  ,
bool  terminateAfterMsg = true
[static]
 

void dbConnect::raise std::ostream &  ,
bool  terminateAfterMsg = true
[static]
 

void dbConnect::readOOFSchema const oofString schemaFileName  )  [virtual]
 

Reads & parses oofSchema from the file schemaFileName.

Populates the dbConnect::sCurrentlyConstructing connection with extra tables.

Todo:
make a version that takes oofFileRef

void dbConnect::resumeSorting  )  const
 

void dbConnect::schemaFileExt const oofString  ) 
 

void dbConnect::setDefaultWordParser oofWordParser inParser  ) 
 

void dbConnect::stats std::ostream &   )  [virtual]
 

void dbConnect::suspendSorting  )  const
 

dbTable * dbConnect::table const char *   ) 
 

dbTable * dbConnect::table unsigned  int  )  const
 

void dbConnect::truncateTrailingSpaces bool  willTruncate = true  )  [inline, static]
 

bool dbConnect::underConstruction  )  [inline, static]
 

bool dbConnect::usesSeparateStorageFiles  )  const [virtual]
 

Reimplemented in dbConnect_ctree, dbConnect_dbase, and dbConnect_FServ.

bool dbConnect::willTruncateTrailingSpaces  )  [inline, static]
 

void dbConnect::writeOOFSchema  )  [virtual]
 

Reimplemented in dbConnect_ctree, dbConnect_ram, and dbConnect_ramp.

void dbConnect::WriteOOFSchemaFile  )  [protected, virtual]
 

Write the oofschema out to the schema file.

Note:
temporarily changes current directory whilst writing file.


Member Data Documentation

oofString dbConnect::mConnectionName [protected]
 

oofDirectory* dbConnect::mDatabaseDir [protected]
 

oofWordParser* dbConnect::mDefaultPrototypeParser [protected]
 

connectionFileStateT dbConnect::mFileState [protected]
 

bool OOF_PublicBase::mHidden [protected, inherited]
 

bool dbConnect::mInDeclarativePhase [protected]
 

bool dbConnect::mOpen [protected]
 

oofString dbConnect::mSchemaFileName [protected]
 

OOF_Dictionary dbConnect::mTables [protected]
 

bool dbConnect::mTempDatabase [protected]
 

dbConnect * dbConnect::sCurrentlyConstructing [static, protected]
 

this static gets zeroed in dbTable::postCloneTableCleanup() this is how we avoid passing dbTable pointers around all the time when creating fields particularly in user constructors when it would clutter things up a LOT!

Warning:
this is NOT thread-safe - do not construct tables in simultaneous threads

oofString dbConnect::sSchemaFileExt = "osc" [static, protected]
 

bool dbConnect::sTruncateTrailingSpaces = false [static, protected]
 


The documentation for this class was generated from the following files:
Generated on Fri Jan 2 00:50:07 2004 for OOFILE by doxygen 1.3.5