cmpiEnumeration.cpp

Go to the documentation of this file.
00001 
00002 /*
00003  *
00004  * cmpiEnumeration.cpp
00005  *
00006  * (C) Copyright IBM Corp. 2003
00007  *
00008  * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
00009  * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
00010  * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
00011  *
00012  * You can obtain a current copy of the Common Public License from
00013  * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
00014  *
00015  * Author:        Adrian Schuur <schuur@de.ibm.com>
00016  * 
00017  * Contributor:   Markus Mueller <sedgewick_de@yahoo.de>
00018  *
00019  * Description: CMPIEnumeration support
00020  *
00021  */
00022 
00023 #include "cmpisrv.h"
00024 
00025 static CMPIStatus enumRelease(CMPIEnumeration* eEnum)
00026 {
00027    if (eEnum->hdl)
00028    {
00029       if ((void*)eEnum->ft==(void*)CMPI_OpEnumeration_Ftab) 
00030          delete (OpenWBEM::Array<OpenWBEM::CIMObjectPath>*)eEnum->hdl;
00031       else
00032          delete (OpenWBEM::Array<OpenWBEM::CIMInstance>*)eEnum->hdl;
00033 
00034       ((CMPI_Object*)eEnum)->unlinkAndDelete();
00035    }
00036    CMReturn(CMPI_RC_OK);
00037 }
00038 
00039 //static CMPIStatus enumReleaseNop(CMPIEnumeration* eEnum) {
00040 //   CMReturn(CMPI_RC_OK);
00041 //}
00042 
00043 static CMPIEnumeration* enumClone(const CMPIEnumeration* eEnum, CMPIStatus* rc)
00044 {
00045    (void)eEnum; (void)rc;
00046 //   CIMInstance* enm=(CIMInstance*)eEnum->hdl;
00047 //   CIMInstance* cInst=new CIMInstance(enum->clone());
00048 //   CMPIEnumeration* neEnum=(CMPIEnumeration*)new CMPI_Object(cInst,CMPI_Instance_Ftab);
00049 //   CMSetStatus(rc,CMPI_RC_OK);
00050 //   return neEnum;
00051    return NULL;
00052 }
00053 
00054 CMPIData enumGetNext(const CMPIEnumeration* eEnum, CMPIStatus* rc)
00055 {
00056    CMPIData data={0,0,{0}};
00057    if ((void*)eEnum->ft==(void*)CMPI_ObjEnumeration_Ftab)
00058    {
00059       CMPI_ObjEnumeration* ie=(CMPI_ObjEnumeration*)eEnum;
00060       data.type=CMPI_instance;
00061       OpenWBEM::Array<OpenWBEM::CIMInstance>* ia=(OpenWBEM::Array<OpenWBEM::CIMInstance>*)ie->hdl;
00062       if (ie->cursor<ie->max)
00063       {
00064          data.value.inst=(CMPIInstance*)
00065          new CMPI_Object(new OpenWBEM::CIMInstance((*ia)[ie->cursor++]));
00066          CMSetStatus(rc,CMPI_RC_OK);
00067       }
00068       else
00069       {
00070          CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00071       }
00072    }
00073 
00074    else if ((void*)eEnum->ft==(void*)CMPI_InstEnumeration_Ftab)
00075    {
00076       CMPI_InstEnumeration* ie=(CMPI_InstEnumeration*)eEnum;
00077       data.type=CMPI_instance;
00078       OpenWBEM::Array<OpenWBEM::CIMInstance>* ia=(OpenWBEM::Array<OpenWBEM::CIMInstance>*)ie->hdl;
00079       if (ie->cursor<ie->max)
00080       {
00081          data.value.inst=(CMPIInstance*)
00082          new CMPI_Object(new OpenWBEM::CIMInstance((*ia)[ie->cursor++]));
00083          CMSetStatus(rc,CMPI_RC_OK);
00084       }
00085       else
00086       {
00087          CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00088       }
00089    }
00090 
00091    else
00092    {
00093       CMPI_OpEnumeration* oe=(CMPI_OpEnumeration*)eEnum;
00094       data.type=CMPI_ref;
00095       OpenWBEM::Array<OpenWBEM::CIMObjectPath>* opa=(OpenWBEM::Array<OpenWBEM::CIMObjectPath>*)oe->hdl;
00096       if (oe->cursor<oe->max)
00097       {
00098          data.value.ref=(CMPIObjectPath*)
00099          new CMPI_Object(new OpenWBEM::CIMObjectPath((*opa)[oe->cursor++]));
00100          CMSetStatus(rc,CMPI_RC_OK);
00101       }
00102       else
00103       {
00104          CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00105       }
00106    }
00107    return data;
00108 }
00109 
00110 CMPIBoolean enumHasNext(const CMPIEnumeration* eEnum, CMPIStatus* rc)
00111 {
00112    CMSetStatus(rc,CMPI_RC_OK);
00113    if ((void*)eEnum->ft==(void*)CMPI_ObjEnumeration_Ftab)
00114    {
00115       CMPI_ObjEnumeration* ie=(CMPI_ObjEnumeration*)eEnum;
00116       if (ie->cursor<ie->max) return true;
00117    }
00118    else if ((void*)eEnum->ft==(void*)CMPI_InstEnumeration_Ftab)
00119    {
00120       CMPI_InstEnumeration* ie=(CMPI_InstEnumeration*)eEnum;
00121       if (ie->cursor<ie->max) return true;
00122    }
00123    else
00124    {
00125       CMPI_OpEnumeration* oe=(CMPI_OpEnumeration*)eEnum;
00126       if (oe->cursor<oe->max) return true;
00127    }
00128    return false;
00129 }
00130 
00131 CMPIArray* enumToArray(const CMPIEnumeration* eEnum, CMPIStatus* rc)
00132 {
00133    (void)eEnum; (void)rc;
00134    return NULL;
00135 }
00136 
00137 
00138 static CMPIEnumerationFT objEnumeration_FT={
00139    CMPICurrentVersion,
00140    enumRelease,
00141    enumClone,
00142    enumGetNext,
00143    enumHasNext,
00144    enumToArray,
00145 };
00146 
00147 static CMPIEnumerationFT instEnumeration_FT={
00148    CMPICurrentVersion,
00149    enumRelease,
00150    enumClone,
00151    enumGetNext,
00152    enumHasNext,
00153    enumToArray,
00154 };
00155 
00156 static CMPIEnumerationFT opEnumeration_FT={
00157    CMPICurrentVersion,
00158    enumRelease,
00159    enumClone,
00160    enumGetNext,
00161    enumHasNext,
00162    enumToArray,
00163 };
00164 
00165 CMPIEnumerationFT *CMPI_ObjEnumeration_Ftab=&objEnumeration_FT;
00166 CMPIEnumerationFT *CMPI_InstEnumeration_Ftab=&instEnumeration_FT;
00167 CMPIEnumerationFT *CMPI_OpEnumeration_Ftab=&opEnumeration_FT;
00168 
00169 CMPI_ObjEnumeration::CMPI_ObjEnumeration(OpenWBEM::Array<OpenWBEM::CIMInstance>* oa)
00170 {
00171    CMPI_ThreadContext::addObject((CMPI_Object*)(this));
00172    cursor=0;
00173    max=oa->size();
00174    hdl=(void*)oa;
00175    ft=CMPI_ObjEnumeration_Ftab;
00176 }
00177 CMPI_InstEnumeration::CMPI_InstEnumeration(OpenWBEM::Array<OpenWBEM::CIMInstance>* ia)
00178 {
00179    CMPI_ThreadContext::addObject((CMPI_Object*)(this));
00180    cursor=0;
00181    max=ia->size();
00182    hdl=(void*)ia;
00183    ft=CMPI_InstEnumeration_Ftab;
00184 }
00185 
00186 CMPI_OpEnumeration::CMPI_OpEnumeration(OpenWBEM::Array<OpenWBEM::CIMObjectPath>* opa)
00187 {
00188    CMPI_ThreadContext::addObject((CMPI_Object*)(this));
00189    cursor=0;
00190    max=opa->size();
00191    hdl=(void*)opa;
00192    ft=CMPI_OpEnumeration_Ftab;
00193 }
00194 
00195 
00196 

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