MOF Embedded Objects

[This is preliminary documentation and subject to change.]

MOF supports the use of objects fully embedded in class or instance declarations. Objects in this context refer to instances of another class. These objects can be declared as strongly typed or weakly typed, depending on whether a class name or the keyword Object is used with the declaration. Both types map to the VT_UNKNOWN type. The following class declaration illustrates how to declare strongly and weakly typed embedded objects:

class MyClass
{
    EmbedClass    Object1;          // strong typed
    object            Object2;          // weakly typed
}

The following examples show how to declare embedded objects within a class declaration:

class Class1 
{ 
     [key] sint32 Class1Index;
};

class Class2 
{
    [key] sint32 Class2Index;
    Class1 EmbedObject1 = instance of Class1{Class1Index = 3;};
};

class Class3
{
    [key] sint32 Class3Index;
    Class2 EmbedObject2 = instance of Class2 {Class2Index = 4;};

};

An embedded object can be an alias only if that object is a reference:

Instance of MyClass as $A
{
    intval = 33;
}

Instance of AnotherClass2
{
    intval = 34;
    EmbeddedObject = $A;      
}
 

To initialize an embedded object, use the syntax for declaring an instance:

Instance of AnotherClass
{
    intval = 33;
    EmbeddedObject = instance of MyClass { intval = 99; }
}

Arrays of embedded objects are permitted. Because arrays can be weakly typed, they can be heterogeneous:

Instance of SomeClass
{
    ObArray = { instance of MyClass {intval = 33; }, 
      instance of YourClass { stringval = "Hello"; } };
}
 

Explicit use of NULL for the default value of embedded objects and paths is allowed, both for initializers and declarations.