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 #ifndef OW_NPI_PROFIDER_IFC_UTILS_HPP_
00031 #define OW_NPI_PROFIDER_IFC_UTILS_HPP_
00032 #include "OW_config.h"
00033 #include "OW_CIMInstance.hpp"
00034 #include "OW_CIMParamValue.hpp"
00035 #include "OW_CIMObjectPath.hpp"
00036 #include "NPIExternal.hpp"
00037
00038 namespace OW_NAMESPACE
00039 {
00040
00041 class NPIVectorFreer
00042 {
00043 public:
00044 NPIVectorFreer(::Vector v) : m_vector(v)
00045 {
00046 }
00047 ~NPIVectorFreer()
00048 {
00049 int n = ::VectorSize(0,m_vector);
00050 for (int i=0; i < n; i++)
00051 {
00052 void * p = ::_VectorGet(0, m_vector, i);
00053 free (p);
00054 }
00055 }
00056 private:
00057 ::Vector m_vector;
00058 };
00059 class NPIHandleFreer
00060 {
00061 public:
00062 NPIHandleFreer(::NPIHandle& h) : m_handle(h)
00063 {
00064
00065 }
00066 ~NPIHandleFreer()
00067 {
00068
00069 UInt32 sz = ((NPIContext *)(m_handle.context))->garbage.size();
00070
00071 for (int i= sz-1; i>=0; i--)
00072 {
00073 NPIGarbageType pgt =
00074 ((NPIContext *)(m_handle.context))->garbageType[i];
00075
00076 void * obj_ptr = ((NPIContext *)(m_handle.context))->garbage[i];
00077 switch (pgt)
00078 {
00079 case VECTOR:
00080 delete(static_cast<charVect *>(obj_ptr));
00081 break;
00082 case CIM_VALUE:
00083 delete(static_cast<CIMValue *>(obj_ptr));
00084 break;
00085 case CIM_QUALIFIER:
00086
00087
00088 break;
00089 case CIM_PARAMVALUE:
00090 delete(static_cast<CIMParamValue *>(obj_ptr));
00091 break;
00092 case CIM_PROPERTY:
00093 delete(static_cast<CIMProperty *>(obj_ptr));
00094 break;
00095 case CIM_INSTANCE:
00096 delete(static_cast<CIMInstance *>(obj_ptr));
00097 break;
00098 case CIM_OBJECTPATH:
00099 delete(static_cast<CIMObjectPath *>(obj_ptr));
00100 break;
00101 case CIM_CLASS:
00102 delete(static_cast<CIMClass *>(obj_ptr));
00103 break;
00104 default:
00105 break;
00106 }
00107 }
00108 ((NPIContext *)(m_handle.context))->garbage.clear();
00109 ((NPIContext *)(m_handle.context))->garbageType.clear();
00110 if (m_handle.providerError != NULL)
00111 {
00112 free(const_cast<void*>(static_cast<const void*>(m_handle.providerError)));
00113 }
00114 }
00115 private:
00116 ::NPIHandle& m_handle;
00117 };
00118
00119 }
00120
00121 #endif