Creating a Derived Member

Meta Data Services Programming

Meta Data Services Programming

Creating a Derived Member

Interface members are either base members or derived members. A derived member is mapped to another interface base member through a relationship. Member derivation supports mapping of the form MemberB Is-Derived-From MemberA, which means that MemberA provides implementation for MemberB.

How to Define a Derived Member

Before you can define a derived member, you must verify that the interface that includes the derived member and the interface that contributes the base member are implemented by the same class. For more information about conditions and constraints that apply to derived member definition, see Derived Member Requirements.

To define a derived member, use the IInterfaceDef2::CreateAlias method to create an alias that represents the derived member. Aliases are created from the interface on which you add the derived member.

If you use CreateAlias, the derived member is automatically mapped to the base member providing implementation details. Mapping is achieved by adding the derived member and the base member to collections. The base member is added to the ServicedByBaseMember (the origin) collection, and the alias to the ServicesDerivedMembers (the destination) collection. The two collections are the two sides of the BaseMemberServicesDerivedMembers relationship class. IInterfaceMember2 provides these collections.

After you create a derived member, you can add a property definition object to the derived member to enhance its definition.

Adding a Derived Member to an Existing Class

You can add an interface containing derived members to an existing class. No modification of the instances is required as long as both the derived members and the existing instances of the class have valid data for the properties and collections.

However, in one case some existing instances of the class may be undesirable, although they're technically valid. In this case, an interface with a derived collection, for example, may be added to a class that already has instances, and the base member may be read-only. This means that new relationships on instances of this class can be added to the derived collection but not (directly) to the base collection. Thus, all new relationships in the base collection will conform to the definition of the derived collection. However, at the time the derived collection definition was added, there may have been existing instances of the class with relationships on the base collection that do not conform to the derived collection.

Updating a Derived Member

You can define whether a derived member can be updated. Update capability is enabled by default. To prohibit updating, set the INTERFACEMEMBER_READONLY flag to TRUE. For more information, see Derivation Behavior and InterfaceMemberFlags Enumeration.

See Also

Defining Inheritance

Example: Basic Member Delegation

Example: Member Delegation with Filtering

IInterfaceDef2::CreateAlias

IInterfaceMember2 interface