Jump to content

somMergeInto

From EDM2
Revision as of 18:19, 12 October 2022 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method transfers SOM class registry information to another SOMClassMgr instance.

Note: For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMClassMgr

Syntax

void somMergeInto (SOMClassMgr receiver, SOMClassMgr target)

Parameters

receiver (SOMClassMgr)
Usually SOMClassMgrObject (or a pointer to an instance of a user-supplied subclass of SOMClassMgr).
target (SOMClassMgr)
A pointer to another instance of SOMClassMgr or one of its subclasses.

Return Code

rc (void)

Remarks

The somMergeInto method transfers the SOMClassMgr registry information from one object to another. The target object is required to be an instance of SOMClassMgr or one of its subclasses. At the completion of this operation, the target object can function as a replacement for the receiver. The receiver object (which is then in a newly uninitialized state) is placed in a mode where all methods invoked on it will be delegated to the target object. If the receiving object is the instance pointed to by the global variable SOMClassMgrObject, then SOMClassMgrObject is reassigned to point to the target object.

Subclasses of SOMClassMgr that override the somMergeInto method should transfer their section of the class manager object from the target to the receiver, then invoke their parent's somMergeInto method as the final step.

Invoke this method only if you are creating your own subclass of SOMClassMgr. You can invoke somMergeInto from an initializer for your new class manager.

Example Code

// === IDL For the New Class Manager ===
#include <somcm.idl>

interface NewCM  :  SOMClassMgr {
        implementation   {
                somDefaultInit:  override;
       };
};

// === C++ implementation for NewCM ===

#define SOM_Module_merge_Source
#include "merge.xih"
SOM_Scope void SOMLINK somDefaultInit(NewCM *somSelf,
                                                        somInitCtrl* ctrl)
{
        NewCMData *somThis;   /* set in BeginInitializer */
        somInitCtrl globalCtrl;
        somBooleanVector myMask;
        NewCMMethodDebug ("NewCM","somDefaultInit");
        NewCM_BeginInitializer_somDefaultInit;

        NewC_Init_SOMClassMgr_somDefaultInit(somSelf, ctrl);

        /*
         *  local NewCM initialization code added by programmer
         */

        SOMClassMgrObject->somMergeInto(somSelf);
}

// === C++ test program ===

#include <merge.xh>
main()
{
        NewCM *ncm = new NewCM;
        SOMClassMgrObject->somDumpSelf(0);
}
// === Output from test program ===

{An instance of class NewCM at address 20084388
 1 classIdSpaceSize:  3200
 1 classIdHashTableSize:  397
 1 loadAffinity:  0
 1 nextLoadAffinity:  1
 1 IR Class:  00000000,  IR Object:  00000000
 1          -Class-- -Token-- Aff Seq ---Id--- Name
 1 í    0ù 20077A48 00000000 000 001 2008260C SOMObject
 1 í    1ù 2007FB38 00000000 000 000 200825EC SOMClassMgr
 1 í    2ù 20083B08 00000000 000 004 2008436C NewCM
 1 í    3ù 20077BD8 00000000 000 002 2008262C SOMClass
 1 í    4ù 20082668 00000000 000 003 2008315C
 SOMParentDerivedMetaclass
}

Related