Previous | Table of Contents | Next |
Although CORBA complex types are represented by Automation Dual Interfaces, creating an instance of a mapped CORBA complex
type is not the same as creating an instance of a mapped CORBA interface. The main difference lies in the fact that the name
space for CORBA complex types differs fundamentally from the CORBA object and factory name spaces.
To support creation of instances of Automation objects exposing Pseudo-Automation Interfaces, we define a new interface, derived
from DICORBAFactory (see Section 17.7.3, “ICORBAFactory Interface,? on page 17-24 for a description of DICORBAFactory).
// ODL[odl, dual, uuid(...)]interface DICORBAFactoryEx: DICORBAFactory{
HRESULT CreateType([in] IDispatch *scopingObject,[in] BSTR typeName, [retval,out] VARIANT *val);HRESULT CreateTypeById([in] IDispatch *scopingObject,[in] BSTR repositoryId,[retval,out] VARIANT *val);}
The UUID for DICORBAFactoryEx is:
{A8B553C5-3B72-11cf-BBFC-444553540000}
This interface can also be implemented as generic (nondual) Automation Interface, in which case it is named DCORBAFactoryEx
and its UUID is:
{E977F905-3B75-11cf-BBFC-444553540000}
The CreateType method creates an Automation object that has been mapped from a CORBA complex type. The parameters are used
to determine the specific type of object returned.
The first parameter, scopingObject, is a pointer to an Automation View Interface. The most derived interface type of the CORBA
object bound to the View identifies the scope within which the second parameter, typeName, is interpreted. For example, assume
the following CORBA interface exists:
// OMG IDL
module A {module B {interface C {
struct S { // ...
}
void op(in S s); // .... } } }
The following Visual Basic example illustrates the primary use of CreateType:
‘ Visual BasicDim myC as ObjectDim myS as ObjectDim myCORBAFactory as ObjectSet myCORBAFactory = CreateObject(“CORBA.Factory?)Set myC = myCORBAFactory.CreateObject( “...? )
‘ creates Automation View of the CORBA object
supporting interface ‘ A::B::CSet myS = myCORBAFactory.CreateType(myC, “S?)myC.op(myS)
The following rules apply to CreateType:
• The typeName parameter can contain a fully-scoped name (i.e., the name begins with a double colon “::?). If so, then the first parameter defines the type name space within which the fully scoped name will be resolved.
• If the scopingObject parameter does not point to a valid Automation View Interface, then CreateObject returns the HRESULT DISP_E_UNKNOWNINTERFACE.
• If the typeName parameter does not identify a valid type in the name space associated with the scopingObject parameter, then CreateObject returns the HRESULT TYPE_E_UNDEFINEDTYPE.
The CreateTypeByIDmethod accomplishes the same general goal of CreateType, the creation of Automation objects that are mapped
from CORBA-constructed types. The second parameter, repositoryID, is a string containing the CORBA Interface Repository ID
of the CORBA type whose mapped Automation Object is to be created. The Interface Repository associated with the CORBA object
identified by the scopingObject parameter defines the repository within which the ID will be resolved.
The following rules apply to CreateTypeById:
• If the scopingObject parameter does not point to a valid Automation View Interface, then CreateObject returns the HRESULT DISP_E_UNKNOWNINTERFACE.
• If the repositoryID parameter does not identify a valid type in the Interface Repository associated with the scopingObject parameter, then CreateObject returns the HRESULT TYPE_E_UNDEFINEDTYPE.
19.8.8.1 ITypeFactory Interface
The DICORBAFactoryExinterface delegates its CreateType and CreateTypeByID methods to an ITypeFactory interface on the scoping
object. ITypeFactory is defined as a COM interface because it is not intended to be exposed to Automation controllers. Every
Automation View object must support the ITypeFactory interface:
//MIDLinterface ITypeFactory: IUnknown {
HRESULT CreateType([in] LPWSTR typeName, [out] VARIANT *val);HRESULT CreateTypeById( [in] RepositoryId repositoryID,[out] VARIANT *val);}
The UUID for ITypeFactory is:
{A8B553C6-3B72-11cf-BBFC-444553540000}
The methods on ITypeFactory provide the behaviors previously described for the corresponding DICORBAFactoryEx methods.
19.8.8.2 DIObjectInfo Interface
The DIObjectInfo interface provides helper functions for retrieving information about a composite data type (such as a union,
structure, exception, …), which is held as an IDispatch pointer.
// ODL[odl, dual, uuid(...)]interface DIObjectInfo: DICORBAFactoryEx{
HRESULT type_name([in] IDispatch *target,[out, optional] VARIANT *except_obj,[out, retval] BSTR *typeName);
HRESULT scoped_name( [in] IDispatch *target,[out, optional] VARIANT *except_obj,[out, retval] BSTR *repositoryId);
HRESULT unique_id([in] IDispatch *target,[out, optional] VARIANT *except_obj,[out, retval] BSTR *repositoryId);
}
The UUID for DIObjectInfo is:
{6dd1b940-21a0-11d1-9d47-00a024a73e4f}
This interface can also be implemented as generic (nondual) Automation Interface, in which case it is named DObjectInfo and
its UUID is:
{8fbbf980-21a0-11d1-9d47-00a024a73e4f}
The Automation object having the ProgId “CORBA.Factory? exposes DIObjectInfo.