OOFILE  1.9
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dbRelRefBase Class Reference

Parent for any field that is a relationship to another table. More...

#include <oofrel.h>

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

Public Types

enum  { kKeyLengthAutoCalculated = USHRT_MAX }
 
enum  FieldIsStandaloneT { eFieldIsStandalone }
 

Public Member Functions

virtual const char * asChars () const
 
bool caseSensitive () const
 
virtual void clear ()
 
virtual dbFieldclone () const
 
void completeCloneOfInverse (dbRelRefBase *cloner)
 
void completeCloneOfInverse (dbTable *clonerTable)
 
virtual oofString copyString () const
 
virtual void copyValueFrom (const dbField *)
 
virtual void copyValueIfDifferent (const dbField *)
 
 dbRelRefBase (const char *fieldName=0, unsigned long maxLinks=0)
 
 dbRelRefBase (const dbRelRefBase &rhs)
 
dbFieldequivalentFieldFromTable (dbTable *) const
 
unsigned long fieldDataLen () const
 
bool fieldIndexIgnoresNulls () const
 
bool fieldIndexIsCompressLeading () const
 
bool fieldIndexIsCompressPadding () const
 
OOF_IndexOptions fieldIndexOptions () const
 
virtual bool fieldIsBinary () const
 
virtual bool fieldIsBlob () const
 
virtual bool fieldIsIndexed () const
 
bool fieldIsJoinKey () const
 Checks if any relationships in field's table use field as join key. More...
 
virtual bool fieldIsKeywordIndexed () const
 
bool fieldIsPartiallyIndexed () const
 
bool fieldIsStandalone () const
 
virtual bool fieldIsUniqueIndexed () const
 
unsigned short fieldKeyLen () const
 
virtual unsigned long fieldMinWrapWidth () const
 
fieldNumT fieldNumber () const
 
unsigned short fieldNumIndexes () const
 
dbTablefieldTable () const
 
virtual unsigned long fieldUsualWrapWidth () const
 
virtual void generateTestData (bool, unsigned long)
 
virtual void getChars (char *ioBuff, unsigned long &outLen) const
 
OOF_RelMNgetMNlink () const
 
bool hasDefaultCalculator () const
 
bool hidden () const
 
void hide (bool hideIt=true)
 
void index (const OOF_IndexOptions=kIndexed)
 
void indexPartialKeyLen (unsigned short)
 
virtual bool insert (std::istream &, char fieldSep, char recSep)
 
bool isDirty () const
 
virtual bool isEmpty () const
 
void joinField (dbField &)
 
dbFieldjoinField () const
 
virtual oofString name () const
 
virtual void postCloneTableCleanup ()
 
void propagateRelatedDeletes (bool prop=true)
 Set relationship to propagate deletes, ie: owns related records. More...
 
bool propagatesDeletes () const
 
virtual bool receiveMsg (OOFmsgT msg, unsigned long senderDefined)
 The default receiveMsg behaviour is to delete yourself when the broadcaster closes. More...
 
void relatesTo (dbRelRefBase &)
 Called by dbRelationship to tie two instances of dbRelRefBase together. More...
 
void resumeListening ()
 
void saveDefaultCalculatedValue ()
 
void saveStoredCalculatedValue ()
 
void setMNlink (OOF_RelMN *)
 Point this relationship at the object which maintains the link. More...
 
void setName (const char *name)
 
virtual void setNumber (long)
 
virtual void setString (const char *)
 
void storeCalculatedValues ()
 
bool storesCalculatedValues () const
 
virtual void subscribeTo (oofBroadcaster *)
 
void suspendListening ()
 
const char * tableName () const
 
virtual void unsubscribe (oofBroadcaster *from=0)
 
void useCalculatorOnlyForDefaults ()
 
bool usingCalculator () const
 
virtual bool validateContents ()
 
virtual dbQueryClausevalueAsQueryLiteral () const
 
bool valueIsDuplicate () const
 
virtual oofWordParserwords () const
 
virtual ~dbRelRefBase ()
 
mandatory dbField overrides
virtual OOF_fieldTypes fieldType () const
 
virtual unsigned long fieldStorageLen () const
 
reflective operations
virtual bool fieldIsSameTypeAs (const dbField *) const
 
virtual const OOF_StringfieldName () const
 Override to return related table name as sensible default. More...
 
virtual void describe (std::ostream &) const
 Provide human-readable information about object. More...
 
virtual void extract (std::ostream &) const
 
virtual OOF_fieldTypes nativeType () const
 
virtual bool fieldIsVirtual () const
 
dbRelRefBaseinverse () const
 
dbTablerelatedTable ()
 
tableNumT relatedTableNumber () const
 
bool isRef () const
 Is "ref" to just one instance. More...
 
virtual bool pointsToCorrectTableType () const
 Default base method. More...
 
simple user-level queries as to type of relationship
bool isOneToMany () const
 
bool isManyToOne () const
 
bool isOneToOne () const
 
bool isManyToMany () const
 
bool isJoin () const
 If we don't have mJoinField then we are a pointer relationship. More...
 
bool isRelBackToParent () const
 Do we point left or right? ie: in Patients->Visits is this relationship field pointing back from Visits to Patients (the inverse relationship). More...
 
perform the relationship traversal
unsigned long countAllRelated ()
 
bool relateRecord (bool broadcastChange=true)
 
bool selectAllRelated (bool broadcastChange=true)
 
bool relateFromRecord (bool broadcastChange=true)
 Used to load a related selection. More...
 
relationship manipulation
void updateRelValue ()
 Propagate values to maintain a relationship. More...
 
void setOID (oidT)
 
void breakRelLink ()
 Break the link from another table pointing at us. More...
 
void changeRelationshipTo (dbRelRefBase &newRhs)
 Change an existing relationship to point to a different field. More...
 

Protected Member Functions

void BuildRelatedTable ()
 
void CalculateWith (dbCalculator *adoptedCalculator, bool useOnlyForDefaults)
 
bool CompletelySpecified () const
 
virtual void CopyCalculatedValueToBuffer ()
 
unsigned long CountAllRelatedIn (dbTable *)
 
oidT OID () const
 
void OID (oidT)
 
void SetCommonRelationshipFields (dbRelRefBase &)
 

Protected Attributes

dbTablemActualRelatedTable
 
OOF_tableBackendmBackend
 
dbCalculatormCalculator
 
fieldNumT mFieldNumber
 
bool mHidden
 
dbRelRefBasemInverseField
 
fieldNumT mInverseFieldNumber
 
dbFieldmJoinField
 
oofBroadcastermListensTo
 
unsigned long mMaxLinks
 
unsigned long mMinLinks
 
OOF_RelMNmMNlink
 
bool mPropagatesDeletes
 
dbTablemRelatedTableProto
 
unsigned short mSuspendCount
 
oofBroadcastermSuspendedListensTo
 
dbTablemTable
 

Detailed Description

Parent for any field that is a relationship to another table.

Initialisation by subclasses with maxLinks==1 or >1 indicates nature of relationship.

Definition at line 19 of file oofrel.h.

Constructor & Destructor Documentation

dbRelRefBase::dbRelRefBase ( const char *  fieldName = 0,
unsigned long  maxLinks = 0 
)

Definition at line 285 of file oofrel.cpp.

Referenced by clone().

dbRelRefBase::dbRelRefBase ( const dbRelRefBase rhs)

Definition at line 299 of file oofrel.cpp.

References OOF_RelMN::cloningRelIs(), mMNlink, and setMNlink().

dbRelRefBase::~dbRelRefBase ( )
virtual

Definition at line 319 of file oofrel.cpp.

References OOF_RelMN::decRefs(), and mMNlink.

Member Function Documentation

const char * dbField::asChars ( ) const
virtualinherited
void dbRelRefBase::breakRelLink ( )

Break the link from another table pointing at us.

Doesn't need to do anything for join relationships as we deem it too dangerous to go and blithely clear key fields which may have multiple uses.

Called when update record on rhs OR when reassign link

Todo:

if save type of rhs is requireExplicitAndBuffer then need to cache some kind of undo comand in case need to cancel delete.

reassess need to clear join key fields - maybe that is needed in some cases to retain referential integrity

Definition at line 899 of file oofrel.cpp.

References isRef(), mInverseField, mJoinField, OID(), and RAISE_EXCEPTION.

Referenced by dbTable::deleteRecord().

void dbRelRefBase::BuildRelatedTable ( )
protected
void dbField::CalculateWith ( dbCalculator adoptedCalculator,
bool  useOnlyForDefaults 
)
protectedinherited
bool dbField::caseSensitive ( ) const
inlineinherited

Definition at line 747 of file oof3.h.

References kIndexCaseSensitive.

virtual void dbField::clear ( )
inlinevirtualinherited
dbField * dbRelRefBase::clone ( ) const
virtual

Implements dbField.

Definition at line 327 of file oofrel.cpp.

References dbRelRefBase().

void dbRelRefBase::completeCloneOfInverse ( dbRelRefBase cloner)
void dbRelRefBase::completeCloneOfInverse ( dbTable clonerTable)
bool dbRelRefBase::CompletelySpecified ( ) const
inlineprotected

Definition at line 228 of file oofrel.h.

References mRelatedTableProto.

Referenced by describe(), fieldName(), isJoin(), and relatesTo().

void dbField::CopyCalculatedValueToBuffer ( )
protectedvirtualinherited
oofString dbField::copyString ( ) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 472 of file oof3.cpp.

References dbField::extract().

Referenced by dbFieldLink::copyFieldToLink(), dbFieldLink::copyLinkToField(), oofRepGraphBand_CSVRender::draw(), oofRepGraphBand_TSVRender::draw(), oofRepViewBand_HTMLRender::draw(), oofRepViewBand_CSVRender::draw(), oofRepViewBand_TSVRender::draw(), oofRepViewBand_WinRender::draw(), oofRepViewBand_MacRender::draw(), oofRepViewBand_RTFRender::draw(), dbRepHTML::drawColumnar(), dbRepHTMLTable::drawColumnar(), dbRepChar::drawColumnar(), dbRepHTML::drawPageWise(), dbRepHTMLTable::drawPageWise(), dbRepChar::drawPageWise(), dbRep::extract(), oofColumnGraph::finishConstruction(), oofPointGraph::finishConstruction(), oofLineGraph::finishConstruction(), oofBarGraph::finishConstruction(), oofStackedBarGraph::finishConstruction(), oofOrdinalStackedBarGraph::finishConstruction(), oofPieGraph::finishConstruction(), oofRepViewEditLink::getCellText(), oofRepFieldBlock::getCellText(), OOF_mixOutlineItem::GetDrawContentsFromView(), dbDate::getStr255(), dbDateTime::getStr255(), dbFieldLink::linkEqualsField(), oofRepFieldBlock::MiddleText(), oofRepCustomViewDrawer::plainText(), OOF_simpleRecordBackend::recordNumberMatching(), OOF_simpleRecordBackend::SearchEqualNonIndexedWildcard(), OOF_simpleRecordBackend::SearchNotEqualNonIndexedWildcard(), OOF_simpleRecordBackend::searchSelContainsAllOf(), OOF_simpleRecordBackend::searchSelContainsAnyOf(), dbGUIAdaptLPopupButton::setValueList(), OOF_simpleRecordBackend::SubSort(), dbFieldLink::validToLeaveForm(), and oofXMLDBWriter::writeRecord().

virtual void dbField::copyValueFrom ( const dbField )
inlinevirtualinherited

Reimplemented in dbDateTime, dbTime, dbDate, dbReal, dbText, dbUlong, dbLong, dbBool, dbUshort, dbChar, and dbShort.

Definition at line 140 of file oof3.h.

Referenced by dbTable::copyRecFrom(), and dbFieldCopier::receiveMsg().

virtual void dbField::copyValueIfDifferent ( const dbField )
inlinevirtualinherited
unsigned long dbRelRefBase::countAllRelated ( )
unsigned long dbRelRefBase::CountAllRelatedIn ( dbTable rhs)
protected
void dbRelRefBase::describe ( std::ostream &  ) const
virtual

Provide human-readable information about object.

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

Reimplemented from dbField.

Definition at line 955 of file oofrel.cpp.

References CompletelySpecified(), dbTable::field(), fieldName(), dbField::fieldName(), isRef(), mInverseFieldNumber, mJoinField, mRelatedTableProto, and propagatesDeletes().

dbField * dbField::equivalentFieldFromTable ( dbTable baseTable) const
inherited
void dbRelRefBase::extract ( std::ostream &  ) const
virtual
unsigned long dbField::fieldDataLen ( ) const
inlineinherited
bool dbField::fieldIndexIgnoresNulls ( ) const
inlineinherited

Definition at line 699 of file oof3.h.

References kIndexNoNulls.

Referenced by OOF_ctreeBackend::countAll().

bool dbField::fieldIndexIsCompressLeading ( ) const
inlineinherited

Definition at line 707 of file oof3.h.

References kIndexCompressLeading.

bool dbField::fieldIndexIsCompressPadding ( ) const
inlineinherited

Definition at line 715 of file oof3.h.

References kIndexCompressPadding.

OOF_IndexOptions dbField::fieldIndexOptions ( ) const
inlineinherited

Definition at line 678 of file oof3.h.

Referenced by dbField::describe().

bool dbField::fieldIsBinary ( ) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 393 of file oof3.cpp.

bool dbField::fieldIsBlob ( ) const
virtualinherited
bool dbField::fieldIsIndexed ( ) const
virtualinherited
bool dbField::fieldIsJoinKey ( ) const
inherited

Checks if any relationships in field's table use field as join key.

Relatively expensive because it's iterating over all fields but all the function calls below are inline queries so will compile down well in release mode.

WARNING Doesn't fan out - if any other tables use this field as a join key then they are doing really weird stuff and the application programmer must add their own checks.

This feature originally added to support OOF_repEditSetupVisitor::VisitViewBandBody

Definition at line 327 of file oof3.cpp.

References dbTable::field(), dbField::fieldIsStandalone(), dbField::fieldType(), joinField(), dbField::mFieldNumber, dbField::mTable, dbTable::numFields(), and relationshipField.

Referenced by OOF_repEditSetupVisitor::VisitIterableBandBody().

bool dbField::fieldIsKeywordIndexed ( ) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 415 of file oof3.cpp.

Referenced by OOF_ctreeBackend::BuildBackendtables().

bool dbField::fieldIsPartiallyIndexed ( ) const
inlineinherited

Definition at line 692 of file oof3.h.

References dbField::kKeyLengthAutoCalculated.

Referenced by dbField::fieldKeyLen().

bool dbRelRefBase::fieldIsSameTypeAs ( const dbField rhs) const
virtual
bool dbField::fieldIsStandalone ( ) const
inlineinherited
bool dbField::fieldIsUniqueIndexed ( ) const
virtualinherited
bool dbRelRefBase::fieldIsVirtual ( ) const
virtual

Reimplemented from dbField.

Definition at line 697 of file oofrel.cpp.

References mJoinField.

unsigned short dbField::fieldKeyLen ( ) const
inherited
unsigned long dbField::fieldMinWrapWidth ( ) const
virtualinherited
const OOF_String & dbRelRefBase::fieldName ( ) const
virtual

Override to return related table name as sensible default.

Usually we don't bother naming individual relationships however you are able to call setName or pass in a name to the ctor. When modelling more than one relationship between the same classes we recommend naming the relationship variables.

Returns
specified name or name of related table.

Reimplemented from dbField.

Definition at line 1050 of file oofrel.cpp.

References CompletelySpecified(), dbField::fieldName(), oofString::isEmpty(), mRelatedTableProto, and dbTable::tableName().

Referenced by describe(), OOF_RelationshipsToInstantiate::findMatch(), propagateRelatedDeletes(), and SetCommonRelationshipFields().

fieldNumT dbField::fieldNumber ( ) const
inlineinherited
unsigned short dbField::fieldNumIndexes ( ) const
inlineinherited

Definition at line 723 of file oof3.h.

References kNotIndexed.

Referenced by OOF_ctreeBackend::BuildBackendtables().

unsigned long dbRelRefBase::fieldStorageLen ( ) const
virtual

Implements dbField.

Definition at line 706 of file oofrel.cpp.

References mJoinField.

dbTable * dbField::fieldTable ( ) const
inherited
OOF_fieldTypes dbRelRefBase::fieldType ( ) const
virtual

Implements dbField.

Definition at line 680 of file oofrel.cpp.

References relationshipField.

Referenced by nativeType().

unsigned long dbField::fieldUsualWrapWidth ( ) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 235 of file oof3.cpp.

References dbField::fieldMinWrapWidth().

Referenced by oofViewFieldDefaultsColSizer::CalculateDefaultWidths().

virtual void dbField::generateTestData ( bool  ,
unsigned long   
)
inlinevirtualinherited

Reimplemented in dbDateTime, dbTime, dbDate, dbReal, dbFixedBinary, dbText, dbUlong, dbLong, dbBLOB, dbBool, dbUshort, dbChar, and dbShort.

Definition at line 147 of file oof3.h.

Referenced by dbTable::generateTestData().

void dbField::getChars ( char *  ioBuff,
unsigned long &  outLen 
) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 481 of file oof3.cpp.

References dbField::extract().

Referenced by dbViewAsTableStorage::GetCellData().

OOF_RelMN * dbRelRefBase::getMNlink ( ) const
inline

Definition at line 221 of file oofrel.h.

References mMNlink.

Referenced by dbBrowseHelper::browseViewWithTable().

bool dbField::hasDefaultCalculator ( ) const
inlineinherited
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.

void dbField::index ( const OOF_IndexOptions  indexOpt = kIndexed)
inherited

Definition at line 212 of file oof3.cpp.

Referenced by joinField(), and SetCommonRelationshipFields().

void dbField::indexPartialKeyLen ( unsigned short  inLen)
inlineinherited

Definition at line 685 of file oof3.h.

bool dbField::insert ( std::istream &  ,
char  fieldSep,
char  recSep 
)
virtualinherited

Reimplemented in dbDateTime, dbTime, dbDate, dbReal, dbText, dbUlong, dbLong, dbBool, dbUshort, dbChar, and dbShort.

Definition at line 513 of file oof3.cpp.

Referenced by dbChar::insert(), dbText::insert(), dbTable::insert(), and operator>>().

dbRelRefBase * dbRelRefBase::inverse ( ) const
inline
bool dbField::isDirty ( ) const
inherited
bool dbField::isEmpty ( ) const
virtualinherited

Reimplemented in dbDateTime, dbDate, dbBLOB, and dbChar.

Definition at line 170 of file oof3.cpp.

Referenced by OOF_ctreeKeywordIndex::updateWords().

bool dbRelRefBase::isJoin ( ) const
inline

If we don't have mJoinField then we are a pointer relationship.

(or some other kind added later than OOFILE 1.4)

Definition at line 304 of file oofrel.h.

References CompletelySpecified(), and mJoinField.

Referenced by dbFieldPickLink::copyFieldToLink(), propagateRelatedDeletes(), and dbRelRef::setRelatedRecord().

bool dbRelRefBase::isManyToMany ( ) const
inline

Definition at line 292 of file oofrel.h.

References isRef(), and mInverseField.

bool dbRelRefBase::isManyToOne ( ) const
inline

Definition at line 276 of file oofrel.h.

References isRef(), and mInverseField.

Referenced by dbAbstractEditHelper::linkPickAdapter().

bool dbRelRefBase::isOneToMany ( ) const
inline

Definition at line 268 of file oofrel.h.

References isRef(), and mInverseField.

Referenced by propagateRelatedDeletes(), and relatesTo().

bool dbRelRefBase::isOneToOne ( ) const
inline

Definition at line 284 of file oofrel.h.

References isRef(), and mInverseField.

Referenced by dbAbstractEditHelper::linkPickAdapter(), and propagateRelatedDeletes().

bool dbRelRefBase::isRef ( ) const
inline

Is "ref" to just one instance.

Returns
false if can relate to multiple records

Definition at line 261 of file oofrel.h.

References mMaxLinks.

Referenced by breakRelLink(), changeRelationshipTo(), describe(), extract(), isManyToMany(), isManyToOne(), isOneToMany(), isOneToOne(), receiveMsg(), relateFromRecord(), SetCommonRelationshipFields(), setOID(), and updateRelValue().

bool dbRelRefBase::isRelBackToParent ( ) const
inline

Do we point left or right? ie: in Patients->Visits is this relationship field pointing back from Visits to Patients (the inverse relationship).

This is important to know if you are following a relationship chain back from a related table to the source. So we test if the table which contains this field actually points back to the LHS via this field.

Definition at line 321 of file oofrel.h.

References dbTable::controllingRelationship(), and dbField::mTable.

Referenced by dbFieldPickLink::dbFieldPickLink(), and dbAbstractEditHelper::linkPickAdapter().

void dbRelRefBase::joinField ( dbField joinBy)
dbField * dbRelRefBase::joinField ( ) const
inline

Definition at line 250 of file oofrel.h.

References mJoinField.

oofString dbField::name ( ) const
virtualinherited

Reimplemented from OOF_PublicBase.

Definition at line 156 of file oof3.cpp.

References dbField::fieldName().

Referenced by dbField::setName().

OOF_fieldTypes dbRelRefBase::nativeType ( ) const
virtual

Reimplemented from dbField.

Definition at line 687 of file oofrel.cpp.

References fieldType(), mJoinField, and uLongField.

oidT dbRelRefBase::OID ( ) const
protected
void dbRelRefBase::OID ( oidT  oid)
protected

Definition at line 726 of file oofrel.cpp.

References dbField::mBackend, OID(), and OOF_tableBackend::writeLong().

bool dbRelRefBase::pointsToCorrectTableType ( ) const
virtual

Default base method.

Macro REL_REF_BODY in oofmacro.h defines virtual overrides for each subclass that do an actual test using the macro-generated dbTable::defaultName() override.

Note
it is possible for people to create relationships other than through the declarative macros so we need to keep the base dbRelRef and dbRelSet usable, which is why this method isn't a pure virtual.
Returns
true always, macro-generated override returns true OR false

Definition at line 1002 of file oofrel.cpp.

Referenced by relatesTo().

void dbRelRefBase::postCloneTableCleanup ( )
virtual

Reimplemented from dbField.

Definition at line 334 of file oofrel.cpp.

References dbTable::field(), dbField::fieldNumber(), mJoinField, and dbField::mTable.

void dbRelRefBase::propagateRelatedDeletes ( bool  prop = true)

Set relationship to propagate deletes, ie: owns related records.

Warning
It is tempting to only allow this if (mTable->inDeclarativePhase()) but that check is not sufficient - during cloning of a table it is possible and legal to call propagateRelatedDeletes, as happens in ooftst42 with the MN link.
Todo:

see if we can add back the commented out test below safely

propagate deletes for N:1 with pointer relationships.

Definition at line 747 of file oofrel.cpp.

References fieldName(), isJoin(), isOneToMany(), isOneToOne(), mPropagatesDeletes, dbField::mTable, dbConnect::raise(), and dbTable::tableName().

Referenced by relatesTo(), and setMNlink().

bool dbRelRefBase::propagatesDeletes ( ) const
inline

Definition at line 235 of file oofrel.h.

References mPropagatesDeletes.

Referenced by describe(), receiveMsg(), and dbTable::relateAllDeletables().

bool dbRelRefBase::receiveMsg ( OOFmsgT  msg,
unsigned long  senderDefined 
)
virtual

The default receiveMsg behaviour is to delete yourself when the broadcaster closes.

In many user subclasses oofSingleListener is a mixin and you have a class owned elsewhere, not self-deleting.

\warning If a subclass is not self-deleting it MUST override receiveMsg 
handling of the msg OOFmsg_BroadcasterClosing to prevent runtime error.

However it is still important to set mListensTo=0 otherwise when you finally get around to deleting your oofSingleListener, it will try to update a deleted oofBroadcaster and cause a crash.

Reimplemented from oofSingleListener.

Definition at line 787 of file oofrel.cpp.

References dbTable::currentOID(), dbTable::deleteSelection(), dbTable::isDirty(), dbTable::isRecordLoaded(), isRef(), dbTable::isTableValid(), dbTable::mBackend, mInverseField, mJoinField, oofSingleListener::mListensTo, dbField::mTable, OID(), OOFmsg_BroadcasterClosing, OOFmsg_ChangeContext, OOFmsg_ChangeSelection, OOFmsg_DeleteRecord, OOFmsg_ResumeSorting, OOFmsg_SaveRecord, OOFmsg_SuspendSorting, OOFmsg_UnloadRecord, propagatesDeletes(), oofSingleListener::receiveMsg(), dbTable::resumeSorting(), dbTable::saveRecord(), dbTable::setTableValid(), dbTable::suspendSorting(), OOF_tableBackend::unloadCache(), and dbTable::unloadRecord().

dbTable * dbRelRefBase::relatedTable ( )
tableNumT dbRelRefBase::relatedTableNumber ( ) const

Definition at line 1066 of file oofrel.cpp.

References mRelatedTableProto, and dbTable::tableNumber().

bool dbRelRefBase::relateFromRecord ( bool  broadcastChange = true)

Used to load a related selection.

Mainly called from dbTable::ensureRecordLoaded and dbTable::MakeTableValid.

It may seem a little backwards but think of the normal context of using this method. We have already loaded a current record in the LHS of a relationship and now want the related record or selection. Remember that OOFILE allows you to iterate a table without forcing instantiation of relationships. Only when you refer to a related selection or specific fields in a related record is the relationship instantiated.

There are three distinct cases dealt with by this method:

  1. an M:N relationship, which is implemented by our member mMNlink.
  2. a 1:1, 1:N or N:1 join relationship which is handled by OOF_simpleRecordBackend::loadRelatedContextJoiningFromTo (normally via a search)
  3. a 1:1, 1:N or N:1 pointer relationship using record OID's in a search or direct lookup

If mInverseField (ie: other side of relationship pointing to us) isRef() then it contains a copy of the OID of a record in our table and we have a direct lookup (not caring if this is 1:1 or N:1 situation).

Otherwise it is 1:N and the OID on the other side is its record's OID, used as a key to search our relationship fields.

Todo:
explore using virtual overrides of relateFromRecord for user-defined relationships

Definition at line 580 of file oofrel.cpp.

References oofBroadcaster::broadcast(), dbTable::currentOID(), dbField::fieldTable(), isRef(), joinField(), OOF_tableBackend::loadRelatedContextJoiningFromTo(), mActualRelatedTable, dbField::mBackend, mInverseField, mJoinField, mMNlink, dbField::mTable, OID(), OOF_DEBUG_LOG, OOFmsg_ChangeSelection, OOF_tableBackend::searchEqual(), OOF_tableBackend::selectJustOID(), OOF_tableBackend::selectNone(), dbTable::setTableValid(), and dbTable::tableName().

Referenced by dbTable::ensureRecordLoaded(), relateRecord(), and OOF_RelMN::removeSelection().

bool dbRelRefBase::relateRecord ( bool  broadcastChange = true)
void dbRelRefBase::relatesTo ( dbRelRefBase rhs)

Called by dbRelationship to tie two instances of dbRelRefBase together.

Makes an actual relationship occur between the known tables in a dbConnection, finishing the work of declaring dbRelRef or dbRelSet members in the tables.

Sets the relational integrity up by default to make sense for Western users. The left table owns the right table unless the relationship is back to front. ie: an N:1 doesn't propagate deletes. Assumes ctor initialises mPropagatesDeletes false. If you have explicitly set mPropagatesDeletes true already it will retain that setting.

At this level we are working with the virtual and base methods of the dbRelRefBase

Note
After this is called (ie: after dbRelationship functor) you can call propagateRelatedDeletes explicitly. eg: if you had a 1:1 relationship just to avoid loading large records, you would want to propagate deletes. We err on the side of caution in not propagating by default when it is hard to tell.

Definition at line 388 of file oofrel.cpp.

References CompletelySpecified(), dbTable::defaultName(), dbField::fieldTable(), isOneToMany(), pointsToCorrectTableType(), propagateRelatedDeletes(), dbConnect::raise(), relatesTo(), and SetCommonRelationshipFields().

Referenced by dbRelationship::dbRelationship(), and relatesTo().

void oofSingleListener::resumeListening ( )
inherited
void dbField::saveDefaultCalculatedValue ( )
inherited
void dbField::saveStoredCalculatedValue ( )
inherited

Definition at line 282 of file oof3.cpp.

References dbField::CopyCalculatedValueToBuffer().

Referenced by OOF_simpleRecordBackend::saveRecord().

bool dbRelRefBase::selectAllRelated ( bool  broadcastChange = true)
void dbRelRefBase::SetCommonRelationshipFields ( dbRelRefBase rhs)
protected
void dbRelRefBase::setMNlink ( OOF_RelMN inLink)

Point this relationship at the object which maintains the link.

Calling setMNlink completes specifying the relationship - we assume the OOF_RelMN class manages the other relationships used to provide the 1:N N:1 that implement the M:N.

Note
doesn't propagateRelatedDeletes because the other relationships that implement the link take care of propagation. However we could call propagateRelatedDeletes(true) if we wanted deleting one side to delete the other automatically.

Definition at line 496 of file oofrel.cpp.

References OOF_RelMN::decRefs(), OOF_RelMN::incRefs(), mMNlink, and propagateRelatedDeletes().

Referenced by dbRelRefBase(), and dbRelationship::linkMNvia().

void dbField::setName ( const char *  name)
inherited

Definition at line 195 of file oof3.cpp.

References dbField::name().

Referenced by dbView::AppendOwnedField(), and OOF_repXMLschemaVisitor::UniquifyTables().

virtual void dbField::setNumber ( long  )
inlinevirtualinherited

Reimplemented in dbDateTime, dbDate, dbReal, dbText, dbUlong, dbLong, dbBool, dbUshort, dbChar, and dbShort.

Definition at line 133 of file oof3.h.

Referenced by dbNumericField::clear().

void dbRelRefBase::setOID ( oidT  inOID)

Definition at line 877 of file oofrel.cpp.

References isRef(), mJoinField, and OID().

Referenced by OOF_RelMN::appendSelection().

virtual void dbField::setString ( const char *  )
inlinevirtualinherited
void dbField::storeCalculatedValues ( )
inlineinherited

Definition at line 813 of file oof3.h.

Referenced by OOF_ctreeBackend::BuildBackendtables().

bool dbField::storesCalculatedValues ( ) const
inlineinherited

Definition at line 806 of file oof3.h.

Referenced by OOF_simpleRecordBackend::GetFieldWriteDest().

void oofSingleListener::subscribeTo ( oofBroadcaster broad)
virtualinherited
void oofSingleListener::suspendListening ( )
inherited
const char * dbField::tableName ( ) const
inherited
void oofSingleListener::unsubscribe ( oofBroadcaster from = 0)
virtualinherited
void dbRelRefBase::updateRelValue ( )

Propagate values to maintain a relationship.

Either copies a join key or stores an OID for pointer traversal.

Note
updating the lhs relationship is performed in receiveMsg, AFTER our saveRecord in case our table's OID is required by the rhs.

Definition at line 855 of file oofrel.cpp.

References dbField::copyValueIfDifferent(), dbTable::currentOID(), dbField::fieldTable(), isRef(), joinField(), mActualRelatedTable, mInverseField, mJoinField, mMNlink, dbField::mTable, OID(), and RAISE_EXCEPTION.

Referenced by OOF_RelMN::appendSelection(), and dbTable::saveRecord().

void dbField::useCalculatorOnlyForDefaults ( )
inlineinherited

Definition at line 799 of file oof3.h.

Referenced by dbField::CalculateWith().

bool dbField::usingCalculator ( ) const
inherited
bool dbField::validateContents ( )
virtualinherited

Definition at line 177 of file oof3.cpp.

dbQueryClause * dbField::valueAsQueryLiteral ( ) const
virtualinherited
bool dbField::valueIsDuplicate ( ) const
inherited
oofWordParser * dbField::words ( ) const
virtualinherited

Reimplemented in dbText, and dbChar.

Definition at line 251 of file oof3.cpp.

Referenced by OOF_simpleRecordBackend::SearchWordNonIndexed(), and OOF_ctreeKeywordIndex::updateWords().

Member Data Documentation

dbTable* dbRelRefBase::mActualRelatedTable
protected
OOF_tableBackend* dbField::mBackend
protectedinherited
dbCalculator* dbField::mCalculator
protectedinherited
fieldNumT dbField::mFieldNumber
protectedinherited
bool OOF_PublicBase::mHidden
protectedinherited

Definition at line 61 of file oof1.h.

dbRelRefBase* dbRelRefBase::mInverseField
protected
fieldNumT dbRelRefBase::mInverseFieldNumber
protected

Definition at line 101 of file oofrel.h.

Referenced by describe(), inverse(), and SetCommonRelationshipFields().

dbField* dbRelRefBase::mJoinField
protected
oofBroadcaster* oofSingleListener::mListensTo
protectedinherited
unsigned long dbRelRefBase::mMaxLinks
protected

Definition at line 98 of file oofrel.h.

Referenced by isRef().

unsigned long dbRelRefBase::mMinLinks
protected

Definition at line 98 of file oofrel.h.

OOF_RelMN* dbRelRefBase::mMNlink
protected
bool dbRelRefBase::mPropagatesDeletes
protected

Definition at line 103 of file oofrel.h.

Referenced by propagateRelatedDeletes(), and propagatesDeletes().

dbTable* dbRelRefBase::mRelatedTableProto
protected
unsigned short oofSingleListener::mSuspendCount
protectedinherited
oofBroadcaster* oofSingleListener::mSuspendedListensTo
protectedinherited
dbTable* dbField::mTable
protectedinherited

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