TypeContext :: referenceContext - Reference context property
The reference context property is used in order to refer to another type context involved in an operation. The system is setting the reference context when executing copy functions in order to refer to the type context of source/target instance. This allows determining, whether a read or store event has been fired during a copy action. Especially initialize event handler should not work or should work differently when being called from within a copy action.
The reference context can be used in an application in order to refer to related context (instance) e.g. when importing data or performing other operations with more than one instance.
The reference context must be set explicitly by the application and is not reset automatically. It should not be called from within context event handlers.
After the reference context has been set by an application, it should be reset before calling next Property::append(), Property::insert() (create or add an instance) or Property::copy()(copy instance) for the related property by calling resetReferenceContext().
The function thows an exception, when no reference context exists. In order to avoid exceptions, one may call hasReferenceContext() before calling this function.
// OSI
if ( hasReferenceContext() )
ref_context &= referenceContext();
// C++
if ( hasReferenceContext() )
ref_context = &referenceContext();
Implementation overview
- Get reference context
TypeContext :: referenceContext (  ) - Set reference context property
TypeContext :: referenceContext ( cTypeContext )
Implementation details
-
Get reference context
odaba::TypeContext & TypeContext  :: referenceContext (  )
In case of copy or duplicate actions, or by application, a reference context may be set, which refers to the source instance in the given context. In case of duplicate() function call, property handles for current context and reference context are the same, but not the context instances.
to list
-
Set reference context property
odaba::TypeContext & TypeContext  :: referenceContext ( odaba::TypeContext &cTypeContext )
The function allows setting a reference context as link in another context e.g. to link structure contexts in a copy process. Only one context can be set as reference context. Calling the function several times will overwrite the reference context each time the function is called.
In order to reset the reference context an empty type context has to be passed to the function.
The function should never be called from within an event structure context handler (especially, when creating or inserting instances), and
void function( set<VOID > source ) {
referenceContext(sorce.typeContext()); // set reference context
// ...do something
resetReferenceContext(emptyCtx);
}
Notes:Setting a reference context before inserting an instance will disable the AUTOIDENT numbering, i.e. __AUTOIDENT (when being defined as auto number attribute) remains unchanged.
- cTypeContext - - internal feature (not documented)
to list