os-cmpi-xen

view src/cmpilr.h @ 109:64e363d418df

Minor changes to cmpilr interface:
- Propogated CMPIStatus structure through to resource files in cmpilr.[ch]
- Functions in cmpilr function table now return int and any data in
caller-provided pointer

This allows functions such as CMPILR_enumInstanceNames to return success when
no instances exist - instead of an exception which will terminate any
enumInstanceNames call chain from originated on superclass.

Updated providers to changes in cmpilr interface.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Fri May 11 17:17:46 2007 -0600 (2007-05-11)
parents fa1ca0490794
children ce72210a88c6
line source
1 // Copyright (C) 2007 IBM Corp.
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 // ============================================================================
17 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com>
18 // ============================================================================
20 #if !defined(__CMPITLR_H__)
21 #define __CMPILR_H__
23 #include "cmpidt.h"
25 /* ------------------------------------------------------------------------- */
26 /* The generic CMPILR function table to manage system resources. */
27 /* ------------------------------------------------------------------------- */
29 typedef struct _CMPIResourceFT {
30 int (*load)();
31 int (*unload)(CMPIBoolean terminating);
32 int (*beginEnum)(void **resList, CMPIStatus *status);
33 void (*endEnum)(void* resList);
34 int (*getNext)(void* resList, void **res, CMPIStatus *status);
35 int (*get)(void* resList, void** res, CMPIStatus *status);
36 void (*release)(void* res);
37 int (*add)(void** resList, void* res, CMPIStatus *status);
38 int (*delete)(void** resList, void* res, CMPIStatus *status);
39 int (*modify)(void** resList, void* res, CMPIStatus *status);
40 int (*res2inst)(void* res, CMPIInstance* inst, CMPIStatus *status);
41 int (*inst2res)(CMPIInstance* inst, void** res, CMPIStatus *status);
42 } CMPIResourceFT;
44 /* ------------------------------------------------------------------------- */
45 /* The generic CMPIPR encapsulated object for system resources. */
46 /* ------------------------------------------------------------------------- */
48 typedef struct _CMPIResource {
49 void* hdl; /* Opaque pointer to any resource specific implementation data. */
50 const CMPIBroker* brkr; /* Handle to the CIM broker/CIMOM. */
51 char* cn; /* The resource provider's CIM class */
52 CMPIResourceFT* ft; /* Pointer to the resource specific function table. */
53 } CMPIResource;
55 /* ------------------------------------------------------------------------- */
56 /* The generic CMPILR resource-agnostic CMPI instance provider functions. */
57 /* ------------------------------------------------------------------------- */
59 CMPIStatus CMPILR_cleanup
60 (CMPIInstanceMI* mi, const CMPIContext* ctx, CMPIBoolean terminating);
62 CMPIStatus CMPILR_enumInstanceNames
63 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
64 const CMPIObjectPath* ref);
66 CMPIStatus CMPILR_enumInstanceNames
67 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
68 const CMPIObjectPath* ref);
70 CMPIStatus CMPILR_enumInstances
71 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
72 const CMPIObjectPath* ref, const char** properties);
74 CMPIStatus CMPILR_getInstance
75 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
76 const CMPIObjectPath* ref, const char** properties);
78 CMPIStatus CMPILR_createInstance
79 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
80 const CMPIObjectPath* ref, const CMPIInstance* inst);
82 CMPIStatus CMPILR_modifyInstance
83 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
84 const CMPIObjectPath* ref, const CMPIInstance* inst, const char** properties);
86 CMPIStatus CMPILR_deleteInstance
87 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
88 const CMPIObjectPath* ref);
90 CMPIStatus CMPILR_execQuery
91 (CMPIInstanceMI* mi, const CMPIContext* ctx, const CMPIResult* rslt,
92 const CMPIObjectPath* ref, const char* lang, const char* query);
94 /* ------------------------------------------------------------------------- */
95 /* Macro generates the function table and _Create_InstanceMI provider entry */
96 /* point for a CMPILR instance provider. */
97 /* ------------------------------------------------------------------------- */
99 #define CMPILRInstanceMIStub(cn,pn,mi) \
100 static CMPIResourceFT resFT = {\
101 load,\
102 unload,\
103 beginEnum,\
104 endEnum,\
105 getNext,\
106 get,\
107 release,\
108 add,\
109 delete,\
110 modify,\
111 res2inst,\
112 inst2res,\
113 };\
114 static CMPIResource res = {\
115 NULL,\
116 NULL,\
117 #cn,\
118 &resFT,\
119 };\
120 static CMPIInstanceMIFT instMIFT = {\
121 CMPICurrentVersion,\
122 CMPICurrentVersion,\
123 "instance" #pn,\
124 CMPILR_cleanup,\
125 CMPILR_enumInstanceNames,\
126 CMPILR_enumInstances,\
127 CMPILR_getInstance,\
128 CMPILR_createInstance,\
129 CMPILR_modifyInstance,\
130 CMPILR_deleteInstance,\
131 CMPILR_execQuery,\
132 };\
133 EXTERN_C \
134 CMPIInstanceMI* pn##_Create_InstanceMI(const CMPIBroker* brkr, const CMPIContext* ctx){\
135 static CMPIInstanceMI instMI = {\
136 (void*)&res,\
137 &instMIFT,\
138 };\
139 mi = &instMI;\
140 ((CMPIResource*)instMI.hdl)->brkr = brkr;\
141 if (!((CMPIResource*)instMI.hdl)->ft->load()) {\
142 return NULL;\
143 }\
144 return &instMI;\
145 };
148 #endif /* __CMPILR_H__ */