(file) Return to CMPI_ContextArgs.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            #include "CMPI_ContextArgs.h"
 33            #include "CMPI_Ftabs.h"
 34            #include "CMPI_Value.h"
 35            #include "CMPI_String.h"
 36            
 37            PEGASUS_USING_STD;
 38            PEGASUS_NAMESPACE_BEGIN
 39            
 40            // CMPIArgs section
 41            
 42            static CMPIStatus argsRelease(CMPIArgs* eArg) {
 43 schuur 1.1    CMReturn(CMPI_RC_OK);
 44            }
 45            
 46            static CMPIStatus argsReleaseNop(CMPIArgs* eArg) {
 47               CMReturn(CMPI_RC_OK);
 48            }
 49            
 50            static CMPIArgs* argsClone(CMPIArgs* eArg, CMPIStatus* rc) {
 51               Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
 52               Array<CIMParamValue>* cArg=new Array<CIMParamValue>();
 53               for (long i=0,s=arg->size(); i<s; i++) {
 54                  const CIMParamValue &v=(*arg)[i];
 55                  cArg->append(v.clone());
 56               }
 57               CMPIArgs* neArg=(CMPIArgs*)new CMPI_Object(cArg,CMPI_ObjectPath_Ftab);
 58               if (rc) CMSetStatus(rc,CMPI_RC_OK);
 59               return neArg;
 60            }
 61            
 62            static long locateArg(const Array<CIMParamValue> &a, const CIMName &eName) {
 63               for (long i=0,s=a.size(); i<s; i++) {
 64 schuur 1.1       const String &n=a[i].getParameterName();
 65                  if (String::equalNoCase(n,eName)) return i;
 66               }
 67               return -1;
 68            }
 69            
 70            static CMPIStatus argsAddArg(CMPIArgs* eArg, char* name, CMPIValue* data, CMPIType type) {
 71               Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
 72               CMPIrc rc;
 73               CIMValue v=value2CIMValue(data,type,&rc);
 74               CIMName sName(name);
 75            
 76               long i=locateArg(*arg,sName);
 77               if (i>=0) arg->remove(i);
 78            
 79               arg->append(CIMParamValue(sName,v));
 80               CMReturn(CMPI_RC_OK);
 81            }
 82            
 83            static CMPIData argsGetArgAt(CMPIArgs* eArg, CMPICount pos, CMPIString** name,
 84                           CMPIStatus* rc) {
 85 schuur 1.1    Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
 86               CMPIData data={0,0,{0}};
 87            
 88               if (pos>arg->size()) {
 89                  if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
 90                  return data;
 91               }
 92            
 93               CIMValue v=(*arg)[pos].getValue();
 94               CIMType pType=v.getType();
 95               CMPIType t=type2CMPIType(pType,v.isArray());
 96            
 97               value2CMPIData(v,t,&data);
 98            
 99               if (name) {
100                  String n=(*arg)[pos].getParameterName();
101                  *name=(CMPIString*)string2CMPIString(n);
102               }
103            
104               if (rc) CMSetStatus(rc,CMPI_RC_OK);
105               return data;
106 schuur 1.1 }
107            
108            static CMPIData argsGetArg(CMPIArgs* eArg, char* name, CMPIStatus* rc) {
109               Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
110               CIMName eName(name);
111            
112               long i=locateArg(*arg,eName);
113               if (i>=0) return argsGetArgAt(eArg,i,NULL,rc);
114            
115               CMPIData data={0,0,{0}};
116               if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
117               return data;
118            }
119            
120            static CMPICount argsGetArgCount(CMPIArgs* eArg, CMPIStatus* rc) {
121               Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
122               if (rc) CMSetStatus(rc,CMPI_RC_OK);
123               return arg->size();
124            }
125            
126            
127 schuur 1.1 static CMPIArgsFT args_FT={
128                 CMPICurrentVersion,
129                 argsRelease,
130                 argsClone,
131                 argsAddArg,
132                 argsGetArg,
133                 argsGetArgAt,
134                 argsGetArgCount,
135            };
136            
137            CMPIArgsFT *CMPI_Args_Ftab=&args_FT;
138            
139            static CMPIArgsFT argsOnStack_FT={
140                 CMPICurrentVersion,
141                 argsReleaseNop,
142                 argsClone,
143                 argsAddArg,
144                 argsGetArg,
145                 argsGetArgAt,
146                 argsGetArgCount,
147            };
148 schuur 1.1 
149            CMPIArgsFT *CMPI_ArgsOnStack_Ftab=&argsOnStack_FT;
150            
151            
152            
153            // CMPIContext Session
154            
155            static CMPIStatus contextReleaseNop(CMPIContext* eCtx) {
156               CMReturn(CMPI_RC_OK);
157            }
158            
159            static CMPIData contextGetEntry(CMPIContext* eCtx, char* name, CMPIStatus* rc) {
160               return argsGetArg((CMPIArgs*)eCtx,name,rc);
161            }
162            
163            CMPIData contextGetEntryAt(CMPIContext* eCtx, CMPICount pos,
164                        CMPIString** name, CMPIStatus* rc) {
165               return argsGetArgAt((CMPIArgs*)eCtx,pos,name,rc);
166            }
167            
168            static CMPICount contextGetEntryCount(CMPIContext* eCtx, CMPIStatus* rc) {
169 schuur 1.1    return argsGetArgCount((CMPIArgs*)eCtx,rc);
170            }
171            
172            static CMPIStatus contextAddEntry(CMPIContext* eCtx, char* name,
173                        CMPIValue* data, CMPIType type) {
174               return argsAddArg((CMPIArgs*)eCtx,name,data,type);
175            }
176            
177            
178            static CMPIContextFT context_FT={
179                 CMPICurrentVersion,
180                 contextReleaseNop,
181                 NULL,
182                 contextGetEntry,
183                 contextGetEntryAt,
184                 contextGetEntryCount,
185                 contextAddEntry,
186            };
187            
188            CMPIContextFT *CMPI_Context_Ftab=&context_FT;
189            
190 schuur 1.1 static CMPIContextFT contextOnStack_FT={
191                 CMPICurrentVersion,
192                 contextReleaseNop,
193                 NULL,
194                 contextGetEntry,
195                 contextGetEntryAt,
196                 contextGetEntryCount,
197                 contextAddEntry,
198            };
199            
200            CMPIContextFT *CMPI_ContextOnStack_Ftab=&contextOnStack_FT;
201            
202            
203            CMPI_Context::CMPI_Context(const OperationContext& ct) {
204                  ctx=(OperationContext*)&ct;
205                  thr=NULL;
206                  hdl=(void*)new Array<CIMParamValue>();
207                  ft=CMPI_Context_Ftab;
208               }
209            
210            CMPI_ContextOnStack::CMPI_ContextOnStack(const OperationContext& ct) {
211 schuur 1.1       ctx=(OperationContext*)&ct;
212                  hdl=(void*)new Array<CIMParamValue>();
213                  ft=CMPI_ContextOnStack_Ftab;
214               }
215            
216            CMPI_ContextOnStack::~CMPI_ContextOnStack() {
217                  delete (Array<CIMParamValue>*)hdl;
218               }
219            
220            CMPI_ArgsOnStack::CMPI_ArgsOnStack(const Array<CIMParamValue>& args) {
221                  hdl=(void*)&args;
222                  ft=CMPI_ArgsOnStack_Ftab;
223               }
224            
225            PEGASUS_NAMESPACE_END
226            
227            
228            
229            
230            
231            
232 schuur 1.1 

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2