cmpiResult.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  * cmpiResult.cpp
00004  *
00005  * Copyright (c) 2002, International Business Machines
00006  *
00007  * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
00008  * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
00009  * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
00010  *
00011  * You can obtain a current copy of the Common Public License from
00012  * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
00013  *
00014  * Author:        Adrian Schuur <schuur@de.ibm.com>
00015  * 
00016  * Contributor:   Markus Mueller <sedgewick_de@yahoo.de>
00017  *
00018  * Description: CMPIObjectPath support
00019  *
00020  */
00021 
00022 #include <iostream>
00023 #include "cmpisrv.h"
00024 #include "OW_CIMException.hpp"
00025 #include "CmpiProviderBase.h"
00026 
00027 static CMPIStatus resultReturnData(const CMPIResult* eRes, const CMPIValue* data,
00028    const CMPIType type)
00029 {
00030    CMPIrc rc;
00031    OpenWBEM::CIMValue v=value2CIMValue(data,type,&rc);
00032    if(eRes->ft==CMPI_ResultMethOnStack_Ftab)
00033    {
00034       CMPIValueValueResultHandler* res=(CMPIValueValueResultHandler*)eRes->hdl;
00035       if(((CMPI_Result*)eRes)->flags & RESULT_set==0)
00036       {
00037          ((CMPI_Result*)eRes)->flags|=RESULT_set;
00038       }
00039       res->handle(v);
00040    }
00041    else
00042    {
00043       CMPIValueValueResultHandler* res=(CMPIValueValueResultHandler*)eRes->hdl;
00044       if(((CMPI_Result*)eRes)->flags & RESULT_set==0)
00045       {
00046          ((CMPI_Result*)eRes)->flags|=RESULT_set;
00047       }
00048       res->handle(v);
00049    }
00050    CMReturn(CMPI_RC_OK);
00051 }
00052 
00053 static CMPIStatus resultReturnInstance(const CMPIResult* eRes, const CMPIInstance* eInst)
00054 {
00055    OpenWBEM::CIMInstanceResultHandlerIFC * res =
00056       static_cast<OpenWBEM::CIMInstanceResultHandlerIFC *> (eRes->hdl);
00057 // const OpenWBEM::CIMInstance& inst =
00058 //    * (static_cast<OpenWBEM::CIMInstance *>(eInst->hdl));
00059    try
00060    {
00061       CMPIStatus rc;
00062       CMPIContext *ctx=CMPI_ThreadContext::getContext();
00063       CMPIFlags flgs = ctx->ft->getEntry(ctx,const_cast<char*>(CMPIInvocationFlags),&rc).value.uint32;
00064       OpenWBEM::CIMInstance* in = (static_cast<OpenWBEM::CIMInstance *>(eInst->hdl));
00065       OpenWBEM::CIMInstance ci(
00066          in->clone((flgs & CMPI_FLAG_LocalOnly         )? OpenWBEM::WBEMFlags::E_LOCAL_ONLY          : OpenWBEM::WBEMFlags::E_NOT_LOCAL_ONLY,
00067                    (flgs & CMPI_FLAG_IncludeQualifiers )? OpenWBEM::WBEMFlags::E_INCLUDE_QUALIFIERS  : OpenWBEM::WBEMFlags::E_EXCLUDE_QUALIFIERS,
00068                    (flgs & CMPI_FLAG_IncludeClassOrigin)? OpenWBEM::WBEMFlags::E_INCLUDE_CLASS_ORIGIN: OpenWBEM::WBEMFlags::E_EXCLUDE_CLASS_ORIGIN));
00069       res->handle(ci);
00070    }
00071    catch(const OpenWBEM::CIMException& e)
00072    {
00073       //CMReturnWithChars(CmpiProviderBase::getBroker(),
00074       //      (_CMPIrc)e.getErrNo(), e.getMessage());
00075       CMReturn((_CMPIrc)e.getErrNo());
00076    }
00077    catch(...)
00078    {
00079       CMReturn(CMPI_RC_ERROR);
00080    }
00081    CMReturn(CMPI_RC_OK);
00082 }
00083 
00084 static CMPIStatus resultReturnObject(const CMPIResult* eRes, const CMPIInstance* eInst)
00085 {
00086    OpenWBEM::CIMInstanceResultHandlerIFC * res =
00087       static_cast<OpenWBEM::CIMInstanceResultHandlerIFC *> (eRes->hdl);
00088    const OpenWBEM::CIMInstance& inst =
00089       * (static_cast<OpenWBEM::CIMInstance *>(eInst->hdl));
00090 
00091    try
00092    {
00093       //std::cout << "inst to handle " << inst.toMOF() << std::endl;
00094       // TODO - turn instance into object
00095       res->handle(inst);
00096 
00097    }
00098    catch(const OpenWBEM::CIMException& e)
00099    {
00100       CMReturn((_CMPIrc)e.getErrNo());
00101    }
00102    catch(...)
00103    {
00104       CMReturn(CMPI_RC_ERROR);
00105    }
00106    CMReturn(CMPI_RC_OK);
00107 }
00108 
00109 static CMPIStatus resultReturnObjectPath(const CMPIResult* eRes,
00110    const CMPIObjectPath* eRef)
00111 {
00112    OpenWBEM::CIMObjectPathResultHandlerIFC * res =
00113       static_cast<OpenWBEM::CIMObjectPathResultHandlerIFC *>(eRes->hdl);
00114 
00115    const OpenWBEM::CIMObjectPath& cop =
00116       * (static_cast<OpenWBEM::CIMObjectPath *>(eRef->hdl));
00117 
00118    try
00119    {
00120       //std::cout << "cop to handle " << cop.toMOF() << std::endl;
00121       res->handle(cop);
00122    }
00123    catch(const OpenWBEM::CIMException& e)
00124    {
00125       CMReturn((_CMPIrc)e.getErrNo());
00126    }
00127    catch(...)
00128    {
00129       CMReturn(CMPI_RC_ERROR);
00130    }
00131 
00132    CMReturn(CMPI_RC_OK);
00133 }
00134 
00135 static CMPIStatus resultReturnInstDone(const CMPIResult* eRes) 
00136 {
00137    (void) eRes;
00138    CMReturn(CMPI_RC_OK);
00139 }
00140 
00141 static CMPIStatus resultReturnRefDone(const CMPIResult* eRes)
00142 {
00143    (void) eRes;
00144    CMReturn(CMPI_RC_OK);
00145 }
00146 
00147 static CMPIStatus resultReturnDataDone(const CMPIResult* eRes)
00148 {
00149    (void) eRes;
00150    CMReturn(CMPI_RC_OK);
00151 }
00152 
00153 static CMPIStatus resultReturnMethDone(const CMPIResult* eRes)
00154 {
00155    (void) eRes;
00156    CMReturn(CMPI_RC_OK);
00157 }
00158 static CMPIStatus resultReturnObjDone(const CMPIResult* eRes)
00159 {
00160    (void) eRes;
00161    CMReturn(CMPI_RC_OK);
00162 }
00163 
00164 
00165 static CMPIStatus resultBadReturnData(const CMPIResult* eRes,
00166    const CMPIValue* data, CMPIType type)
00167 {
00168    (void) eRes;
00169    (void) data;
00170    (void) type;
00171    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
00172 }
00173 
00174 static CMPIStatus resultBadReturnInstance(const CMPIResult* eRes,
00175    const CMPIInstance* eInst)
00176 {
00177    (void) eRes;
00178    (void) eInst;
00179    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
00180 }
00181 
00182 static CMPIStatus resultBadReturnObjectPath(const CMPIResult* eRes,
00183    const CMPIObjectPath* eRef)
00184 {
00185    (void) eRes;
00186    (void) eRef;
00187    CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
00188 }
00189 
00190 static CMPIResultFT resultMethOnStack_FT={
00191    CMPICurrentVersion,
00192    NULL,
00193    NULL,
00194    resultReturnData,
00195    resultBadReturnInstance,
00196    resultBadReturnObjectPath,
00197    resultReturnMethDone,
00198 };
00199 
00200 static CMPIResultFT resultObjOnStack_FT={
00201    CMPICurrentVersion,
00202    NULL,
00203    NULL,
00204    resultBadReturnData,
00205    resultReturnObject,
00206    resultBadReturnObjectPath,
00207    resultReturnObjDone,
00208 };
00209 
00210 static CMPIResultFT resultData_FT={
00211    CMPICurrentVersion,
00212    NULL,
00213    NULL,
00214    resultReturnData,
00215    resultBadReturnInstance,
00216    resultBadReturnObjectPath,
00217    resultReturnDataDone,
00218 };
00219 
00220 static CMPIResultFT resultInstOnStack_FT={
00221    CMPICurrentVersion,
00222    NULL,
00223    NULL,
00224    resultBadReturnData,
00225    resultReturnInstance,
00226    resultBadReturnObjectPath,
00227    resultReturnInstDone,
00228 };
00229 
00230 static CMPIResultFT resultResponseOnStack_FT={
00231    CMPICurrentVersion,
00232    NULL,
00233    NULL,
00234    resultReturnData,
00235    resultBadReturnInstance,
00236    resultBadReturnObjectPath,
00237    resultReturnDataDone,
00238 };
00239 
00240 static CMPIResultFT resultRefOnStack_FT={
00241    CMPICurrentVersion,
00242    NULL,
00243    NULL,
00244    resultBadReturnData,
00245    resultBadReturnInstance,
00246    resultReturnObjectPath,
00247    resultReturnRefDone,
00248 };
00249 
00250 
00251 CMPIResultFT *CMPI_ResultMeth_Ftab=&resultMethOnStack_FT;
00252 CMPIResultFT *CMPI_ResultData_Ftab=&resultData_FT;
00253 CMPIResultFT *CMPI_ResultMethOnStack_Ftab=&resultMethOnStack_FT;
00254 CMPIResultFT *CMPI_ResultInstOnStack_Ftab=&resultInstOnStack_FT;
00255 CMPIResultFT *CMPI_ResultObjOnStack_Ftab=&resultObjOnStack_FT;
00256 CMPIResultFT *CMPI_ResultRefOnStack_Ftab=&resultRefOnStack_FT;
00257 CMPIResultFT *CMPI_ResultResponseOnStack_Ftab=&resultResponseOnStack_FT;
00258 
00259 
00260 CMPI_ResultOnStack::CMPI_ResultOnStack(
00261    const OpenWBEM::CIMObjectPathResultHandlerIFC & handler)
00262 {
00263    hdl = (void *)(&handler);
00264    ft = CMPI_ResultRefOnStack_Ftab;
00265    flags = RESULT_ObjectPath;
00266 }
00267 
00268 CMPI_ResultOnStack::CMPI_ResultOnStack(
00269    const OpenWBEM::CIMInstanceResultHandlerIFC & handler)
00270 {
00271    hdl = (void *)(&handler);
00272    ft = CMPI_ResultInstOnStack_Ftab;
00273    flags = RESULT_Instance;
00274 }
00275 
00276 #if 0
00277 // ObjectResponseHandler
00278 CMPI_ResultOnStack::CMPI_ResultOnStack(
00279    const OpenWBEM::CIMInstanceResultHandlerIFC & handler)
00280 {
00281    hdl= (void *)(&handler);
00282    ft=CMPI_ResultInstOnStack_Ftab;
00283    flags=RESULT_Instance;
00284 }
00285 
00286 CMPI_ResultOnStack::CMPI_ResultOnStack(
00287    const OpenWBEM::MethodResultResultHandlerIFC & handler)
00288 {
00289    hdl= (void *)(&handler);
00290    ft=CMPI_ResultMethOnStack_Ftab;
00291    flags=RESULT_Method;
00292 }
00293 #endif
00294 
00295 CMPI_ResultOnStack::CMPI_ResultOnStack(const
00296    CMPIObjectPathValueResultHandler& handler)
00297 {
00298    hdl = (void *)&handler;
00299    ft = CMPI_ResultResponseOnStack_Ftab;
00300    flags = RESULT_Response;
00301 }
00302 
00303 CMPI_ResultOnStack::CMPI_ResultOnStack(
00304    const CMPIValueValueResultHandler& handler)
00305 {
00306    hdl = (void *)&handler;
00307    ft = CMPI_ResultResponseOnStack_Ftab;
00308    flags = RESULT_Response;
00309 }
00310 
00311 CMPI_ResultOnStack::CMPI_ResultOnStack()
00312 {
00313    //hdl= static_cast<void* >(&handler);
00314    ft=CMPI_ResultResponseOnStack_Ftab;
00315    flags=RESULT_Response;
00316 }
00317 
00318 CMPI_ResultOnStack::~CMPI_ResultOnStack()
00319 {
00320    //std::cout << "--- ~CMPI_ResultOnStack()" << std::endl;
00321    //if (flags & RESULT_set==0)  ((ResponseHandler*)hdl)->processing();
00322    //if (flags & RESULT_done==0) ((ResponseHandler*)hdl)->complete();
00323 }
00324 

Generated on Thu Feb 9 08:47:49 2006 for openwbem by  doxygen 1.4.6