OOFILE  1.9
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members

Database connection to a RAM database that can be persisted out to a single file. More...

#include <ooframp.h>

Inheritance diagram for dbConnect_ramp:
Inheritance graph
[legend]
Collaboration diagram for dbConnect_ramp:
Collaboration graph
[legend]

Public Member Functions

void attachTable (dbTable *)
 
virtual void close ()
 
const oofStringconnectionName () const
 
void copyAllFrom (dbConnect *)
 
oofDirectorydatabaseDirectory () const
 
 dbConnect_ramp (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 ()
 
virtual void enterWriteLocking ()
 
virtual void exitLocking ()
 
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)
 
virtual void newConnection (const FSSpec &)
 
unsigned int numTables () const
 
virtual void openConnection (const char *connectionName)
 
virtual void openConnection (const FSSpec &)
 
virtual bool openOrCreateConnection (const char *connectionName)
 
virtual void readOOFSchema (const oofString &schemaFileName)
 Reads & parses oofSchema from the file schemaFileName. More...
 
void resumeSorting () const
 
void revert ()
 
void save ()
 
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_ramp ()
 

Static Public Member Functions

static dbConnectcurrentlyConstructing ()
 
static bool fileExists (const char *fName)
 
static OOF_tableBackendjustMakeTableBackend (dbTable *)
 
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
 
oofDirectorymDatabaseDir
 
oofWordParsermDefaultPrototypeParser
 
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
 

Friends

class OOF_rampBackend
 

Detailed Description

Database connection to a RAM database that can be persisted out to a single file.

See also
OOF_rampBackend
Warning
files can't be shared cross-platform as they are endian-specific

Definition at line 26 of file ooframp.h.

Constructor & Destructor Documentation

dbConnect_ramp::dbConnect_ramp ( bool  isTemporary = false)

Definition at line 36 of file ooframp.cpp.

dbConnect_ramp::~dbConnect_ramp ( )
virtual

Definition at line 42 of file ooframp.cpp.

References close(), deleteStorage(), dbConnect::mOpen, and dbConnect::mTempDatabase.

Member Function Documentation

void dbConnect::attachTable ( dbTable theTable)
inherited
void dbConnect_ramp::close ( )
virtual

Reimplemented from dbConnect_ram.

Definition at line 341 of file ooframp.cpp.

References dbConnect::mOpen, and save().

Referenced by ~dbConnect_ramp().

const oofString & dbConnect::connectionName ( ) const
inlineinherited
void dbConnect::copyAllFrom ( dbConnect rhs)
inherited
dbConnect * dbConnect::currentlyConstructing ( )
inlinestaticinherited
oofDirectory * dbConnect::databaseDirectory ( ) const
inlineinherited

Definition at line 1683 of file oof1.h.

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

void dbConnect::deleteAll ( )
inherited
void dbConnect_ramp::deleteStorage ( )
virtual

Reimplemented from dbConnect.

Definition at line 364 of file ooframp.cpp.

References oofFileRef::deleteFile(), dbConnect::mConnectionName, and dbConnect::mDatabaseDir.

Referenced by ~dbConnect_ramp().

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

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(), dbConnect::mConnectionName, and dbConnect::mTables.

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

void dbConnect::dumpData ( std::ostream &  )
inherited
virtual void dbConnect_ram::enterReadLocking ( )
inlinevirtualinherited

Implements dbConnect.

Definition at line 48 of file oofram.h.

virtual void dbConnect_ram::enterWriteLocking ( )
inlinevirtualinherited

Implements dbConnect.

Definition at line 47 of file oofram.h.

virtual void dbConnect_ram::exitLocking ( )
inlinevirtualinherited

Implements dbConnect.

Definition at line 46 of file oofram.h.

void dbConnect::extract ( std::ostream &  os)
inlineinherited

Definition at line 967 of file oof1.h.

Referenced by OOF_XMLrepParser::~OOF_XMLrepParser().

bool dbConnect::fileExists ( const char *  fName)
staticinherited

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 
)
inherited
oofWordParser * dbConnect::getDefaultWordParser ( )
inherited

Definition at line 754 of file oof1.cpp.

References dbConnect::mDefaultPrototypeParser.

Referenced by dbTable::getDefaultWordParser().

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

Definition at line 51 of file oof1.h.

Referenced by OOF_Dictionary::EntryMatchesVisibility().

void OOF_PublicBase::hide ( bool  hideIt = true)
inlineinherited

Definition at line 52 of file oof1.h.

bool dbConnect::inDeclarativePhase ( ) const
inlineinherited

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.

Definition at line 1702 of file oof1.h.

void dbConnect::InitOpenOrCreateState ( )
protectedinherited

Definition at line 748 of file oof1.cpp.

References dbConnect::eStart, and dbConnect::mFileState.

Referenced by dbConnect_ctree::FinishOpenOrCreateConnection().

bool dbConnect::isOpen ( ) const
inlineinherited

Definition at line 1690 of file oof1.h.

OOF_tableBackend * dbConnect_ram::justMakeTableBackend ( dbTable forTable)
staticinherited

Definition at line 168 of file oofram.cpp.

Referenced by dbConnect_ram::MakeTableBackend().

void dbConnect::MakeAllTablesValid ( ) const
protectedinherited

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

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

Definition at line 419 of file oof1.cpp.

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

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

oofString dbConnect::MakeOOFSchemaString ( )
protectedinherited

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(), dbConnect::describe(), and oofString::length().

oofString dbConnect::MakeSchemaFileName ( )
protectedvirtualinherited

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

Definition at line 463 of file oof1.cpp.

Referenced by dbConnect::WriteOOFSchemaFile().

oofString dbConnect::name ( ) const
virtualinherited

Reimplemented from OOF_PublicBase.

Definition at line 409 of file oof1.cpp.

References dbConnect::connectionName().

void dbConnect_ramp::newConnection ( const char *  connectionName)
virtual

Reimplemented from dbConnect_ram.

Definition at line 72 of file ooframp.cpp.

References dbConnect::mDatabaseDir, dbConnect::mOpen, and RAISE_EXCEPTION.

void dbConnect_ramp::newConnection ( const FSSpec &  inMacFSSpec)
virtual

Reimplemented from dbConnect_ram.

Definition at line 145 of file ooframp.cpp.

References dbConnect::mDatabaseDir, dbConnect::mOpen, and RAISE_EXCEPTION.

unsigned int dbConnect::numTables ( ) const
inlineinherited
void dbConnect_ramp::openConnection ( const char *  connectionName)
virtual

Reimplemented from dbConnect_ram.

Definition at line 97 of file ooframp.cpp.

References dbConnect::mDatabaseDir, dbConnect::mOpen, and RAISE_EXCEPTION.

void dbConnect_ramp::openConnection ( const FSSpec &  inMacFSSpec)
virtual

Reimplemented from dbConnect_ram.

Definition at line 160 of file ooframp.cpp.

References dbConnect::mDatabaseDir, dbConnect::mOpen, and RAISE_EXCEPTION.

bool dbConnect_ramp::openOrCreateConnection ( const char *  connectionName)
virtual

Reimplemented from dbConnect_ram.

Definition at line 121 of file ooframp.cpp.

References dbConnect::mDatabaseDir, dbConnect::mOpen, and RAISE_EXCEPTION.

void dbConnect::OpenOrCreateStateTransition ( bool  inOpenedVSCreated)
protectedinherited

Manage state transitions for FinishOpenOrCreateConnection.

Parameters
inOpenedVSCreatedis true if just created file, false if opened

Definition at line 727 of file oof1.cpp.

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

Referenced by dbConnect_ctree::FinishOpenOrCreateConnection().

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

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 
)
staticinherited

Definition at line 698 of file oof1.cpp.

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

void dbConnect::readOOFSchema ( const oofString schemaFileName)
virtualinherited

Reads & parses oofSchema from the file schemaFileName.

Populates the dbConnect::sCurrentlyConstructing connection with extra tables.

Todo:
make a version that takes oofFileRef

Definition at line 548 of file oof1.cpp.

References dbConnect::sCurrentlyConstructing.

void dbConnect::resumeSorting ( ) const
inherited
void dbConnect_ramp::revert ( )
void dbConnect_ramp::save ( )
void dbConnect::schemaFileExt ( const oofString newExt)
inherited

Definition at line 717 of file oof1.cpp.

References dbConnect::sSchemaFileExt.

void dbConnect::setDefaultWordParser ( oofWordParser inParser)
inherited

Definition at line 764 of file oof1.cpp.

References dbConnect::mDefaultPrototypeParser.

void dbConnect::stats ( std::ostream &  )
virtualinherited
void dbConnect::suspendSorting ( ) const
inherited
dbTable * dbConnect::table ( unsigned int  tableNum) const
inherited
dbTable * dbConnect::table ( const char *  tableName)
inherited

Definition at line 443 of file oof1.cpp.

References dbConnect::mTables.

void dbConnect::truncateTrailingSpaces ( bool  willTruncate = true)
inlinestaticinherited

Definition at line 1660 of file oof1.h.

bool dbConnect::underConstruction ( )
inlinestaticinherited

Definition at line 1653 of file oof1.h.

bool dbConnect::usesSeparateStorageFiles ( ) const
virtualinherited

Reimplemented in dbConnect_FServ, dbConnect_ctree, and dbConnect_dbase.

Definition at line 450 of file oof1.cpp.

Referenced by dbConnect::deleteStorage().

bool dbConnect::willTruncateTrailingSpaces ( )
inlinestaticinherited

Definition at line 1667 of file oof1.h.

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

void dbConnect_ramp::writeOOFSchema ( )
virtual

Reimplemented from dbConnect_ram.

Definition at line 307 of file ooframp.cpp.

Referenced by save().

void dbConnect::WriteOOFSchemaFile ( )
protectedvirtualinherited

Write the oofschema out to the schema file.

Note
temporarily changes current directory whilst writing file.

Definition at line 502 of file oof1.cpp.

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

Referenced by dbConnect::writeOOFSchema().

Friends And Related Function Documentation

friend class OOF_rampBackend
friend

Definition at line 60 of file ooframp.h.

Member Data Documentation

oofString dbConnect::mConnectionName
protectedinherited
oofDirectory* dbConnect::mDatabaseDir
protectedinherited
oofWordParser* dbConnect::mDefaultPrototypeParser
protectedinherited
connectionFileStateT dbConnect::mFileState
protectedinherited
bool OOF_PublicBase::mHidden
protectedinherited

Definition at line 61 of file oof1.h.

bool dbConnect::mInDeclarativePhase
protectedinherited

Definition at line 1023 of file oof1.h.

bool dbConnect::mOpen
protectedinherited
oofString dbConnect::mSchemaFileName
protectedinherited

Definition at line 1022 of file oof1.h.

Referenced by dbConnect_ctree::newConnection().

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

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

Definition at line 1026 of file oof1.h.

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

oofString dbConnect::sSchemaFileExt ="osc"
staticprotectedinherited

Definition at line 1029 of file oof1.h.

Referenced by dbConnect::schemaFileExt().

bool dbConnect::sTruncateTrailingSpaces = false
staticprotectedinherited

Definition at line 1027 of file oof1.h.


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