version 1.7.6.1, 2013/06/03 22:36:27
|
version 1.7.6.2, 2014/03/12 22:35:05
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
/** |
|
* This file redefines the CIMRepository.h interfaces to be a |
|
* read-only memory-resident class repository and an in-memory instance |
|
* repository. It implements all functions of the |
|
* CIMRepository.h interface. All class functions that would |
|
* modify the repository return exceptions since the repository is read-only. |
|
* Functions that return data (ex. getClass, enumerateClasses, etc.) return |
|
* the same form of data as the other repository implementations. |
|
* |
|
* NOTE: This repository does NOT implement a cache because it |
|
* appeared that it would be of little gain since the movement |
|
* of data from the in-memory repository is already fast. |
|
* Therefore there are some parameters of the API (Ex clone) |
|
* that are not implemented. |
|
* |
|
* The class repository is actually a .CPP/.h file that is |
|
* produced by the MOF compiler from input mof files. This file |
|
* includes the definition of all namespaces, qualifiers, and |
|
* classes defined as part of the mof input. |
|
* |
|
* The instance repository is an in-memory repository that |
|
* includes functions to load the instance repository on startup |
|
* and checkpoint the instance repository each time a change is |
|
* made |
|
* |
|
* See PEP 307 for more information on the implementation and |
|
* usage of the memory-resident repository. |
|
*/ |
|
|
#include "MRR.h" | #include "MRR.h" |
#include <cstdarg> | #include <cstdarg> |
#include <Pegasus/Common/Resolver.h> | #include <Pegasus/Common/Resolver.h> |
|
|
@return true if the property is in the list otherwise false. | @return true if the property is in the list otherwise false. |
*/ | */ |
static Boolean _containsProperty( | static Boolean _containsProperty( |
CIMProperty& property, |
const CIMProperty& property, |
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
// For each property in the propertly list | // For each property in the propertly list |
for (Uint32 p=0; p<propertyList.size(); p++) | for (Uint32 p=0; p<propertyList.size(); p++) |
{ | { |
if (propertyList[p].equal(property.getName())) | if (propertyList[p].equal(property.getName())) |
|
{ |
return true; | return true; |
} | } |
|
} |
return false; | return false; |
} | } |
| |
|
|
// remove qualifiers of the class | // remove qualifiers of the class |
Uint32 count = 0; | Uint32 count = 0; |
while ((count = cimClass.getQualifierCount()) > 0) | while ((count = cimClass.getQualifierCount()) > 0) |
|
{ |
cimClass.removeQualifier(count - 1); | cimClass.removeQualifier(count - 1); |
|
} |
| |
// remove qualifiers from the properties | // remove qualifiers from the properties |
for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++) | for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++) |
|
|
CIMProperty p = cimClass.getProperty(i); | CIMProperty p = cimClass.getProperty(i); |
count = 0; | count = 0; |
while ((count = p.getQualifierCount()) > 0) | while ((count = p.getQualifierCount()) > 0) |
|
{ |
p.removeQualifier(count - 1); | p.removeQualifier(count - 1); |
} | } |
|
} |
| |
// remove qualifiers from the methods | // remove qualifiers from the methods |
for (Uint32 i = 0; i < cimClass.getMethodCount(); i++) | for (Uint32 i = 0; i < cimClass.getMethodCount(); i++) |
|
|
CIMParameter p = m.getParameter(j); | CIMParameter p = m.getParameter(j); |
count = 0; | count = 0; |
while ((count = p.getQualifierCount()) > 0) | while ((count = p.getQualifierCount()) > 0) |
|
{ |
p.removeQualifier(count - 1); | p.removeQualifier(count - 1); |
} | } |
|
} |
count = 0; | count = 0; |
while ((count = m.getQualifierCount()) > 0) | while ((count = m.getQualifierCount()) > 0) |
|
{ |
m.removeQualifier(count - 1); | m.removeQualifier(count - 1); |
} | } |
} | } |
|
} |
| |
///////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////// |
// | // |
|
|
// Since the propertyList is not NULL, only properties in the list | // Since the propertyList is not NULL, only properties in the list |
// should be included in the instance. | // should be included in the instance. |
if (!_containsProperty(cimInstance.getProperty(i), propertyList)) | if (!_containsProperty(cimInstance.getProperty(i), propertyList)) |
|
{ |
cimInstance.removeProperty(i); | cimInstance.removeProperty(i); |
} | } |
} | } |
} | } |
|
} |
| |
/* remove all Qualifiers from a single CIMInstance. Removes | /* remove all Qualifiers from a single CIMInstance. Removes |
all of the qualifiers from the instance and from properties | all of the qualifiers from the instance and from properties |
|
|
// remove qualifiers from the instance | // remove qualifiers from the instance |
Uint32 count = 0; | Uint32 count = 0; |
while ((count = cimInstance.getQualifierCount()) > 0) | while ((count = cimInstance.getQualifierCount()) > 0) |
|
{ |
cimInstance.removeQualifier(count - 1); | cimInstance.removeQualifier(count - 1); |
|
} |
| |
// remove qualifiers from the properties | // remove qualifiers from the properties |
for (Uint32 i = 0; i < cimInstance.getPropertyCount(); i++) | for (Uint32 i = 0; i < cimInstance.getPropertyCount(); i++) |
|
|
CIMProperty p = cimInstance.getProperty(i); | CIMProperty p = cimInstance.getProperty(i); |
count = 0; | count = 0; |
while ((count = p.getQualifierCount()) > 0) | while ((count = p.getQualifierCount()) > 0) |
|
{ |
p.removeQualifier(count - 1); | p.removeQualifier(count - 1); |
} | } |
} | } |
|
} |
| |
/* removes all ClassOrigin attributes from a single CIMInstance. Removes | /* removes all ClassOrigin attributes from a single CIMInstance. Removes |
the classOrigin attribute from each property in the Instance. | the classOrigin attribute from each property in the Instance. |
|
|
| |
Uint32 propertyCount = cimInstance.getPropertyCount(); | Uint32 propertyCount = cimInstance.getPropertyCount(); |
for (Uint32 i = 0; i < propertyCount ; i++) | for (Uint32 i = 0; i < propertyCount ; i++) |
|
{ |
cimInstance.getProperty(i).setClassOrigin(CIMName()); | cimInstance.getProperty(i).setClassOrigin(CIMName()); |
} | } |
|
} |
| |
/* Filters the properties, qualifiers, and classorigin out of a single instance. | /* Filters the properties, qualifiers, and classorigin out of a single instance. |
Based on the parameters provided for propertyList, includeQualifiers, | Based on the parameters provided for propertyList, includeQualifiers, |
|
|
| |
Uint32 propertyCount = cimClass.getPropertyCount(); | Uint32 propertyCount = cimClass.getPropertyCount(); |
for (Uint32 i = 0; i < propertyCount ; i++) | for (Uint32 i = 0; i < propertyCount ; i++) |
|
{ |
cimClass.getProperty(i).setClassOrigin(CIMName()); | cimClass.getProperty(i).setClassOrigin(CIMName()); |
|
} |
| |
Uint32 methodCount = cimClass.getMethodCount(); | Uint32 methodCount = cimClass.getMethodCount(); |
for (Uint32 i=0; i < methodCount ; i++) | for (Uint32 i=0; i < methodCount ; i++) |
|
{ |
cimClass.getMethod(i).setClassOrigin(CIMName()); | cimClass.getMethod(i).setClassOrigin(CIMName()); |
} | } |
} | } |
|
} |
| |
| |
static bool _contains(const CIMPropertyList& propertyList, const CIMName& name) | static bool _contains(const CIMPropertyList& propertyList, const CIMName& name) |
|
|
for (Uint32 i = 0; i < propertyList.size(); i++) | for (Uint32 i = 0; i < propertyList.size(); i++) |
{ | { |
if (propertyList[i] == name) | if (propertyList[i] == name) |
|
{ |
return true; | return true; |
} | } |
|
} |
| |
return false; | return false; |
} | } |
|
|
// Add or replace property in result instance: | // Add or replace property in result instance: |
| |
if (pos != PEG_NOT_FOUND) | if (pos != PEG_NOT_FOUND) |
|
{ |
resultInstance.removeProperty(pos); | resultInstance.removeProperty(pos); |
|
} |
| |
resultInstance.addProperty(cp); | resultInstance.addProperty(cp); |
} | } |
|
|
const MRRNameSpace* ns = _nameSpaceTable[i]; | const MRRNameSpace* ns = _nameSpaceTable[i]; |
| |
if (_eqi(ns->name, name)) | if (_eqi(ns->name, name)) |
|
{ |
return ns; | return ns; |
} | } |
|
} |
| |
// Not found! | // Not found! |
return 0; | return 0; |
|
|
static bool _isSubClass(const MRRClass* super, const MRRClass* sub) | static bool _isSubClass(const MRRClass* super, const MRRClass* sub) |
{ | { |
if (!super) | if (!super) |
|
{ |
return true; | return true; |
|
} |
| |
for (MRRClass* p = sub->super; p; p = p->super) | for (MRRClass* p = sub->super; p; p = p->super) |
{ | { |
if (p == super) | if (p == super) |
|
{ |
return true; | return true; |
} | } |
|
} |
| |
return false; | return false; |
} | } |
|
|
static char** _makePropertyList(const CIMPropertyList& propertyList) | static char** _makePropertyList(const CIMPropertyList& propertyList) |
{ | { |
if (propertyList.isNull()) | if (propertyList.isNull()) |
|
{ |
return 0; | return 0; |
|
} |
| |
size_t size = propertyList.size(); | size_t size = propertyList.size(); |
char** pl = (char**)malloc(sizeof(char*) * (size + 1)); | char** pl = (char**)malloc(sizeof(char*) * (size + 1)); |
| |
for (size_t i = 0; i < size; i++) | for (size_t i = 0; i < size; i++) |
|
{ |
pl[i] = strdup(*Str(propertyList[i])); | pl[i] = strdup(*Str(propertyList[i])); |
|
} |
| |
pl[size] = 0; | pl[size] = 0; |
| |
|
|
static void _freePropertyList(char** pl) | static void _freePropertyList(char** pl) |
{ | { |
if (!pl) | if (!pl) |
|
{ |
return; | return; |
|
} |
| |
for (size_t i = 0; pl[i]; i++) | for (size_t i = 0; pl[i]; i++) |
{ | { |
|
|
static void _printPropertyList(const char* const* pl) | static void _printPropertyList(const char* const* pl) |
{ | { |
if (!pl) | if (!pl) |
|
{ |
return; | return; |
|
} |
| |
for (size_t i = 0; pl[i]; i++) | for (size_t i = 0; pl[i]; i++) |
|
{ |
printf("pl[%s]\n", pl[i]); | printf("pl[%s]\n", pl[i]); |
} | } |
|
} |
| |
static bool _contains(const Array<const MRRClass*>& x, const MRRClass* sc) | static bool _contains(const Array<const MRRClass*>& x, const MRRClass* sc) |
{ | { |
|
|
while (n--) | while (n--) |
{ | { |
if (*p++ == sc) | if (*p++ == sc) |
|
{ |
return true; | return true; |
} | } |
|
} |
| |
return false; | return false; |
} | } |
|
|
const MRRClass* sc = FindClass(ns, *Str(className)); | const MRRClass* sc = FindClass(ns, *Str(className)); |
| |
if (!sc) | if (!sc) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); |
|
} |
| |
| |
// Lookup result class (if any). | // Lookup result class (if any). |
|
|
rmc = FindClass(ns, *Str(resultClass)); | rmc = FindClass(ns, *Str(resultClass)); |
| |
if (!rmc) | if (!rmc) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass))); |
} | } |
|
} |
| |
// Convert these to UTF8 now to avoid doing so in loop below. | // Convert these to UTF8 now to avoid doing so in loop below. |
| |
|
|
// Skip non-association classes: | // Skip non-association classes: |
| |
if (!(amc->flags & MRR_FLAG_ASSOCIATION)) | if (!(amc->flags & MRR_FLAG_ASSOCIATION)) |
|
{ |
continue; | continue; |
|
} |
| |
// Filter by assocClass parameter: | // Filter by assocClass parameter: |
| |
if (!assocClass.isNull() && !_eqi(ac, amc->name)) | if (!assocClass.isNull() && !_eqi(ac, amc->name)) |
|
{ |
continue; | continue; |
|
} |
| |
// Process reference properties: | // Process reference properties: |
| |
|
|
// Skip non references: | // Skip non references: |
| |
if (!(sf->flags & MRR_FLAG_REFERENCE)) | if (!(sf->flags & MRR_FLAG_REFERENCE)) |
|
{ |
continue; | continue; |
|
} |
| |
const MRRReference* sr = (const MRRReference*)sf; | const MRRReference* sr = (const MRRReference*)sf; |
| |
// Filter by role parameter. | // Filter by role parameter. |
| |
if (role.size() && !_eqi(r, sf->name)) | if (role.size() && !_eqi(r, sf->name)) |
|
{ |
continue; | continue; |
|
} |
| |
// Filter by source class: | // Filter by source class: |
| |
if (!IsA(sr->ref, sc)) | if (!IsA(sr->ref, sc)) |
|
{ |
continue; | continue; |
|
} |
| |
// Process result reference: | // Process result reference: |
| |
|
|
// Skip the feature under consideration: | // Skip the feature under consideration: |
| |
if (rmf == sf) | if (rmf == sf) |
|
{ |
continue; | continue; |
|
} |
| |
// Skip non references: | // Skip non references: |
| |
if (!(rmf->flags & MRR_FLAG_REFERENCE)) | if (!(rmf->flags & MRR_FLAG_REFERENCE)) |
|
{ |
continue; | continue; |
|
} |
| |
const MRRReference* rmr = (const MRRReference*)rmf; | const MRRReference* rmr = (const MRRReference*)rmf; |
| |
// Filter by resultRole parameter. | // Filter by resultRole parameter. |
| |
if (resultRole.size() && !_eqi(rr, rmf->name)) | if (resultRole.size() && !_eqi(rr, rmf->name)) |
|
{ |
continue; | continue; |
|
} |
| |
// Skip references not of the result class kind: | // Skip references not of the result class kind: |
| |
if (rmc && !IsA(rmr->ref, rmc)) | if (rmc && !IsA(rmr->ref, rmc)) |
|
{ |
continue; | continue; |
|
} |
| |
// ATTN: should we include entire class hierarchy under | // ATTN: should we include entire class hierarchy under |
// result class? | // result class? |
|
|
// If reached, then save this one. | // If reached, then save this one. |
| |
if (!_contains(result, rmr->ref)) | if (!_contains(result, rmr->ref)) |
|
{ |
result.append(rmr->ref); | result.append(rmr->ref); |
} | } |
} | } |
} | } |
} | } |
|
} |
| |
static void _references( | static void _references( |
const MRRNameSpace* ns, | const MRRNameSpace* ns, |
|
|
const MRRClass* sc = FindClass(ns, *Str(className)); | const MRRClass* sc = FindClass(ns, *Str(className)); |
| |
if (!sc) | if (!sc) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); |
|
} |
| |
// Lookup result class (if any). | // Lookup result class (if any). |
| |
|
|
rmc = FindClass(ns, *Str(resultClass)); | rmc = FindClass(ns, *Str(resultClass)); |
| |
if (!rmc) | if (!rmc) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(resultClass))); |
} | } |
|
} |
| |
// Convert these to UTF8 now to avoid doing so in loop below. | // Convert these to UTF8 now to avoid doing so in loop below. |
| |
|
|
// Skip non-association classes: | // Skip non-association classes: |
| |
if (!(amc->flags & MRR_FLAG_ASSOCIATION)) | if (!(amc->flags & MRR_FLAG_ASSOCIATION)) |
|
{ |
continue; | continue; |
|
} |
| |
// Filter by result class: | // Filter by result class: |
| |
if (rmc && !IsA(rmc, amc)) | if (rmc && !IsA(rmc, amc)) |
|
{ |
continue; | continue; |
|
} |
| |
// Process reference properties: | // Process reference properties: |
| |
|
|
// Skip non references: | // Skip non references: |
| |
if (!(sf->flags & MRR_FLAG_REFERENCE)) | if (!(sf->flags & MRR_FLAG_REFERENCE)) |
|
{ |
continue; | continue; |
|
} |
| |
const MRRReference* sr = (const MRRReference*)sf; | const MRRReference* sr = (const MRRReference*)sf; |
| |
// Filter by role parameter. | // Filter by role parameter. |
| |
if (role.size() && !_eqi(r, sf->name)) | if (role.size() && !_eqi(r, sf->name)) |
|
{ |
continue; | continue; |
|
} |
| |
// Filter by source class: | // Filter by source class: |
| |
if (!IsA(sr->ref, sc)) | if (!IsA(sr->ref, sc)) |
|
{ |
continue; | continue; |
|
} |
| |
// Add this one to the output: | // Add this one to the output: |
| |
if (!_contains(result, amc)) | if (!_contains(result, amc)) |
|
{ |
result.append((MRRClass*)amc); | result.append((MRRClass*)amc); |
} | } |
} | } |
} | } |
|
} |
| |
static const MRRClass* _findMRRClass( | static const MRRClass* _findMRRClass( |
const char* nameSpace, | const char* nameSpace, |
|
|
const MRRNameSpace* ns = _findNameSpace(nameSpace); | const MRRNameSpace* ns = _findNameSpace(nameSpace); |
| |
if (!ns) | if (!ns) |
|
{ |
return 0; | return 0; |
|
} |
| |
return FindClass(ns, className); | return FindClass(ns, className); |
} | } |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Lookup class: | // Lookup class: |
| |
|
|
super = FindClass(ns, *Str(className)); | super = FindClass(ns, *Str(className)); |
| |
if (!super) | if (!super) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); |
} | } |
|
} |
| |
// Iterate all classes looking for matches: | // Iterate all classes looking for matches: |
| |
|
|
if (deepInheritance) | if (deepInheritance) |
{ | { |
if (_isSubClass(super, sc)) | if (_isSubClass(super, sc)) |
|
{ |
result.append(sc->name); | result.append(sc->name); |
} | } |
|
} |
else | else |
{ | { |
if (_isDirectSubClass(super, sc)) | if (_isDirectSubClass(super, sc)) |
|
{ |
result.append(sc->name); | result.append(sc->name); |
} | } |
} | } |
|
} |
| |
return result; | return result; |
} | } |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Get associator schema-classes: | // Get associator schema-classes: |
| |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Get associator schema-classes: | // Get associator schema-classes: |
| |
|
|
Array<CIMObjectPath> result; | Array<CIMObjectPath> result; |
| |
for (Uint32 i = 0; i < mcs.size(); i++) | for (Uint32 i = 0; i < mcs.size(); i++) |
|
{ |
result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name)); | result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name)); |
|
} |
| |
return result; | return result; |
} | } |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Get reference schema-classes: | // Get reference schema-classes: |
| |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Get reference schema-classes: | // Get reference schema-classes: |
| |
|
|
Array<CIMObjectPath> result; | Array<CIMObjectPath> result; |
| |
for (Uint32 i = 0; i < mcs.size(); i++) | for (Uint32 i = 0; i < mcs.size(); i++) |
|
{ |
result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name)); | result.append(CIMObjectPath(_getHostName(), nameSpace, mcs[i]->name)); |
|
} |
| |
return result; | return result; |
} | } |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Lookup qualifier: | // Lookup qualifier: |
| |
const MRRQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName)); | const MRRQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName)); |
| |
if (!mqd) | if (!mqd) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, | Throw((CIM_ERR_NOT_FOUND, |
"unknown qualifier: %s", *Str(qualifierName))); | "unknown qualifier: %s", *Str(qualifierName))); |
|
} |
| |
// Make the qualifier declaration: | // Make the qualifier declaration: |
| |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Build the array of qualifier declarations: | // Build the array of qualifier declarations: |
| |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Lookup class: | // Lookup class: |
| |
|
|
// Append superclass names: | // Append superclass names: |
| |
for (const MRRClass* p = sc->super; p; p = p->super) | for (const MRRClass* p = sc->super; p; p = p->super) |
|
{ |
superClassNames.append(p->name); | superClassNames.append(p->name); |
} | } |
|
} |
| |
//============================================================================== | //============================================================================== |
// | // |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Lookup class: | // Lookup class: |
| |
|
|
Uint32 pos = _rep->_findInstance(nameSpace, instanceName); | Uint32 pos = _rep->_findInstance(nameSpace, instanceName); |
| |
if (pos == PEG_NOT_FOUND) | if (pos == PEG_NOT_FOUND) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName))); | Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName))); |
|
} |
| |
CIMInstance cimInstance = _rep->_rep[pos].second.clone(); | CIMInstance cimInstance = _rep->_rep[pos].second.clone(); |
| |
|
|
Uint32 pos = _rep->_findInstance(nameSpace, instanceName); | Uint32 pos = _rep->_findInstance(nameSpace, instanceName); |
| |
if (pos == PEG_NOT_FOUND) | if (pos == PEG_NOT_FOUND) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName))); | Throw((CIM_ERR_NOT_FOUND, "%s", *Str(instanceName))); |
|
} |
| |
_rep->_rep.remove(pos); | _rep->_rep.remove(pos); |
_rep->_processSaveCallback(); | _rep->_processSaveCallback(); |
|
|
// Reject if an instance with this name already exists: | // Reject if an instance with this name already exists: |
| |
if (_rep->_findInstance(nameSpace, cop) != PEG_NOT_FOUND) | if (_rep->_findInstance(nameSpace, cop) != PEG_NOT_FOUND) |
|
{ |
Throw((CIM_ERR_ALREADY_EXISTS, "%s", *Str(cop))); | Throw((CIM_ERR_ALREADY_EXISTS, "%s", *Str(cop))); |
|
} |
| |
// Add instance to array: | // Add instance to array: |
| |
|
|
const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); | const MRRNameSpace* ns = _findNameSpace(*Str(nameSpace)); |
| |
if (!ns) | if (!ns) |
|
{ |
Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); | Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace))); |
|
} |
| |
// Lookup class: | // Lookup class: |
| |
|
|
super = FindClass(ns, *Str(className)); | super = FindClass(ns, *Str(className)); |
| |
if (!super) | if (!super) |
|
{ |
Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); | Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className))); |
} | } |
|
} |
| |
// Iterate all classes looking for matches: | // Iterate all classes looking for matches: |
| |
|
|
for (Uint32 i = 0; i < classNames.size(); i++) | for (Uint32 i = 0; i < classNames.size(); i++) |
{ | { |
Array<CIMInstance> instances = enumerateInstancesForClass( | Array<CIMInstance> instances = enumerateInstancesForClass( |
nameSpace, classNames[i], false, includeQualifiers, |
nameSpace, classNames[i], includeQualifiers, |
includeClassOrigin, propertyList); | includeClassOrigin, propertyList); |
| |
for (Uint32 i = 0 ; i < instances.size(); i++) | for (Uint32 i = 0 ; i < instances.size(); i++) |
|
|
for (Uint32 i = 0; i < _rep->_rep.size(); i++) | for (Uint32 i = 0; i < _rep->_rep.size(); i++) |
{ | { |
if (_rep->_rep[i].first != nameSpace) | if (_rep->_rep[i].first != nameSpace) |
|
{ |
continue; | continue; |
|
} |
| |
CIMInstance& ci = _rep->_rep[i].second; | CIMInstance& ci = _rep->_rep[i].second; |
| |
if (ci.getPath().getClassName() == className) | if (ci.getPath().getClassName() == className) |
|
{ |
result.append(ci.getPath()); | result.append(ci.getPath()); |
} | } |
|
} |
| |
return result; | return result; |
} | } |
|
|
CIMNamespaceName nameSpace; | CIMNamespaceName nameSpace; |
| |
if (MRRDeserializeNameSpace(in, pos, nameSpace) != 0) | if (MRRDeserializeNameSpace(in, pos, nameSpace) != 0) |
|
{ |
return; | return; |
|
} |
| |
CIMInstance cimInstance; | CIMInstance cimInstance; |
| |
if (MRRDeserializeInstance(in, pos, cimInstance) != 0) | if (MRRDeserializeInstance(in, pos, cimInstance) != 0) |
|
{ |
return; | return; |
|
} |
| |
_rep.append(NamespaceInstancePair(nameSpace, cimInstance)); | _rep.append(NamespaceInstancePair(nameSpace, cimInstance)); |
} | } |
|
|
Boolean MRRAddNameSpace(const MRRNameSpace* nameSpace) | Boolean MRRAddNameSpace(const MRRNameSpace* nameSpace) |
{ | { |
if (!nameSpace) | if (!nameSpace) |
|
{ |
return false; | return false; |
|
} |
| |
if (_nameSpaceTableSize == _MAX_NAMESPACE_TABLE_SIZE) | if (_nameSpaceTableSize == _MAX_NAMESPACE_TABLE_SIZE) |
|
{ |
return false; | return false; |
|
} |
| |
if (_findNameSpace(nameSpace->name)) | if (_findNameSpace(nameSpace->name)) |
|
{ |
return false; | return false; |
|
} |
| |
_nameSpaceTable[_nameSpaceTableSize++] = nameSpace; | _nameSpaceTable[_nameSpaceTableSize++] = nameSpace; |
| |
|
|
Boolean localOnly, | Boolean localOnly, |
Boolean includeQualifiers, | Boolean includeQualifiers, |
Boolean includeClassOrigin, | Boolean includeClassOrigin, |
const CIMPropertyList& propertyList) |
const CIMPropertyList& propertyList, |
|
Boolean clone) // Not used by MRR. |
{ | { |
return getClass(nameSpace, className, localOnly, includeQualifiers, | return getClass(nameSpace, className, localOnly, includeQualifiers, |
includeClassOrigin, propertyList); | includeClassOrigin, propertyList); |