00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #include "OW_config.h"
00037 #include "OW_CppSimpleAssociatorProviderIFC.hpp"
00038 #include "OW_CIMInstance.hpp"
00039 #include "OW_CIMClass.hpp"
00040 #include "OW_CIMObjectPath.hpp"
00041 #include "OW_CIMProperty.hpp"
00042 #include "OW_CIMValue.hpp"
00043 #include "OW_CIMNameSpace.hpp"
00044 #include "OW_ResultHandlerIFC.hpp"
00045 #include "OW_CIMOMHandleIFC.hpp"
00046
00047
00048 namespace OW_NAMESPACE
00049 {
00050 namespace
00051 {
00052 class AssocHelperResultHandlerIFC : public CIMInstanceResultHandlerIFC
00053 {
00054 public:
00055 AssocHelperResultHandlerIFC(const CIMObjectPath& objectName,
00056 const String& resultClass, const String& role,
00057 const String& resultRole)
00058 : _objectName(objectName)
00059 , _resultClass(resultClass)
00060 , _role(role)
00061 , _resultRole(resultRole) {}
00062 void doHandle(const CIMInstance& inst)
00063 {
00064 if (_resultRole.length() > 0)
00065 {
00066 CIMProperty prop = inst.getProperty(_resultRole);
00067
00068 if (prop)
00069 {
00070 CIMObjectPath cop;
00071 prop.getValue().get(cop);
00072 assocAuxHandler(cop);
00073 }
00074 }
00075 else
00076 {
00077 CIMPropertyArray cpa = inst.getProperties();
00078 for (CIMPropertyArray::const_iterator iter = cpa.begin();
00079 iter < cpa.end(); ++iter)
00080 {
00081 CIMDataType dt = iter->getDataType();
00082 if (!dt.isReferenceType())
00083 {
00084 continue;
00085 }
00086 String propName = iter->getName();
00087 if (_role == propName)
00088 {
00089 continue;
00090 }
00091 CIMObjectPath cop;
00092 iter->getValue().get(cop);
00093 if (cop != _objectName)
00094 {
00095 assocAuxHandler(cop);
00096 }
00097 }
00098 }
00099 }
00100 protected:
00101 virtual void assocAuxHandler(const CIMObjectPath& cop) = 0;
00102 private:
00103 CIMObjectPath _objectName;
00104 String _resultClass;
00105 String _role;
00106 String _resultRole;
00107 };
00108
00109
00111 class _RHAssociators : public AssocHelperResultHandlerIFC
00112 {
00113 public:
00114 _RHAssociators(CIMInstanceResultHandlerIFC& result,
00115 const CIMObjectPath& objectName,
00116 const String& resultClass,
00117 const String& role,
00118 const String& resultRole,
00119 const CIMOMHandleIFCRef& lch,
00120 WBEMFlags:: EIncludeQualifiersFlag includeQualifiers,
00121 WBEMFlags:: EIncludeClassOriginFlag includeClassOrigin,
00122 const StringArray *propertyList)
00123 : AssocHelperResultHandlerIFC(objectName,resultClass ,role ,resultRole)
00124 , _realHandler(result)
00125 , _lch(lch)
00126 , _includeQualifiers(includeQualifiers)
00127 , _includeClassOrigin(includeClassOrigin)
00128 , _propertyList(propertyList)
00129 {}
00130 protected:
00131 virtual void assocAuxHandler(const CIMObjectPath &cop)
00132 {
00133 CIMInstance inst = _lch->getInstance(cop.getFullNameSpace().getNameSpace(),
00134 cop, WBEMFlags::E_NOT_LOCAL_ONLY,
00135 _includeQualifiers, _includeClassOrigin,
00136 _propertyList);
00137 _realHandler.handle(inst);
00138 }
00139 private:
00140 CIMInstanceResultHandlerIFC& _realHandler;
00141 const CIMOMHandleIFCRef& _lch;
00142 WBEMFlags::EIncludeQualifiersFlag _includeQualifiers;
00143 WBEMFlags::EIncludeClassOriginFlag _includeClassOrigin;
00144 const StringArray* _propertyList;
00145 };
00146
00148 class _RHAssociatorNames : public AssocHelperResultHandlerIFC
00149 {
00150 public:
00151 _RHAssociatorNames(CIMObjectPathResultHandlerIFC& result,
00152 const CIMObjectPath& objectName,
00153 const String& resultClass,
00154 const String& role,
00155 const String& resultRole)
00156 : AssocHelperResultHandlerIFC(objectName,resultClass ,role ,resultRole)
00157 , _realHandler(result) { }
00158 protected:
00159 virtual void assocAuxHandler(const CIMObjectPath &cop)
00160 {
00161 _realHandler.handle(cop);
00162 }
00163 private:
00164 CIMObjectPathResultHandlerIFC& _realHandler;
00165 };
00166
00168 class _RHReferences : public CIMInstanceResultHandlerIFC
00169 {
00170 public:
00171 _RHReferences(CIMInstanceResultHandlerIFC& realHandler,
00172 WBEMFlags:: EIncludeQualifiersFlag includeQualifiers,
00173 WBEMFlags:: EIncludeClassOriginFlag includeClassOrigin,
00174 const StringArray *propertyList)
00175 : _realHandler(realHandler)
00176 , _includeQualifiers(includeQualifiers)
00177 , _includeClassOrigin(includeClassOrigin)
00178 , _propertyList(propertyList)
00179 {
00180 }
00181
00182 void doHandle(const CIMInstance& inst)
00183 {
00184 CIMInstance rval = inst.clone(WBEMFlags::E_NOT_LOCAL_ONLY,
00185 _includeQualifiers,
00186 _includeClassOrigin,
00187 _propertyList);
00188 _realHandler.handle(rval);
00189 }
00190 private:
00191 CIMInstanceResultHandlerIFC& _realHandler;
00192 WBEMFlags::EIncludeQualifiersFlag _includeQualifiers;
00193 WBEMFlags::EIncludeClassOriginFlag _includeClassOrigin;
00194 const StringArray* _propertyList;
00195 };
00196
00198 class _RHReferenceNames : public CIMInstanceResultHandlerIFC
00199 {
00200 public:
00201 _RHReferenceNames(CIMObjectPathResultHandlerIFC& realHandler, const String& ns)
00202 : _realHandler(realHandler)
00203 , _ns(ns) {}
00204 void doHandle(const CIMInstance& inst)
00205 {
00206 CIMObjectPath cop(_ns, inst);
00207 _realHandler.handle(cop);
00208 }
00209 private:
00210 CIMObjectPathResultHandlerIFC& _realHandler;
00211 String _ns;
00212 };
00213
00214 }
00215
00300 void
00301 CppSimpleAssociatorProviderIFC::associators(const ProviderEnvironmentIFCRef &env,
00302 CIMInstanceResultHandlerIFC &result,
00303 const String &ns,
00304 const CIMObjectPath &objectName,
00305 const String &assocClass,
00306 const String &resultClass,
00307 const String &role,
00308 const String &resultRole,
00309 WBEMFlags:: EIncludeQualifiersFlag includeQualifiers,
00310 WBEMFlags:: EIncludeClassOriginFlag includeClassOrigin,
00311 const StringArray *propertyList)
00312 {
00313
00314 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00315 CIMClass theAssocClass = lch->getClass(ns, assocClass);
00316 _RHAssociators rh(result, objectName, resultClass, role, resultRole,
00317 lch, includeQualifiers, includeClassOrigin, propertyList);
00318
00319 doReferences(env, rh, ns, objectName, theAssocClass, resultClass,
00320 role, resultRole);
00321 }
00338 void
00339 CppSimpleAssociatorProviderIFC::associatorNames(const ProviderEnvironmentIFCRef &env,
00340 CIMObjectPathResultHandlerIFC &result,
00341 const String &ns,
00342 const CIMObjectPath &objectName,
00343 const String &assocClass,
00344 const String &resultClass,
00345 const String &role,
00346 const String &resultRole)
00347 {
00348
00349
00350 _RHAssociatorNames rh(result, objectName, resultClass, role, resultRole);
00351
00352 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00353 CIMClass theAssocClass = lch->getClass(ns, assocClass);
00354
00355 doReferences(env, rh, ns, objectName, theAssocClass, resultClass,
00356 role, resultRole);
00357 }
00358
00389 void
00390 CppSimpleAssociatorProviderIFC::references(const ProviderEnvironmentIFCRef
00391 &env, CIMInstanceResultHandlerIFC &result,
00392 const String &ns,
00393 const CIMObjectPath &objectName,
00394 const String &resultClass,
00395 const String &role,
00396 WBEMFlags:: EIncludeQualifiersFlag includeQualifiers,
00397 WBEMFlags:: EIncludeClassOriginFlag includeClassOrigin,
00398 const StringArray *propertyList)
00399 {
00400
00401 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00402 CIMClass theAssocClass = lch->getClass(ns, resultClass,
00403 WBEMFlags::E_NOT_LOCAL_ONLY,
00404 includeQualifiers,
00405 includeClassOrigin);
00406
00407 _RHReferences rh(result,includeQualifiers ,includeClassOrigin ,propertyList );
00408 doReferences(env, rh, ns, objectName, theAssocClass, "", role, "");
00409 }
00424 void
00425 CppSimpleAssociatorProviderIFC::referenceNames(const ProviderEnvironmentIFCRef &env,
00426 CIMObjectPathResultHandlerIFC &result,
00427 const String &ns,
00428 const CIMObjectPath &objectName,
00429 const String &resultClass,
00430 const String &role)
00431 {
00432
00433 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00434 CIMClass theAssocClass = lch->getClass(ns, resultClass);
00435 _RHReferenceNames rh(result,ns);
00436 doReferences(env, rh,ns ,objectName , theAssocClass,"",role, "");
00437 }
00438
00439 }