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
00035 #include "OW_config.h"
00036 #include "OW_CppSimpleInstanceProviderIFC.hpp"
00037 #include "OW_CIMObjectPath.hpp"
00038 #include "OW_CIMInstance.hpp"
00039 #include "OW_CIMException.hpp"
00040 #include "OW_ResultHandlerIFC.hpp"
00041
00042 namespace OW_NAMESPACE
00043 {
00044
00045 using namespace WBEMFlags;
00046 namespace {
00047 OW_DECLARE_EXCEPTION(FoundTheInst);
00048 OW_DEFINE_EXCEPTION(FoundTheInst);
00050 class GetInstanceHandler : public CIMInstanceResultHandlerIFC
00051 {
00052 public:
00053 GetInstanceHandler(const CIMObjectPath& instanceName, CIMInstance& theInst)
00054 : m_instanceName(instanceName)
00055 , m_theInst(theInst)
00056 {
00057 }
00058 void doHandle(const CIMInstance& inst)
00059 {
00060 if (CIMObjectPath(m_instanceName.getNameSpace(), inst) == m_instanceName)
00061 {
00062 m_theInst = inst;
00063 OW_THROW(FoundTheInstException, "");
00064 }
00065 }
00066 private:
00067 CIMObjectPath m_instanceName;
00068 CIMInstance& m_theInst;
00069 };
00070 }
00072 CIMInstance
00073 CppSimpleInstanceProviderIFC::getInstance(
00074 const ProviderEnvironmentIFCRef &env,
00075 const String &ns,
00076 const CIMObjectPath &instanceName,
00077 ELocalOnlyFlag localOnly,
00078 EIncludeQualifiersFlag includeQualifiers,
00079 EIncludeClassOriginFlag includeClassOrigin,
00080 const StringArray *propertyList,
00081 const CIMClass &cimClass)
00082 {
00083 CIMInstance theInst(CIMNULL);
00084 GetInstanceHandler handler(instanceName, theInst);
00085
00086
00087
00088 try
00089 {
00090 this->doSimpleEnumInstances(env,ns,cimClass,handler, E_ALL_PROPERTIES);
00091 }
00092 catch (const FoundTheInstException&)
00093 {
00094 return theInst.clone(localOnly, includeQualifiers, includeClassOrigin, propertyList);
00095 }
00096 OW_THROWCIMMSG(CIMException::NOT_FOUND, instanceName.toString().c_str());
00097 }
00098 namespace {
00100 class EnumInstanceNamesHandler : public CIMInstanceResultHandlerIFC
00101 {
00102 public:
00103 EnumInstanceNamesHandler(CIMObjectPathResultHandlerIFC &result,
00104 const String& ns)
00105 : m_result(result)
00106 , m_ns(ns)
00107 {
00108 }
00109 void doHandle(const CIMInstance& inst)
00110 {
00111 m_result.handle(CIMObjectPath(m_ns, inst));
00112 }
00113 private:
00114 CIMObjectPathResultHandlerIFC& m_result;
00115 String m_ns;
00116 };
00117 }
00119 void
00120 CppSimpleInstanceProviderIFC::enumInstanceNames(
00121 const ProviderEnvironmentIFCRef &env,
00122 const String &ns,
00123 const String &className,
00124 CIMObjectPathResultHandlerIFC &result,
00125 const CIMClass &cimClass)
00126 {
00127 EnumInstanceNamesHandler handler(result, ns);
00128 this->doSimpleEnumInstances(env,ns,cimClass,handler, E_KEY_PROPERTIES_ONLY);
00129 }
00130 namespace {
00132 class EnumInstancesHandler : public CIMInstanceResultHandlerIFC
00133 {
00134 public:
00135 EnumInstancesHandler(CIMInstanceResultHandlerIFC &result,
00136 ELocalOnlyFlag localOnly_,
00137 EDeepFlag deep_,
00138 EIncludeQualifiersFlag includeQualifiers_,
00139 EIncludeClassOriginFlag includeClassOrigin_,
00140 const StringArray *propertyList_,
00141 const CIMClass &requestedClass_,
00142 const CIMClass &cimClass_)
00143 : m_result(result)
00144 , localOnly(localOnly_)
00145 , deep(deep_)
00146 , includeQualifiers(includeQualifiers_)
00147 , includeClassOrigin(includeClassOrigin_)
00148 , propertyList(propertyList_)
00149 , requestedClass(requestedClass_)
00150 , cimClass(cimClass_)
00151 {
00152 }
00153 void doHandle(const CIMInstance& inst)
00154 {
00155 m_result.handle(inst.clone(localOnly, deep, includeQualifiers,
00156 includeClassOrigin, propertyList, requestedClass,
00157 cimClass));
00158 }
00159 private:
00160 CIMInstanceResultHandlerIFC& m_result;
00161 ELocalOnlyFlag localOnly;
00162 EDeepFlag deep;
00163 EIncludeQualifiersFlag includeQualifiers;
00164 EIncludeClassOriginFlag includeClassOrigin;
00165 const StringArray *propertyList;
00166 const CIMClass &requestedClass;
00167 const CIMClass &cimClass;
00168 };
00169 }
00171 void
00172 CppSimpleInstanceProviderIFC::enumInstances(
00173 const ProviderEnvironmentIFCRef &env,
00174 const String &ns,
00175 const String &className,
00176 CIMInstanceResultHandlerIFC &result,
00177 ELocalOnlyFlag localOnly,
00178 EDeepFlag deep,
00179 EIncludeQualifiersFlag includeQualifiers,
00180 EIncludeClassOriginFlag includeClassOrigin,
00181 const StringArray *propertyList,
00182 const CIMClass &requestedClass,
00183 const CIMClass &cimClass)
00184 {
00185 EnumInstancesHandler handler(result, localOnly, deep, includeQualifiers,
00186 includeClassOrigin, propertyList, requestedClass, cimClass);
00187 this->doSimpleEnumInstances(env,ns,cimClass,handler, E_ALL_PROPERTIES);
00188 }
00189
00190 }
00191