SomSubstituteClass

This method causes the somFindClass, somFindClsInFile, and somClassFromIdmethods to substitute one class for another.

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


 * Original Class : SOMClassMgr

Syntax
 SOMClassMgr   receiver; string        origClassName; string        newClassName; long          rc;

rc = somSubstituteClass(receiver, origClassName, newClassName); 

Parameters
SOMClassMgr.
 * receiver (SOMClassMgr) : Usually SOMClassMgrObject or a pointer to an instance of a user-defined subclass of


 * origClassName (string) : A NULL terminated string containing the old class name.


 * newClassName (string) : A NULL terminated string containing the new class name.

Return Code

 * rc (long) : The somSubstituteClass method returns a value of zero to indicate success; a non-zero value indicates an error was detected.

Remarks
The somSubstituteClass method causes the somFindClass, somFindClsInFile, and somClassFromId methods to return the class named newClassName whenever they would normally return the class named origClassName. This effectively results in class newClassName replacing or substituting for class origClassName. For example, the New macro will subsequently create instances of newClassName.

Some restrictions are enforced to ensure that this works well. Both class origClassName and class newClassName must have been already registered before issuing this method, and newClass must be an immediate child of origClass. In addition (although not enforced), no instances should exist of either class at the time this method is invoked.

A convenience macro (SOM_SubstituteClass ) is provided for C or C++ users. In one operation, it creates both the old and the new class and then substitutes the new one in place of the old. The use of both the somSubstituteClass method and the SOM_SubstituteClass macro is illustrated in the example below.

Original Class

 * SOMClassMgr

Example Code

 * 1) include 
 * 2) include 

/* Macro form */ SOM_SubstituteClass (Student, MyStudent); /* Direct use of the method, equivalent to * the macro form above. */ { SOMClass origClass, replacementClass;

origClass = StudentNewClass (Student_MajorVersion,                                       Student_MinorVersion); replacementClass = MyStudentNewClass (MyStudent_MajorVersion,                                     MyStudent_MinorVersion); SOMClassMgr_somSubstituteClass (   SOMClass_somGetName (origClass),    SOMClass_somGetName (replacementClass)); } 

Methods

 * somClassFromId
 * somFindClass
 * somFindClsInFile
 * somMergeInto