Creating a New Instance from Old Properties
A join view class contains properties from source class instances that are connected by a common property value, such as Class1.Prop1 = Class2.Prop2. Each instance in a join view class consists of parts of different class instances.
You can base a join view class on inequality of property values, such as Class1.Prop1 <> Class2.Prop2 where Prop1 and Prop2 are not mapped to the same property in the view class.
A join view class is helpful when the information you are looking for is contained in separate but related classes. For example, if you want information about a printer and about the printer configuration, you can create a join view class that contains some of the properties of the Win32_Printer class and some of the properties of the Win32_PrinterConfiguration class. Without the View Provider, you must retrieve and merge the properties of the separate instances to get the information you need.
The following procedure describes how to create a join view class.
To create a join view class
Begin a class definition with the JoinOn string qualifier.
The JoinOn, Association, and Union qualifiers are mutually exclusive.
If necessary, filter the instances that you want in the join class by applying the PostJoinFilter qualifier.
The PostJoinFilter provider allows you to restrict the instances of a view class to instances that meet specific conditions.
Create the queries that define source instances of the view class with the ViewSources qualifier.
Define the names and locations of the namespaces where the source instances are located with the ViewSpaces qualifier.
Define the properties that you want in a join view class with the PropertySources qualifier.
When properties are added to the join view based on equality, the two source properties must be mapped in one PropertySources qualifier.
The following code example shows two properties that are mapped in one PropertySources qualifier.
[PropertySources{"IDProcess", "IDProcess"}] Uint32 ProcessID;
By using the HiddenDefault qualifier, you can tag the properties that belong to a source class.
The following code example shows a join view class created from the Performance Monitor provider classes Win32_PerfRawData_PerfProc_Process and Win32_PerfRawData_PerfProc_Thread with properties of both classes joined by the ProcessID property.
#pragma namespace("\\\\.\\root\\cimv2")
instance of __Win32Provider as $DataProv
{
Name = "MS_VIEW_INSTANCE_PROVIDER";
ClsId = "{AA70DDF4-E11C-11D1-ABB0-00C04FD9159E}";
ImpersonationLevel = 1;
PerUserInitialization = "True";
};
instance of __InstanceProviderRegistration
{
Provider = $DataProv;
SupportsPut = True;
SupportsGet = True;
SupportsDelete = True;
SupportsEnumeration = True;
QuerySupportLevels = {"WQL:UnarySelect"};
};
[JoinOn("Win32_PerfRawData_PerfProc_Process.IDProcess =
Win32_PerfRawData_PerfProc_Thread.IDProcess"),
ViewSources{"SELECT Name, IDProcess, PriorityBase
FROM Win32_PerfRawData_PerfProc_Process",
"SELECT Name, IDProcess, ThreadState,
PriorityCurrent FROM Win32_PerfRawData_PerfProc_Thread"},
ViewSpaces{"\\\\.\\root\\cimv2", "\\\\.\\root\\cimv2"},
dynamic: ToInstance, provider("MS_VIEW_INSTANCE_PROVIDER")]
class JoinedProcessThread
{
[PropertySources{"IDProcess", "IDProcess"}]
Uint32 ProcessID;
[PropertySources{"Name", ""}]
String PName;
[PropertySources{"", "Name"}, key]
String TName;
[PropertySources{"", "ThreadState"}]
Uint32 State;
[PropertySources{"PriorityBase", ""}]
Uint32 BasePriority;
[PropertySources{"", "PriorityCurrent"}]
Uint32 CurrentPriority;
};