somDefaultConstAssign

From EDM2
Jump to: navigation, search

somDefaultConstAssign Provides support for a "const" object-assignment operator. Designed to be overridden.

Original Class 
SOMObject

Syntax

void somDefaultConstAssign (SOMObject receiver, somInitCtrl ctrl, SOMObject fromObj)

Parameters

receiver (SOMObject) 
A pointer to an object of an arbitrary SOM class, S.
ctrl (somInitCtrl) 
A pointer to a somInitCtrl structure, or NULL.
fromObj (SOMObject) 
A pointer to an object of class S or some class descended from S.

Return Code

rc (void)

Remarks

In C++, assignment to an object of class "X" is accomplished by using (an appropriate overloading of) the assignment operator provided by "X". To make assignment available on all SOM objects, SOMObject introduces the somDefaultAssign and somDefaultConstAssign methods. The default behavior of these methods is to perform a shallow copy of data from one object to another. When this default is not appropriate for a class, and it is possible to perform the copy without modifying fromObj, it is recommended that the class implementor override the somDefaultConstAssign method.

Generally, an object user should use the somDefaultAssign method to perform object assignment.

The considerations important to overriding somDefaultConstAssign are similar to those described in the SOM Programming Guide for overriding somDefaultInit. (See "Initializing and Uninitializing Objects" in Chapter 5, "Implementing Classes in SOM.") The basic difference between somDefaultInit and somDefaultConstAssign is that the latter method takes an object (fromObj) as an argument that is to be copied.

Example Code

// IDL for a class that overrides somDefaultConstAssign
#include <X.idl>

interface Y : X  {
        implementation  {
                somDefaultConstAssign: override, init;
        };
};

Related

Methods