Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
dbConnect Class Referenceabstract

Abstract interface for database. More...

#include <oof1.h>

Inheritance diagram for dbConnect:
Inheritance graph
Collaboration diagram for dbConnect:
Collaboration graph

Public Member Functions

void attachTable (dbTable *)
virtual void close ()=0
const oofStringconnectionName () const
void copyAllFrom (dbConnect *)
oofDirectorydatabaseDirectory () const
 dbConnect (bool isTemporary=false)
void deleteAll ()
virtual void deleteStorage ()
virtual void describe (std::ostream &) const
 Provide human-readable information about object. More...
void dumpData (std::ostream &)
virtual void enterReadLocking ()=0
virtual void enterWriteLocking ()=0
virtual void exitLocking ()=0
void extract (std::ostream &os)
void generateTestData (unsigned long maxRecs=10000, bool generateRandom=true, unsigned long seedOrCount=0)
oofWordParsergetDefaultWordParser ()
void gotoDatabaseDir () const
bool hidden () const
void hide (bool hideIt=true)
bool inDeclarativePhase () const
 Connection has been declared but not opened or created. More...
bool isOpen () const
virtual oofString name () const
virtual void newConnection (const char *connectionName)=0
virtual void newConnection (const FSSpec &)=0
unsigned int numTables () const
virtual void openConnection (const char *connectionName)=0
virtual void openConnection (const FSSpec &)=0
virtual void readOOFSchema (const oofString &schemaFileName)
 Reads & parses oofSchema from the file schemaFileName. More...
void resumeSorting () const
void schemaFileExt (const oofString &)
void setDefaultWordParser (oofWordParser *inParser)
virtual void stats (std::ostream &)
void suspendSorting () const
dbTabletable (unsigned int) const
dbTabletable (const char *)
virtual bool usesSeparateStorageFiles () const
virtual void writeOOFSchema ()
virtual ~dbConnect ()
 Destroys tables if any are left that we own, allowing for dynamic database creation. More...

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

void InitOpenOrCreateState ()
void MakeAllTablesValid () const
 Final step in construction, can use tables against database after this. More...
oofString MakeOOFSchemaString ()
 Produce a string containing the oofschema with the length of the schema string aphended to the end. More...
virtual oofString MakeSchemaFileName ()
 produce a file name for schema file. More...
void OpenOrCreateStateTransition (bool inOpenedOrCreated)
 Manage state transitions for FinishOpenOrCreateConnection. More...
virtual void WriteOOFSchemaFile ()
 Write the oofschema out to the schema file. More...

Protected Attributes

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

Static Protected Attributes

static 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! More...
static oofString sSchemaFileExt ="osc"
static bool sTruncateTrailingSpaces = false

Detailed Description

Abstract interface for database.

Subclassed to indicate type of database backend to use.

Definition at line 920 of file oof1.h.

Constructor & Destructor Documentation

dbConnect::dbConnect ( bool  isTemporary = false)

Definition at line 358 of file oof1.cpp.

References sCurrentlyConstructing.

dbConnect::~dbConnect ( )

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

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

Definition at line 379 of file oof1.cpp.

References OOF_Dictionary::count(), OOF_mixRefCount::decRefs(), mDatabaseDir, mDefaultPrototypeParser, mOpen, mTables, OOF_Dictionary::next(), numTables(), OOF_Dictionary::start(), and OOF_Dictionary::value().

Member Function Documentation

void dbConnect::attachTable ( dbTable theTable)
virtual void dbConnect::close ( )
pure virtual
const oofString & dbConnect::connectionName ( ) const
void dbConnect::copyAllFrom ( dbConnect rhs)

Definition at line 632 of file oof1.cpp.

References dbTable::copyAllFrom(), OOF_Dictionary::count(), mTables, and numTables().

dbConnect * dbConnect::currentlyConstructing ( )
oofDirectory * dbConnect::databaseDirectory ( ) const

Definition at line 1683 of file oof1.h.

Referenced by OOF_dbaseBackend::deleteStorage(), and OOF_ctreeBackend::deleteStorage().

void dbConnect::deleteAll ( )

Definition at line 604 of file oof1.cpp.

References OOF_Dictionary::count(), dbTable::deleteAll(), mTables, and numTables().

void dbConnect::deleteStorage ( )
void dbConnect::describe ( std::ostream &  ) const

Provide human-readable information about object.

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

Reimplemented from OOF_PublicBase.

Definition at line 562 of file oof1.cpp.

References OOF_Dictionary::describe(), mConnectionName, and mTables.

Referenced by MakeOOFSchemaString(), WriteOOFSchemaFile(), and OOF_XMLrepParser::~OOF_XMLrepParser().

void dbConnect::dumpData ( std::ostream &  )
virtual void dbConnect::enterReadLocking ( )
pure virtual
virtual void dbConnect::enterWriteLocking ( )
pure virtual
virtual void dbConnect::exitLocking ( )
pure virtual
void dbConnect::extract ( std::ostream &  os)

Definition at line 967 of file oof1.h.

Referenced by OOF_XMLrepParser::~OOF_XMLrepParser().

bool dbConnect::fileExists ( const char *  fName)

Definition at line 683 of file oof1.cpp.

References oofDirectory::fileExists().

void dbConnect::generateTestData ( unsigned long  maxRecs = 10000,
bool  generateRandom = true,
unsigned long  seedOrCount = 0 
oofWordParser * dbConnect::getDefaultWordParser ( )

Definition at line 754 of file oof1.cpp.

References mDefaultPrototypeParser.

Referenced by dbTable::getDefaultWordParser().

void dbConnect::gotoDatabaseDir ( ) const
bool OOF_PublicBase::hidden ( ) const

Definition at line 51 of file oof1.h.

Referenced by OOF_Dictionary::EntryMatchesVisibility().

void OOF_PublicBase::hide ( bool  hideIt = true)

Definition at line 52 of file oof1.h.

bool dbConnect::inDeclarativePhase ( ) const

Connection has been declared but not opened or created.

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

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

Definition at line 1702 of file oof1.h.

void dbConnect::InitOpenOrCreateState ( )

Definition at line 748 of file oof1.cpp.

References eStart, and mFileState.

Referenced by dbConnect_ctree::FinishOpenOrCreateConnection().

bool dbConnect::isOpen ( ) const

Definition at line 1690 of file oof1.h.

void dbConnect::MakeAllTablesValid ( ) const

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

resets dbTable::sCurrentlyConstructing to detect fields declared outside tables

Definition at line 419 of file oof1.cpp.

References OOF_Dictionary::count(), mTables, numTables(), dbTable::setTableValid(), and OOF_Dictionary::value().

Referenced by dbConnect_ram::newConnection(), dbConnect_ram::openConnection(), and dbConnect_ram::openOrCreateConnection().

oofString dbConnect::MakeOOFSchemaString ( )

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

Definition at line 521 of file oof1.cpp.

References oofString::convertNumber(), describe(), and oofString::length().

oofString dbConnect::MakeSchemaFileName ( )

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.


Definition at line 463 of file oof1.cpp.

Referenced by WriteOOFSchemaFile().

oofString dbConnect::name ( ) const

Reimplemented from OOF_PublicBase.

Definition at line 409 of file oof1.cpp.

References connectionName().

virtual void dbConnect::newConnection ( const char *  connectionName)
pure virtual
virtual void dbConnect::newConnection ( const FSSpec &  )
pure virtual
unsigned int dbConnect::numTables ( ) const
virtual void dbConnect::openConnection ( const char *  connectionName)
pure virtual
virtual void dbConnect::openConnection ( const FSSpec &  )
pure virtual
void dbConnect::OpenOrCreateStateTransition ( bool  inOpenedVSCreated)

Manage state transitions for FinishOpenOrCreateConnection.

inOpenedVSCreatedis true if just created file, false if opened

Definition at line 727 of file oof1.cpp.

References eCreatedFile, eInvalidlyCreationInOpen, eInvalidlyOpenInCreation, eOpenedFile, eStart, and mFileState.

Referenced by dbConnect_ctree::FinishOpenOrCreateConnection().

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

Referenced by dbBrowseHelper::browseViewWithListBox(), dbBrowseHelper::browseViewWithTable(), OOF_ramBackend::BuildBackendtables(), OOF_dbaseBackend::BuildBackendtables(), OOF_ctreeBackend::BuildBackendtables(), dbRelRefBase::BuildRelatedTable(), oofRepMacGUIPreviewPP::calcPageHeight(), dbTable::copyAllFrom(), dbChar::copyValueFrom(), dbShort::copyValueFrom(), dbUshort::copyValueFrom(), dbBool::copyValueFrom(), dbLong::copyValueFrom(), dbUlong::copyValueFrom(), dbText::copyValueFrom(), dbReal::copyValueFrom(), dbDate::copyValueFrom(), dbTime::copyValueFrom(), dbDateTime::copyValueFrom(), dbShort::copyValueIfDifferent(), dbChar::copyValueIfDifferent(), dbUshort::copyValueIfDifferent(), dbBool::copyValueIfDifferent(), dbLong::copyValueIfDifferent(), dbUlong::copyValueIfDifferent(), dbText::copyValueIfDifferent(), dbReal::copyValueIfDifferent(), dbDate::copyValueIfDifferent(), dbTime::copyValueIfDifferent(), dbDateTime::copyValueIfDifferent(), OOF_ctreeBackend::countAll(), OOF_dbaseBackend::createTableInConnection(), dbDate::currentCentury(), dbDate::currentDate2ymd(), dbTime::currentTime2hms(), dbDateTime::currentTime2ymdhms(), dbDateTime::daysInMonth(), dbField::dbField(), dbTable::dbTable(), OOF_ramBackend::deleteRecord(), OOF_dbaseBackend::deleteRecord(), OOF_ctreeBackend::deleteRecord(), oofRepWindow::DoOpen(), dbConnect_ctree::enterReadLocking(), dbConnect_ctree::enterWriteLocking(), dbField::equivalentFieldFromTable(), OOF_ULSorter::exchange(), OOF_ULPSorter::exchange(), dbConnect_ctree::exitLocking(), dbQueryField::getSearchTables(), OOF_ramBackend::gotoRecord(), OOF_dbaseBackend::gotoRecord(), OOF_ctreeBackend::gotoRecord(), OOF_mixKeywordableField::indexWords(), dbChar::insert(), dbText::insert(), dbTable::insert(), dbRelationship::linkMNvia(), OOF_dbaseBackend::loadBlob(), dbConnect_dbase::newConnection(), OOF_ctreeBackend::newRecord(), dbConnect_dbase::openConnection(), dbConnect_dbase::openOrCreateConnection(), OOF_dbaseBackend::openTableInConnection(), dbChar::operator+=(), OOF_XMLrepParser::parseFile(), dbRelRefBase::propagateRelatedDeletes(), dbBrowseHelper::receiveMsg(), dbRelRefBase::relatesTo(), oofBroadcaster::removeReceiver(), OOF_simpleRecordBackend::revertRecord(), OOF_simpleRecordBackend::search(), OOF_simpleRecordBackend::SearchBetweenNonIndexed(), OOF_simpleRecordBackend::SearchBinaryFieldToLiteral(), OOF_simpleRecordBackend::SearchComparativeNonIndexed(), OOF_simpleRecordBackend::SearchEqualNonIndexed(), OOF_simpleRecordBackend::SearchNotEqualNonIndexed(), OOF_simpleRecordBackend::SearchOutsideNonIndexed(), OOF_simpleRecordBackend::SearchSelectionBinaryFieldToLiteral(), OOF_simpleRecordBackend::selectJustOID(), dbChar::setChars(), dbRelRefBase::SetCommonRelationshipFields(), OOF_simpleRecordBackend::sortSelectionInverseNow(), OOF_simpleRecordBackend::sortSelectionNow(), OOF_simpleRecordBackend::SubSort(), oofSingleListener::suspendListening(), dbDateTime::ulong2ymdhms(), dbField::valueAsQueryLiteral(), dbAbstractEditHelper::warnUser(), and OOF_recordCache::~OOF_recordCache().

void dbConnect::raise ( const char *  str,
bool  terminateAfterMsg = true 

Definition at line 698 of file oof1.cpp.

References oofErrorReporter::defaultReporter(), and oofErrorReporter::raise().

void dbConnect::readOOFSchema ( const oofString schemaFileName)

Reads & parses oofSchema from the file schemaFileName.

Populates the dbConnect::sCurrentlyConstructing connection with extra tables.

make a version that takes oofFileRef

Definition at line 548 of file oof1.cpp.

References sCurrentlyConstructing.

void dbConnect::resumeSorting ( ) const
void dbConnect::schemaFileExt ( const oofString newExt)

Definition at line 717 of file oof1.cpp.

References sSchemaFileExt.

void dbConnect::setDefaultWordParser ( oofWordParser inParser)

Definition at line 764 of file oof1.cpp.

References mDefaultPrototypeParser.

void dbConnect::stats ( std::ostream &  )

Definition at line 570 of file oof1.cpp.

References OOF_Dictionary::count(), mTables, dbTable::stats(), and OOF_Dictionary::value().

void dbConnect::suspendSorting ( ) const
dbTable * dbConnect::table ( unsigned int  tableNum) const
dbTable * dbConnect::table ( const char *  tableName)

Definition at line 443 of file oof1.cpp.

References mTables.

void dbConnect::truncateTrailingSpaces ( bool  willTruncate = true)

Definition at line 1660 of file oof1.h.

bool dbConnect::underConstruction ( )

Definition at line 1653 of file oof1.h.

bool dbConnect::usesSeparateStorageFiles ( ) const

Reimplemented in dbConnect_FServ, dbConnect_ctree, and dbConnect_dbase.

Definition at line 450 of file oof1.cpp.

Referenced by deleteStorage().

bool dbConnect::willTruncateTrailingSpaces ( )

Definition at line 1667 of file oof1.h.

Referenced by dbChar::insert(), and dbText::insert().

void dbConnect::writeOOFSchema ( )

Reimplemented in dbConnect_ctree, dbConnect_ramp, and dbConnect_ram.

Definition at line 535 of file oof1.cpp.

References WriteOOFSchemaFile().

void dbConnect::WriteOOFSchemaFile ( )

Write the oofschema out to the schema file.

temporarily changes current directory whilst writing file.

Definition at line 502 of file oof1.cpp.

References describe(), gotoDatabaseDir(), and MakeSchemaFileName().

Referenced by writeOOFSchema().

Member Data Documentation

oofString dbConnect::mConnectionName
oofDirectory* dbConnect::mDatabaseDir
oofWordParser* dbConnect::mDefaultPrototypeParser

Definition at line 1024 of file oof1.h.

Referenced by getDefaultWordParser(), setDefaultWordParser(), and ~dbConnect().

connectionFileStateT dbConnect::mFileState
bool OOF_PublicBase::mHidden

Definition at line 61 of file oof1.h.

bool dbConnect::mInDeclarativePhase

Definition at line 1023 of file oof1.h.

bool dbConnect::mOpen
oofString dbConnect::mSchemaFileName

Definition at line 1022 of file oof1.h.

Referenced by dbConnect_ctree::newConnection().

OOF_Dictionary dbConnect::mTables
bool dbConnect::mTempDatabase
dbConnect * dbConnect::sCurrentlyConstructing

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!

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

Definition at line 1026 of file oof1.h.

Referenced by dbConnect(), readOOFSchema(), and dbConnect_ram::SetupConnection().

oofString dbConnect::sSchemaFileExt ="osc"

Definition at line 1029 of file oof1.h.

Referenced by schemaFileExt().

bool dbConnect::sTruncateTrailingSpaces = false

Definition at line 1027 of file oof1.h.

The documentation for this class was generated from the following files: