version 1.1.2.1, 2007/11/08 23:20:50
|
version 1.1.2.2, 2007/11/08 23:29:55
|
|
|
} | } |
| |
int MergeFeatures( | int MergeFeatures( |
const SchemaClass* mc, |
const SchemaClass* sc, |
bool localOnly, | bool localOnly, |
Uint32 flags, | Uint32 flags, |
SchemaFeatureInfo features[SCHEMA_MAX_FEATURES], | SchemaFeatureInfo features[SCHEMA_MAX_FEATURES], |
size_t& numFeatures) | size_t& numFeatures) |
{ | { |
if (!localOnly && mc->super) |
if (!localOnly && sc->super) |
{ | { |
if (MergeFeatures( | if (MergeFeatures( |
mc->super, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
sc->super, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
// Process all features of this class: | // Process all features of this class: |
| |
for (size_t i = 0; mc->features[i]; i++) |
for (size_t i = 0; sc->features[i]; i++) |
{ | { |
const SchemaFeature* mf = mc->features[i]; |
const SchemaFeature* sf = sc->features[i]; |
| |
if (!(mf->flags & flags)) |
if (!(sf->flags & flags)) |
continue; | continue; |
| |
// Override feature if defined by ancestor class: | // Override feature if defined by ancestor class: |
|
|
| |
for (size_t j = 0; j < numFeatures; j++) | for (size_t j = 0; j < numFeatures; j++) |
{ | { |
const SchemaFeature* tmp = features[j].mf; |
const SchemaFeature* tmp = features[j].sf; |
| |
if (_eqi(mf->name, tmp->name)) |
if (_eqi(sf->name, tmp->name)) |
{ | { |
features[j].mf = mf; |
features[j].sf = sf; |
features[j].mc = mc; |
features[j].sc = sc; |
found = true; | found = true; |
break; | break; |
} | } |
|
|
return -1; | return -1; |
} | } |
| |
features[numFeatures].mf = mf; |
features[numFeatures].sf = sf; |
features[numFeatures].mc = mc; |
features[numFeatures].sc = sc; |
numFeatures++; | numFeatures++; |
} | } |
} | } |
|
|
struct QualifierInfo | struct QualifierInfo |
{ | { |
const char* qualifier; | const char* qualifier; |
const SchemaClass* mc; |
const SchemaClass* sc; |
}; | }; |
| |
static const SchemaFeature* _findFeature( | static const SchemaFeature* _findFeature( |
const SchemaClass* mc, |
const SchemaClass* sc, |
const char* name) | const char* name) |
{ | { |
for (size_t i = 0; mc->features[i]; i++) |
for (size_t i = 0; sc->features[i]; i++) |
{ | { |
const SchemaFeature* mf = mc->features[i]; |
const SchemaFeature* sf = sc->features[i]; |
| |
if (_eqi(mf->name, name)) |
if (_eqi(sf->name, name)) |
return mf; |
return sf; |
} | } |
| |
// Not found! | // Not found! |
|
|
} | } |
| |
static const SchemaFeature* _findParameter( | static const SchemaFeature* _findParameter( |
const SchemaMethod* mm, |
const SchemaMethod* sm, |
const char* name) | const char* name) |
{ | { |
for (size_t i = 0; mm->parameters[i]; i++) |
for (size_t i = 0; sm->parameters[i]; i++) |
{ | { |
const SchemaFeature* mf = mm->parameters[i]; |
const SchemaFeature* sf = sm->parameters[i]; |
| |
if (_eqi(mm->name, name)) |
if (_eqi(sm->name, name)) |
return mf; |
return sf; |
} | } |
| |
// Not found! | // Not found! |
|
|
| |
static int _mergeQualifiers( | static int _mergeQualifiers( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const char* featureName, | const char* featureName, |
const char* parameterName, | const char* parameterName, |
bool depth, | bool depth, |
|
|
{ | { |
// Merge super-class qualifiers: | // Merge super-class qualifiers: |
| |
if (mc->super) |
if (sc->super) |
{ | { |
_mergeQualifiers(ns, mc->super, featureName, parameterName, depth + 1, |
_mergeQualifiers(ns, sc->super, featureName, parameterName, depth + 1, |
qualifiers, numQualifiers); | qualifiers, numQualifiers); |
} | } |
| |
|
|
if (!featureName && !parameterName) | if (!featureName && !parameterName) |
{ | { |
// Case 1: get class qualifiers: | // Case 1: get class qualifiers: |
quals = mc->qualifiers; |
quals = sc->qualifiers; |
} | } |
else if (featureName && !parameterName) | else if (featureName && !parameterName) |
{ | { |
// Case 2: get feature qualifiers: | // Case 2: get feature qualifiers: |
| |
const SchemaFeature* mf = _findFeature(mc, featureName); |
const SchemaFeature* sf = _findFeature(sc, featureName); |
| |
if (mf) |
if (sf) |
quals = mf->qualifiers; |
quals = sf->qualifiers; |
} | } |
else if (featureName && parameterName) | else if (featureName && parameterName) |
{ | { |
// Case 3: get parameter qualifiers: | // Case 3: get parameter qualifiers: |
| |
const SchemaFeature* mf = _findFeature(mc, featureName); |
const SchemaFeature* sf = _findFeature(sc, featureName); |
| |
if (mf && (mf->flags & SCHEMA_FLAG_METHOD)) |
if (sf && (sf->flags & SCHEMA_FLAG_METHOD)) |
{ | { |
const SchemaMethod* mm = (const SchemaMethod*)mf; |
const SchemaMethod* sm = (const SchemaMethod*)sf; |
const SchemaFeature* p = _findParameter(mm, parameterName); |
const SchemaFeature* p = _findParameter(sm, parameterName); |
| |
if (p) | if (p) |
quals = p->qualifiers; | quals = p->qualifiers; |
|
|
if (qi[0] == qj[0]) | if (qi[0] == qj[0]) |
{ | { |
qualifiers[j].qualifier = qi; | qualifiers[j].qualifier = qi; |
qualifiers[j].mc = mc; |
qualifiers[j].sc = sc; |
found = true; | found = true; |
break; | break; |
} | } |
|
|
} | } |
| |
qualifiers[numQualifiers].qualifier = qi; | qualifiers[numQualifiers].qualifier = qi; |
qualifiers[numQualifiers].mc = mc; |
qualifiers[numQualifiers].sc = sc; |
numQualifiers++; | numQualifiers++; |
} | } |
} | } |
|
|
template<class C> | template<class C> |
static int _addQualifiers( | static int _addQualifiers( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const char* featureName, | const char* featureName, |
const char* parameterName, | const char* parameterName, |
C& c) | C& c) |
|
|
size_t numQualifiers = 0; | size_t numQualifiers = 0; |
| |
if (_mergeQualifiers( | if (_mergeQualifiers( |
ns, mc, featureName, parameterName, 0, qualifiers, numQualifiers) != 0) |
ns, sc, featureName, parameterName, 0, qualifiers, numQualifiers) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addProperty( | static int _addProperty( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const SchemaProperty* mp, |
const SchemaProperty* sp, |
const char* classOrigin, | const char* classOrigin, |
bool propagated, | bool propagated, |
bool includeQualifiers, | bool includeQualifiers, |
|
|
| |
CIMValue cv; | CIMValue cv; |
| |
if (_makeValue(cv, mp->type, mp->subscript, mp->value) != 0) |
if (_makeValue(cv, sp->type, sp->subscript, sp->value) != 0) |
{ | { |
return -1; | return -1; |
} | } |
| |
// Create property: | // Create property: |
| |
CIMProperty cp(mp->name, cv); |
CIMProperty cp(sp->name, cv); |
| |
if (includeClassOrigin) | if (includeClassOrigin) |
cp.setClassOrigin(classOrigin); | cp.setClassOrigin(classOrigin); |
|
|
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, mp->name, 0, cp) != 0) |
if (_addQualifiers(ns, sc, sp->name, 0, cp) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addReference( | static int _addReference( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const SchemaReference* mr, |
const SchemaReference* sr, |
const char* classOrigin, | const char* classOrigin, |
bool propagated, | bool propagated, |
bool includeQualifiers, | bool includeQualifiers, |
|
|
Boolean isArray; | Boolean isArray; |
Uint32 arraySize; | Uint32 arraySize; |
| |
if (mr->subscript == -1) |
if (sr->subscript == -1) |
{ | { |
isArray = false; | isArray = false; |
arraySize = 0; | arraySize = 0; |
|
|
else | else |
{ | { |
isArray = true; | isArray = true; |
arraySize = mr->subscript; |
arraySize = sr->subscript; |
} | } |
| |
// Set referenceClassName: | // Set referenceClassName: |
| |
CIMName rcn = mr->ref->name; |
CIMName rcn = sr->ref->name; |
| |
// Create value: | // Create value: |
| |
|
|
| |
// Create property: | // Create property: |
| |
CIMProperty cp(mr->name, cv, arraySize, rcn); |
CIMProperty cp(sr->name, cv, arraySize, rcn); |
| |
if (includeClassOrigin) | if (includeClassOrigin) |
cp.setClassOrigin(classOrigin); | cp.setClassOrigin(classOrigin); |
|
|
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, mr->name, 0, cp) != 0) |
if (_addQualifiers(ns, sc, sr->name, 0, cp) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addPropertyParameter( | static int _addPropertyParameter( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const SchemaMethod* mm, |
const SchemaMethod* sm, |
const SchemaProperty* mp, |
const SchemaProperty* sp, |
bool includeQualifiers, | bool includeQualifiers, |
CIMMethod& cm) | CIMMethod& cm) |
{ | { |
|
|
bool isArray; | bool isArray; |
Uint32 arraySize; | Uint32 arraySize; |
| |
if (mp->subscript == -1) |
if (sp->subscript == -1) |
{ | { |
isArray = false; | isArray = false; |
arraySize = 0; | arraySize = 0; |
|
|
else | else |
{ | { |
isArray = true; | isArray = true; |
arraySize = Uint32(mp->subscript); |
arraySize = Uint32(sp->subscript); |
} | } |
| |
CIMParameter cp(mp->name, CIMType(mp->type), isArray, arraySize); |
CIMParameter cp(sp->name, CIMType(sp->type), isArray, arraySize); |
| |
// Add qualifiers: | // Add qualifiers: |
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, mm->name, mp->name, cm) != 0) |
if (_addQualifiers(ns, sc, sm->name, sp->name, cm) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addReferenceParameter( | static int _addReferenceParameter( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const SchemaMethod* mm, |
const SchemaMethod* sm, |
const SchemaReference* mr, |
const SchemaReference* sr, |
bool includeQualifiers, | bool includeQualifiers, |
CIMMethod& cm) | CIMMethod& cm) |
{ | { |
|
|
bool isArray; | bool isArray; |
Uint32 arraySize; | Uint32 arraySize; |
| |
if (mr->subscript == -1) |
if (sr->subscript == -1) |
{ | { |
isArray = false; | isArray = false; |
arraySize = 0; | arraySize = 0; |
|
|
else | else |
{ | { |
isArray = true; | isArray = true; |
arraySize = Uint32(mr->subscript); |
arraySize = Uint32(sr->subscript); |
} | } |
| |
CIMName rcn = mr->ref->name; |
CIMName rcn = sr->ref->name; |
CIMParameter cp(mr->name, CIMTYPE_REFERENCE, isArray, arraySize, rcn); |
CIMParameter cp(sr->name, CIMTYPE_REFERENCE, isArray, arraySize, rcn); |
| |
// Add qualifiers: | // Add qualifiers: |
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, mm->name, mr->name, cm) != 0) |
if (_addQualifiers(ns, sc, sm->name, sr->name, cm) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addMethod( | static int _addMethod( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
const SchemaMethod* mm, |
const SchemaMethod* sm, |
const char* classOrigin, | const char* classOrigin, |
bool propagated, | bool propagated, |
bool includeQualifiers, | bool includeQualifiers, |
|
|
{ | { |
// Create method: | // Create method: |
| |
CIMMethod cm(mm->name, CIMType(mm->type)); |
CIMMethod cm(sm->name, CIMType(sm->type)); |
| |
if (includeClassOrigin) | if (includeClassOrigin) |
cm.setClassOrigin(classOrigin); | cm.setClassOrigin(classOrigin); |
|
|
| |
// Add parameters: | // Add parameters: |
| |
for (size_t i = 0; mm->parameters[i]; i++) |
for (size_t i = 0; sm->parameters[i]; i++) |
{ | { |
SchemaFeature* mf = mm->parameters[i]; |
SchemaFeature* sf = sm->parameters[i]; |
| |
if (mf->flags & SCHEMA_FLAG_PROPERTY) |
if (sf->flags & SCHEMA_FLAG_PROPERTY) |
{ | { |
SchemaProperty* mp = (SchemaProperty*)mf; |
SchemaProperty* sp = (SchemaProperty*)sf; |
_addPropertyParameter(ns, mc, mm, mp, includeQualifiers, cm); |
_addPropertyParameter(ns, sc, sm, sp, includeQualifiers, cm); |
} | } |
else if (mf->flags & SCHEMA_FLAG_REFERENCE) |
else if (sf->flags & SCHEMA_FLAG_REFERENCE) |
{ | { |
SchemaReference* mr = (SchemaReference*)mf; |
SchemaReference* sr = (SchemaReference*)sf; |
_addReferenceParameter(ns, mc, mm, mr, includeQualifiers, cm); |
_addReferenceParameter(ns, sc, sm, sr, includeQualifiers, cm); |
} | } |
} | } |
| |
|
|
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, mm->name, 0, cm) != 0) |
if (_addQualifiers(ns, sc, sm->name, 0, cm) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
static int _addFeatures( | static int _addFeatures( |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
bool localOnly, | bool localOnly, |
bool includeQualifiers, | bool includeQualifiers, |
bool includeClassOrigin, | bool includeClassOrigin, |
|
|
SchemaFeatureInfo features[SCHEMA_MAX_FEATURES]; | SchemaFeatureInfo features[SCHEMA_MAX_FEATURES]; |
size_t numFeatures = 0; | size_t numFeatures = 0; |
| |
if (MergeFeatures(mc, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
if (MergeFeatures(sc, localOnly, 0xFFFFFFFF, features, numFeatures) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
// Set propagated flag: | // Set propagated flag: |
| |
bool propagated = fi.mc != mc; |
bool propagated = fi.sc != sc; |
| |
// Set classOrigin: | // Set classOrigin: |
| |
const char* classOrigin = fi.mc->name; |
const char* classOrigin = fi.sc->name; |
| |
// Skip feature not in property list: | // Skip feature not in property list: |
| |
const SchemaFeature* mf = fi.mf; |
const SchemaFeature* sf = fi.sf; |
| |
if (propertyList && !_hasProperty(propertyList, mf->name)) |
if (propertyList && !_hasProperty(propertyList, sf->name)) |
continue; | continue; |
| |
// Add the feature: | // Add the feature: |
| |
if (mf->flags & SCHEMA_FLAG_PROPERTY) |
if (sf->flags & SCHEMA_FLAG_PROPERTY) |
{ | { |
SchemaProperty* mp = (SchemaProperty*)mf; |
SchemaProperty* sp = (SchemaProperty*)sf; |
| |
if (_addProperty(ns, mc, mp, classOrigin, propagated, |
if (_addProperty(ns, sc, sp, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
return -1; | return -1; |
} | } |
} | } |
else if (mf->flags & SCHEMA_FLAG_REFERENCE) |
else if (sf->flags & SCHEMA_FLAG_REFERENCE) |
{ | { |
SchemaReference* mr = (SchemaReference*)mf; |
SchemaReference* sr = (SchemaReference*)sf; |
| |
if (_addReference(ns, mc, mr, classOrigin, propagated, |
if (_addReference(ns, sc, sr, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
return -1; | return -1; |
} | } |
} | } |
else if (mf->flags & SCHEMA_FLAG_METHOD) |
else if (sf->flags & SCHEMA_FLAG_METHOD) |
{ | { |
SchemaMethod* mm = (SchemaMethod*)mf; |
SchemaMethod* sm = (SchemaMethod*)sf; |
| |
if (_addMethod(ns, mc, mm, classOrigin, propagated, |
if (_addMethod(ns, sc, sm, classOrigin, propagated, |
includeQualifiers, includeClassOrigin, cc) != 0) | includeQualifiers, includeClassOrigin, cc) != 0) |
{ | { |
return -1; | return -1; |
|
|
int MakeClass( | int MakeClass( |
const char* hostName, | const char* hostName, |
const SchemaNameSpace* ns, | const SchemaNameSpace* ns, |
const SchemaClass* mc, |
const SchemaClass* sc, |
Boolean localOnly, | Boolean localOnly, |
Boolean includeQualifiers, | Boolean includeQualifiers, |
Boolean includeClassOrigin, | Boolean includeClassOrigin, |
|
|
{ | { |
CIMName scn; | CIMName scn; |
| |
if (mc->super) |
if (sc->super) |
scn = mc->super->name; |
scn = sc->super->name; |
| |
cc = CIMClass(mc->name, scn); |
cc = CIMClass(sc->name, scn); |
} | } |
| |
// Add qualifiers: | // Add qualifiers: |
| |
if (includeQualifiers) | if (includeQualifiers) |
{ | { |
if (_addQualifiers(ns, mc, 0, 0, cc) != 0) |
if (_addQualifiers(ns, sc, 0, 0, cc) != 0) |
{ | { |
return -1; | return -1; |
} | } |
|
|
| |
// Features: | // Features: |
| |
if (_addFeatures(ns, mc, localOnly, includeQualifiers, |
if (_addFeatures(ns, sc, localOnly, includeQualifiers, |
includeClassOrigin, propertyList, cc) != 0) | includeClassOrigin, propertyList, cc) != 0) |
{ | { |
return -1; | return -1; |
|
|
| |
// Object path: | // Object path: |
| |
cc.setPath(CIMObjectPath(hostName, ns->name, mc->name)); |
cc.setPath(CIMObjectPath(hostName, ns->name, sc->name)); |
} | } |
catch (Exception& e) | catch (Exception& e) |
{ | { |
|
|
{ | { |
for (size_t i = 0; ns->classes[i]; i++) | for (size_t i = 0; ns->classes[i]; i++) |
{ | { |
const SchemaClass* mc = ns->classes[i]; |
const SchemaClass* sc = ns->classes[i]; |
| |
if (_eqi(mc->name, name)) |
if (_eqi(sc->name, name)) |
return mc; |
return sc; |
} | } |
| |
// Not found! | // Not found! |
|
|
} | } |
| |
const SchemaFeature* FindFeature( | const SchemaFeature* FindFeature( |
const SchemaClass* mc, |
const SchemaClass* sc, |
const char* name, | const char* name, |
Uint32 flags) | Uint32 flags) |
{ | { |
for (size_t i = 0; mc->features[i]; i++) |
for (size_t i = 0; sc->features[i]; i++) |
{ | { |
const SchemaFeature* mf = mc->features[i]; |
const SchemaFeature* sf = sc->features[i]; |
| |
if (mf->flags & flags && _eqi(mf->name, name)) |
if (sf->flags & flags && _eqi(sf->name, name)) |
return mf; |
return sf; |
} | } |
| |
// Not found! | // Not found! |