Example: Basic Member Delegation

Meta Data Services Programming

Meta Data Services Programming

Example: Basic Member Delegation

This example includes sample code for creating a derived property and a derived collection. This example illustrates how to create a new interface and define the derived property. Creating a relationship with a predefined base property declares that this property is derived. Similarly, this example also illustrates how to define a derived collection. The same procedure is used for method definitions. There is no change in the programming logic of setting and getting properties or manipulating collections.

The following table identifies the Repository Type Information (RTIM) objects and the corresponding pointers that appear in the sample code.

RTIM object Pointer
IinterfaceDef *pINewIface;
IclassDef *pIClassDef;
IpropertyDef *pIBaseProp, *pIDerivedProp;
IrelationshipDef *pINewRelshipDef;
IrelshipColDef *pIBaseCol, *pIDerivedCol;
IreposTypeLib *pITypeLib;

In order to run this sample, you must create a type library and a class definition for a new interface. Also, the collection pIBaseCol (a collection that is the same type as the one being delegated) and the property pIBaseProp (a property that is the same type as the one being delegated) must have been defined earlier. The pointers pIBaseCol and pIBaseProp are assumed to have been already set before running this example.

// Create a new interface:
pIClassDef->CreateInterfaceDef(CRepVariant(OBJID_INewOrgIface), 
CVariant("INewIface"), CRepVariant(IID_INewIface), pIIReposDispatch, 
CVariant("Default"), &pINewIface);

// Create an alias property:
pINewIface->CreateAlias(CRepVariant(OBJID_ALongDerived), 
CVariant("ALongDerived"), DISPID_ALongDerived, pIBaseProp, 
&pIDerivedProp);

// Create an alias collection:
pINewIface->CreateAlias(CRepVariant(OBJID_CollectionDerived), 
CVariant("CollectionDerived"), DISPID_CollectionDerived, 
pIBaseCol, &pIDerivedCol);

See Also

Creating a Derived Member

Defining Inheritance

Example: Member Delegation with Filtering