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 "OWBI1_SimpleAssociatorProviderIFC.hpp"
00038 #include "OWBI1_CIMInstance.hpp"
00039 #include "OWBI1_CIMClass.hpp"
00040 #include "OWBI1_CIMObjectPath.hpp"
00041 #include "OWBI1_CIMProperty.hpp"
00042 #include "OWBI1_CIMValue.hpp"
00043 #include "OWBI1_CIMNameSpace.hpp"
00044 #include "OWBI1_ResultHandlerIFC.hpp"
00045 #include "OWBI1_CIMOMHandleIFC.hpp"
00046 #include "OWBI1_ProviderEnvironmentIFC.hpp"
00047 #include "OWBI1_CIMPropertyList.hpp"
00048
00049
00050 namespace OWBI1
00051 {
00052 namespace
00053 {
00054 class AssocHelperResultHandlerIFC : public CIMInstanceResultHandlerIFC
00055 {
00056 public:
00057 AssocHelperResultHandlerIFC(const CIMObjectPath& objectName,
00058 const CIMName& resultClass, const CIMName& role,
00059 const CIMName& resultRole)
00060 : _objectName(objectName)
00061 , _resultClass(resultClass)
00062 , _role(role)
00063 , _resultRole(resultRole)
00064 {
00065 }
00066 void doHandle(const CIMInstance& inst)
00067 {
00068 if (_resultRole != "")
00069 {
00070 CIMProperty prop = inst.getProperty(_resultRole);
00071
00072 if (prop)
00073 {
00074 CIMObjectPath cop;
00075 prop.getValue().get(cop);
00076 assocAuxHandler(cop);
00077 }
00078 }
00079 else
00080 {
00081 CIMPropertyArray cpa = inst.getProperties();
00082 for (CIMPropertyArray::const_iterator iter = cpa.begin();
00083 iter < cpa.end(); ++iter)
00084 {
00085 CIMDataType dt = iter->getDataType();
00086 if (!dt.isReferenceType())
00087 {
00088 continue;
00089 }
00090 CIMName propName = iter->getName();
00091 if (_role == propName)
00092 {
00093 continue;
00094 }
00095 CIMObjectPath cop;
00096 iter->getValue().get(cop);
00097 if (cop != _objectName)
00098 {
00099 assocAuxHandler(cop);
00100 }
00101 }
00102 }
00103 }
00104 protected:
00105 virtual void assocAuxHandler(const CIMObjectPath& cop) = 0;
00106 private:
00107 CIMObjectPath _objectName;
00108 CIMName _resultClass;
00109 CIMName _role;
00110 CIMName _resultRole;
00111 };
00112
00113
00115 class _RHAssociators : public AssocHelperResultHandlerIFC
00116 {
00117 public:
00118 _RHAssociators(CIMInstanceResultHandlerIFC& result,
00119 const CIMObjectPath& objectName,
00120 const CIMName& resultClass,
00121 const CIMName& role,
00122 const CIMName& resultRole,
00123 const CIMOMHandleIFCRef& lch,
00124 const CIMPropertyList& propertyList)
00125 : AssocHelperResultHandlerIFC(objectName,resultClass ,role ,resultRole)
00126 , _realHandler(result)
00127 , _lch(lch)
00128 , _propertyList(propertyList)
00129 {
00130 }
00131 protected:
00132 virtual void assocAuxHandler(const CIMObjectPath &cop)
00133 {
00134 CIMInstance inst = _lch->getInstance(cop.getFullNameSpace().getNameSpace(),
00135 cop, _propertyList);
00136 _realHandler.handle(inst);
00137 }
00138 private:
00139 CIMInstanceResultHandlerIFC& _realHandler;
00140 const CIMOMHandleIFCRef& _lch;
00141 const CIMPropertyList _propertyList;
00142 };
00143
00145 class _RHAssociatorNames : public AssocHelperResultHandlerIFC
00146 {
00147 public:
00148 _RHAssociatorNames(CIMObjectPathResultHandlerIFC& result,
00149 const CIMObjectPath& objectName,
00150 const CIMName& resultClass,
00151 const CIMName& role,
00152 const CIMName& resultRole)
00153 : AssocHelperResultHandlerIFC(objectName,resultClass ,role ,resultRole)
00154 , _realHandler(result)
00155 {
00156 }
00157 protected:
00158 virtual void assocAuxHandler(const CIMObjectPath &cop)
00159 {
00160 _realHandler.handle(cop);
00161 }
00162 private:
00163 CIMObjectPathResultHandlerIFC& _realHandler;
00164 };
00165
00167 class _RHReferences : public CIMInstanceResultHandlerIFC
00168 {
00169 public:
00170 _RHReferences(CIMInstanceResultHandlerIFC& realHandler,
00171 const CIMPropertyList& propertyList)
00172 : _realHandler(realHandler)
00173 , _propertyList(propertyList)
00174 {
00175 }
00176
00177 void doHandle(const CIMInstance& inst)
00178 {
00179 CIMInstance rval = inst.clone(_propertyList);
00180 _realHandler.handle(rval);
00181 }
00182 private:
00183 CIMInstanceResultHandlerIFC& _realHandler;
00184 const CIMPropertyList _propertyList;
00185 };
00186
00188 class _RHReferenceNames : public CIMInstanceResultHandlerIFC
00189 {
00190 public:
00191 _RHReferenceNames(CIMObjectPathResultHandlerIFC& realHandler, const String& ns)
00192 : _realHandler(realHandler)
00193 , _ns(ns)
00194 {
00195 }
00196 void doHandle(const CIMInstance& inst)
00197 {
00198 CIMObjectPath cop(_ns, inst);
00199 _realHandler.handle(cop);
00200 }
00201 private:
00202 CIMObjectPathResultHandlerIFC& _realHandler;
00203 String _ns;
00204 };
00205
00206 }
00207
00208 void
00209 BI1SimpleAssociatorProviderIFC::associators(const ProviderEnvironmentIFCRef &env,
00210 CIMInstanceResultHandlerIFC &result,
00211 const String &ns,
00212 const CIMObjectPath &objectName,
00213 const CIMName &assocClass,
00214 const CIMName &resultClass,
00215 const CIMName &role,
00216 const CIMName &resultRole,
00217 const CIMPropertyList& propertyList)
00218 {
00219
00220 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00221 CIMClass theAssocClass = lch->getClass(ns, assocClass);
00222 _RHAssociators rh(result, objectName, resultClass, role, resultRole,
00223 lch, propertyList);
00224
00225 doReferences(env, rh, ns, objectName, theAssocClass, resultClass,
00226 role, resultRole);
00227 }
00228
00229 void
00230 BI1SimpleAssociatorProviderIFC::associatorNames(const ProviderEnvironmentIFCRef &env,
00231 CIMObjectPathResultHandlerIFC &result,
00232 const String &ns,
00233 const CIMObjectPath &objectName,
00234 const CIMName &assocClass,
00235 const CIMName &resultClass,
00236 const CIMName &role,
00237 const CIMName &resultRole)
00238 {
00239
00240
00241 _RHAssociatorNames rh(result, objectName, resultClass, role, resultRole);
00242
00243 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00244 CIMClass theAssocClass = lch->getClass(ns, assocClass);
00245
00246 doReferences(env, rh, ns, objectName, theAssocClass, resultClass,
00247 role, resultRole);
00248 }
00249
00250 void
00251 BI1SimpleAssociatorProviderIFC::references(const ProviderEnvironmentIFCRef
00252 &env, CIMInstanceResultHandlerIFC &result,
00253 const String &ns,
00254 const CIMObjectPath &objectName,
00255 const CIMName &resultClass,
00256 const CIMName &role,
00257 const CIMPropertyList& propertyList)
00258 {
00259
00260 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00261 CIMClass theAssocClass = lch->getClass(ns, resultClass);
00262
00263 _RHReferences rh(result, propertyList );
00264 doReferences(env, rh, ns, objectName, theAssocClass, "", role, "");
00265 }
00280 void
00281 BI1SimpleAssociatorProviderIFC::referenceNames(const ProviderEnvironmentIFCRef &env,
00282 CIMObjectPathResultHandlerIFC &result,
00283 const String &ns,
00284 const CIMObjectPath &objectName,
00285 const CIMName &resultClass,
00286 const CIMName &role)
00287 {
00288
00289 CIMOMHandleIFCRef lch = env->getCIMOMHandle();
00290 CIMClass theAssocClass = lch->getClass(ns, resultClass);
00291 _RHReferenceNames rh(result,ns);
00292 doReferences(env, rh,ns ,objectName , theAssocClass,"",role, "");
00293 }
00294
00295 }