version 1.1.2.2, 2007/10/02 17:27:10
|
version 1.1.2.3, 2007/10/03 22:45:52
|
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
static const size_t _MAX_FEATURES = 1024; |
|
static const size_t _MAX_QUALIFIERS = 1024; | static const size_t _MAX_QUALIFIERS = 1024; |
| |
static bool _eqi(const char* s1, const char* s2) | static bool _eqi(const char* s1, const char* s2) |
|
|
} | } |
| |
default: | default: |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
} | } |
| |
default: | default: |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
| |
// Unreachable! | // Unreachable! |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
struct FeatureInfo |
int MergeFeatures( |
{ |
|
const MetaFeature* mf; |
|
const MetaClass* mc; |
|
}; |
|
|
|
static int _mergeFeatures( |
|
const MetaClass* mc, | const MetaClass* mc, |
bool localOnly, | bool localOnly, |
FeatureInfo features[_MAX_FEATURES], |
Uint32 flags, |
|
MetaFeatureInfo features[META_MAX_FEATURES], |
size_t& numFeatures) | size_t& numFeatures) |
{ | { |
if (!localOnly && mc->super) | if (!localOnly && mc->super) |
{ | { |
if (_mergeFeatures(mc->super, localOnly, features, numFeatures) != 0) |
if (MergeFeatures( |
|
mc->super, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
const MetaFeature* mf = mc->features[i]; | const MetaFeature* mf = mc->features[i]; |
| |
|
if (!(mf->flags & flags)) |
|
continue; |
|
|
// Override feature if defined by ancestor class: | // Override feature if defined by ancestor class: |
| |
bool found = false; | bool found = false; |
|
|
| |
if (!found) | if (!found) |
{ | { |
if (numFeatures == _MAX_FEATURES) |
if (numFeatures == META_MAX_FEATURES) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
{ | { |
if (numQualifiers == _MAX_QUALIFIERS) | if (numQualifiers == _MAX_QUALIFIERS) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
if (_mergeQualifiers( | if (_mergeQualifiers( |
ns, mc, featureName, parameterName, 0, qualifiers, numQualifiers) != 0) | ns, mc, featureName, parameterName, 0, qualifiers, numQualifiers) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
| |
if (_makeValue(cv, qd->type, qd->subscript, q + 1) != 0) | if (_makeValue(cv, qd->type, qd->subscript, q + 1) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
| |
if (_makeValue(cv, mp->type, mp->subscript, mp->value) != 0) | if (_makeValue(cv, mp->type, mp->subscript, mp->value) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
{ | { |
if (_addQualifiers(ns, mc, mp->name, 0, cp) != 0) | if (_addQualifiers(ns, mc, mp->name, 0, cp) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
if (_addQualifiers(ns, mc, mr->name, 0, cp) != 0) | if (_addQualifiers(ns, mc, mr->name, 0, cp) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
if (_addQualifiers(ns, mc, mm->name, mp->name, cm) != 0) | if (_addQualifiers(ns, mc, mm->name, mp->name, cm) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
if (_addQualifiers(ns, mc, mm->name, mr->name, cm) != 0) | if (_addQualifiers(ns, mc, mm->name, mr->name, cm) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
if (_addQualifiers(ns, mc, mm->name, 0, cm) != 0) | if (_addQualifiers(ns, mc, mm->name, 0, cm) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
{ | { |
// Merge features from all inheritance levels into a single array: | // Merge features from all inheritance levels into a single array: |
| |
FeatureInfo features[_MAX_FEATURES]; |
MetaFeatureInfo features[META_MAX_FEATURES]; |
size_t numFeatures = 0; | size_t numFeatures = 0; |
| |
if (_mergeFeatures(mc, localOnly, features, numFeatures) != 0) |
if (MergeFeatures(mc, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
| |
for (size_t i = 0; i < numFeatures; i++) | for (size_t i = 0; i < numFeatures; i++) |
{ | { |
const FeatureInfo& fi = features[i]; |
const MetaFeatureInfo& fi = features[i]; |
| |
// Set propagated flag: | // Set propagated flag: |
| |
|
|
if (_addProperty(ns, mc, mp, classOrigin, propagated, | if (_addProperty(ns, mc, mp, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
if (_addReference(ns, mc, mr, classOrigin, propagated, | if (_addReference(ns, mc, mr, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
if (_addMethod(ns, mc, mm, classOrigin, propagated, | if (_addMethod(ns, mc, mm, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
} | } |
| |
int MakeClass( | int MakeClass( |
|
const char* hostName, |
const MetaNameSpace* ns, | const MetaNameSpace* ns, |
const MetaClass* mc, | const MetaClass* mc, |
Boolean localOnly, | Boolean localOnly, |
|
|
{ | { |
if (_addQualifiers(ns, mc, 0, 0, cc) != 0) | if (_addQualifiers(ns, mc, 0, 0, cc) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
} | } |
|
|
if (_addFeatures(ns, mc, localOnly, includeQualifiers, | if (_addFeatures(ns, mc, localOnly, includeQualifiers, |
includeClassOrigin, propertyList, cc) != 0) | includeClassOrigin, propertyList, cc) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
|
|
|
// Object path: |
|
|
|
cc.setPath(CIMObjectPath(hostName, ns->name, mc->name)); |
} | } |
catch (Exception& e) | catch (Exception& e) |
{ | { |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
| |
if (_makeValue(cv, mqd->type, mqd->subscript, mqd->value) != 0) | if (_makeValue(cv, mqd->type, mqd->subscript, mqd->value) != 0) |
{ | { |
printf("T[%u]\n", __LINE__); |
|
return -1; | return -1; |
} | } |
| |
|
|
return 0; | return 0; |
} | } |
| |
|
const MetaClass* FindClass(const MetaNameSpace* ns, const char* name) |
|
{ |
|
for (size_t i = 0; ns->classes[i]; i++) |
|
{ |
|
const MetaClass* mc = ns->classes[i]; |
|
|
|
if (_eqi(mc->name, name)) |
|
return mc; |
|
} |
|
|
|
// Not found! |
|
return 0; |
|
} |
|
|
|
const MetaQualifierDecl* FindQualifierDecl( |
|
const MetaNameSpace* ns, |
|
const char* name) |
|
{ |
|
for (size_t i = 0; ns->classes[i]; i++) |
|
{ |
|
const MetaQualifierDecl* mqd = ns->qualifiers[i]; |
|
|
|
if (_eqi(mqd->name, name)) |
|
return mqd; |
|
} |
|
|
|
// Not found! |
|
return 0; |
|
} |
|
|
|
bool IsSubClass(const MetaClass* super, const MetaClass* sub) |
|
{ |
|
if (!super) |
|
return true; |
|
|
|
for (MetaClass* p = sub->super; p; p = p->super) |
|
{ |
|
if (p == super) |
|
return true; |
|
} |
|
|
|
return false; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |