(file) Return to CMPI_Array.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

  1 schuur 1.1 //%2003////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
  4            // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
  6            // IBM Corp.; EMC Corporation, The Open Group.
  7            //
  8            // Permission is hereby granted, free of charge, to any person obtaining a copy
  9            // of this software and associated documentation files (the "Software"), to
 10            // deal in the Software without restriction, including without limitation the
 11            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 12            // sell copies of the Software, and to permit persons to whom the Software is
 13            // furnished to do so, subject to the following conditions:
 14            //
 15            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 16            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 17            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 18            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 19            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 21            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 22 schuur 1.1 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 23            //
 24            //==============================================================================
 25            //
 26            // Author:      Adrian Schuur, schuur@de.ibm.com
 27            //
 28            // Modified By:
 29            //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32 schuur 1.4 #include "CMPI_Version.h"
 33 schuur 1.1 
 34            #include "CMPI_Object.h"
 35            #include "CMPI_Ftabs.h"
 36            
 37            PEGASUS_USING_STD;
 38            PEGASUS_NAMESPACE_BEGIN
 39            
 40 schuur 1.9 extern "C" {
 41            
 42               static CMPIStatus arrayRelease(CMPIArray* eArray) {
 43               //   cout<<"--- arrayRelease()"<<endl;
 44                  CMPIData *dta=(CMPIData*)eArray->hdl;
 45                  if (dta) {
 46                     delete[] dta;
 47                     ((CMPI_Object*)eArray)->unlinkAndDelete();
 48                  }
 49                  CMReturn(CMPI_RC_OK);
 50 schuur 1.1    }
 51            
 52 schuur 1.9    static CMPIArray* arrayClone(CMPIArray* eArray, CMPIStatus* rc) {
 53                  CMPIData* dta=(CMPIData*)eArray->hdl;
 54                  CMPIData* nDta=new CMPIData[dta->value.uint32+1];
 55                  CMPI_Object* obj=new CMPI_Object(nDta);
 56                  obj->unlink();
 57                  CMPIArray* nArray=(CMPIArray*)obj;
 58                  CMPIStatus rrc={CMPI_RC_OK,NULL};
 59            
 60                  if (dta->type & CMPI_ENC) for (unsigned int i=1; i<=dta->value.uint32; i++)
 61                     nDta[i].state=CMPI_nullValue;
 62            
 63                  for (unsigned int i=0; i<=dta->value.uint32; i++) {
 64                     nDta[i]=dta[i];
 65                     if (dta->type & CMPI_ENC && dta[i].state==CMPI_goodValue) {
 66                        nDta[i].value.string=
 67                        ((CMPIString*)dta[i].value.string)->ft->clone((CMPIString*)dta[i].value.string,&rrc);
 68                  if (rrc.rc) {
 69                           arrayRelease(nArray);
 70                     if (rc) *rc=rrc;
 71                     return NULL;
 72 schuur 1.1       }
 73 schuur 1.9          }
 74                  }
 75                  if (rc) CMSetStatus(rc,CMPI_RC_OK);
 76                  return nArray;
 77 schuur 1.1    }
 78            
 79 schuur 1.9    static CMPIData arrayGetElementAt(CMPIArray* eArray, CMPICount pos, CMPIStatus* rc) {
 80                  CMPIData *dta=(CMPIData*)eArray->hdl;
 81                  if (rc) CMSetStatus(rc,CMPI_RC_OK);
 82                  if (pos<dta->value.uint32) return dta[pos+1];
 83            
 84                  CMPIData data={0,0,{0}};
 85                  if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
 86                  return data;
 87               }
 88 schuur 1.1 
 89 schuur 1.9    CMPIStatus arraySetElementAt(CMPIArray* eArray, CMPICount pos,
 90                                                   CMPIValue *val, CMPIType type) {
 91                  CMPIData *dta=(CMPIData*)eArray->hdl;
 92            
 93                  if (pos<dta->value.uint32) {
 94                     if ((dta->type&~CMPI_ARRAY)==type) {
 95                        dta[pos+1].state=CMPI_goodValue;
 96                        dta[pos+1].value=*val;
 97                        CMReturn(CMPI_RC_OK);
 98                     }
 99 schuur 1.10 	 else {
100             	    char msg[512];
101             	    sprintf(msg,"arraySetElementAt(): CMPI_RC_ERR_TYPE_MISMATCH. Is %p - should be %p",
102                            (void*)(long)type,(void*)(long)dta->type);
103                         CMReturnWithString(CMPI_RC_ERR_TYPE_MISMATCH,
104             	         reinterpret_cast<CMPIString*>(new CMPI_Object(msg)));
105             	 }
106 schuur 1.1        }
107 schuur 1.9        CMReturn(CMPI_RC_ERR_NOT_FOUND);
108                }
109             
110                static CMPICount arrayGetSize(CMPIArray* eArray, CMPIStatus* rc) {
111                   CMPIData *dta=(CMPIData*)eArray->hdl;
112                   if (rc) CMSetStatus(rc,CMPI_RC_OK);
113                   return dta->value.uint32;
114 schuur 1.1     }
115             
116 schuur 1.9     static CMPIType arrayGetType(CMPIArray* eArray, CMPIStatus* rc) {
117                   CMPIData *dta=(CMPIData*)eArray->hdl;
118                   if (rc) CMSetStatus(rc,CMPI_RC_OK);
119                   return dta->type;
120                }
121 schuur 1.1  
122             }
123             
124             static CMPIArrayFT array_FT={
125                  CMPICurrentVersion,
126                  arrayRelease,
127                  arrayClone,
128                  arrayGetSize,
129                  arrayGetType,
130                  arrayGetElementAt,
131                  arraySetElementAt,
132             };
133             
134             CMPIArrayFT *CMPI_Array_Ftab=&array_FT;
135             
136             PEGASUS_NAMESPACE_END
137             
138             
139             
140             

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2