bc55c2aec60159801b87d9964b82e1ddff61e265
[tpot/pegasus/.git] / src / Pegasus / Common / ResponseHandler.h
1 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Chip Vincent (cvincent@us.ibm.com)
25 //
26 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
27 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #ifndef Pegasus_ResponseHandler_h
31 #define Pegasus_ResponseHandler_h
32
33 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/Array.h>
35 #include <Pegasus/Common/Linkage.h>
36
37 #include <Pegasus/Common/CIMInstance.h>
38 #include <Pegasus/Common/CIMObjectPath.h>
39 #include <Pegasus/Common/CIMParamValue.h>
40 #include <Pegasus/Common/CIMValue.h>
41 #include <Pegasus/Common/CIMIndication.h>
42 #include <Pegasus/Common/CIMObject.h>
43 #include <Pegasus/Common/CIMClass.h>
44 #include <Pegasus/Common/OperationContext.h>
45
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 class ResponseHandlerRep;
50
51 /**
52 <p>The <tt>ResponseHandler</tt> class allows a provider
53 to report operation progress and results to the CIM Server.
54 Subclasses are defined for each of the types of object
55 that a provider can deliver to the CIM Server.
56 A <tt>ResponseHandler</tt> object of the appropriate type
57 is passed to provider
58 functions that are invoked to process client requests (it
59 is not passed to the <tt>{@link initialize initialize}</tt>
60 or <tt>{@link terminate terminate}</tt> functions). It
61 contains the following public member functions that
62 may be used to deliver results to the CIM Server:</p>
63 <ul>
64 <li><tt>{@link processing processing}</tt> - inform the CIM Server
65 that delivery of results is beginning.</li>
66 <li><tt>{@link deliver deliver}</tt> - deliver an incremental
67 result to the CIM Server; the CIM Server accumulates results as
68 they are received from the provider.</li>
69 <li><tt>{@link complete complete}</tt> - inform the CIM Server that
70 process of the request is complete and that no further
71 results will be delivered.</li>
72 </ul>
73 */
74
75 class PEGASUS_COMMON_LINKAGE ResponseHandler
76 {
77 public:
78
79     /**
80     Destructor.
81     */
82     virtual ~ResponseHandler(void);
83
84     // This method is defined in subclasses, specialized for 
85     // the appropriate data type.
86     //virtual void deliver(const T & object);
87
88     // This method is defined in subclasses, specialized for 
89     // the appropriate data type.
90     //virtual void deliver(const Array<T> & objects);
91
92     /**
93     Inform the CIM Server that delivery of results will begin.
94     <p>The provider must call <tt>processing</tt> before
95     attempting to call <tt>deliver</tt>.
96     */
97     virtual void processing(void) = 0;
98
99     /**
100     Inform the CIM Server that delivery of results is complete.
101     <p>The provider must call <tt>complete</tt> when all
102     results have been delivered. It must not call <tt>deliver</tt>
103     after calling <tt>complete</tt>.</p>
104     */
105     virtual void complete(void) = 0;
106
107 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
108     /**
109     Set the context for the results delivered to the CIM Server.
110     <p>The <tt>setContext</tt> function is used by providers to
111     set a context for the response, in the form of an OperationContext
112     object.  The context of the response contains the settings that
113     apply to all the results delivered to the CIM Server.  An example
114     context is the language of the response, in the form of a 
115     ContentLanguageListContainer in the OperationContext.</p>
116     <p>This method may be called at any point in the response
117     processing before <tt>complete</tt> is called.</p>
118     <p>Currently supported OperationContext containers:
119     <li>
120     ContentLanguageListContainer: used to set the ContentLanguages of the
121     results.
122     </li>
123     </p>
124     <p>Implementation Note:  This method is concrete to preserve 
125     binary compatibility with previous releases of the CIMServer</p> 
126     */
127     void setContext(const OperationContext & context);
128 #endif  // PEGASUS_USE_EXPERIMENTAL_INTERFACES
129
130 protected:
131     
132     ResponseHandler();
133
134     ResponseHandler(const ResponseHandler& handler);
135
136     ResponseHandler& operator=(const ResponseHandler& handler);
137
138     //
139     // Gets the context for the results delivered to the CIM Server.
140     //
141     OperationContext getContext(void) const;
142
143     ResponseHandlerRep* _rep;
144 };
145
146
147 //
148 // InstanceResponseHandler
149 ///
150 class PEGASUS_COMMON_LINKAGE InstanceResponseHandler : virtual public ResponseHandler
151 {
152 public:
153     /** <p>The <tt>deliver</tt> function is used by providers to
154         deliver results to the CIM Server. For operations that require a
155         single element result (<tt>getInstance</tt>, for example),
156         <tt>deliver</tt> should be called only once to deliver the
157         entire result. For operations that involve
158         enumeration, the single-element form shown here may be
159         used, each iteration delivering an incremental element
160         of the total result. The Array form below may be used
161         to deliver a larger set of result elements.</p>
162     */
163     virtual void deliver(const CIMInstance & instance) = 0;
164
165     /** <p>This form of the <tt>deliver</tt> function may be used
166         to return a set of elements to the CIM Server. The set is not
167         required to be complete, and the provider may invoke this
168         function multiple times, if necessary. This form should only
169         be used when the operation requires a result consisting
170         of more than one element, such as an enumeration.</p>
171     */
172     virtual void deliver(const Array<CIMInstance> & instances) = 0;
173 };
174
175
176 //
177 // ObjectPathResponseHandler
178 ///
179 class PEGASUS_COMMON_LINKAGE ObjectPathResponseHandler : virtual public ResponseHandler
180 {
181 public:
182     /** <p>The <tt>deliver</tt> function is used by providers to
183         deliver results to the CIM Server. For operations that require a
184         single element result (<tt>getInstance</tt>, for example),
185         <tt>deliver</tt> should be called only once to deliver the
186         entire result. For operations that involve
187         enumeration, the single-element form shown here may be
188         used, each iteration delivering an incremental element
189         of the total result. The Array form below may be used
190         to deliver a larger set of result elements.</p>
191     */
192     virtual void deliver(const CIMObjectPath & objectPath) = 0;
193
194     /** <p>This form of the <tt>deliver</tt> function may be used
195         to return a set of elements to the CIM Server. The set is not
196         required to be complete, and the provider may invoke this
197         function multiple times, if necessary. This form should only
198         be used when the operation requires a result consisting
199         of more than one element, such as an enumeration.</p>
200     */
201     virtual void deliver(const Array<CIMObjectPath> & objectPaths) = 0;
202 };
203
204
205 //
206 // MethodResultResponseHandler
207 ///
208 class PEGASUS_COMMON_LINKAGE MethodResultResponseHandler : virtual public ResponseHandler
209 {
210 public:
211     ///
212     virtual void deliverParamValue(const CIMParamValue & outParamValue) = 0;
213
214     ///
215     virtual void deliverParamValue(const Array<CIMParamValue> & outParamValues) = 0;
216
217     ///
218     virtual void deliver(const CIMValue & returnValue) = 0;
219 };
220
221
222 //
223 // IndicationResponseHandler
224 //
225 // NOTE: This class definition should not be considered complete until
226 // indication support has been completed in Pegasus.  Implementation of
227 // indication support may reveal a need for API changes in this class.
228 class PEGASUS_COMMON_LINKAGE IndicationResponseHandler : virtual public ResponseHandler
229 {
230 public:
231     virtual void deliver(const CIMIndication & indication) = 0;
232
233     virtual void deliver(const Array<CIMIndication> & indications) = 0;
234
235     virtual void deliver(
236         const OperationContext & context,
237         const CIMIndication & indication) = 0;
238
239     virtual void deliver(
240         const OperationContext & context,
241         const Array<CIMIndication> & indications) = 0;
242 };
243
244
245 //
246 // ObjectResponseHandler
247 //
248 // NOTE: This class definition should not be considered complete until
249 // association provider and/or query provider support has been completed
250 // in Pegasus, as those are the only APIs that use this response handler
251 // type.  Implementation of support for those provider types may reveal
252 // a need for API changes in this class.
253 ///
254 class PEGASUS_COMMON_LINKAGE ObjectResponseHandler : virtual public ResponseHandler
255 {
256 public:
257     /** <p>The <tt>deliver</tt> function is used by providers to
258         deliver results to the CIM Server. For operations that require a
259         single element result (<tt>getInstance</tt>, for example),
260         <tt>deliver</tt> should be called only once to deliver the
261         entire result. For operations that involve
262         enumeration, the single-element form shown here may be
263         used, each iteration delivering an incremental element
264         of the total result. The Array form below may be used
265         to deliver a larger set of result elements.</p>
266     */
267     virtual void deliver(const CIMObject & object) = 0;
268
269     /** <p>This form of the <tt>deliver</tt> function may be used
270         to return a set of elements to the CIM Server. The set is not
271         required to be complete, and the provider may invoke this
272         function multiple times, if necessary. This form should only
273         be used when the operation requires a result consisting
274         of more than one element, such as an enumeration.</p>
275     */
276     virtual void deliver(const Array<CIMObject> & objects) = 0;
277 };
278
279
280 #ifdef PEGASUS_INTERNALONLY
281 // This type is used in CIMPropertyProvider which Pegasus does not support
282 //
283 // ValueResponseHandler
284 //
285 class PEGASUS_COMMON_LINKAGE ValueResponseHandler : virtual public ResponseHandler
286 {
287 public:
288     virtual void deliver(const CIMValue & value) = 0;
289
290     virtual void deliver(const Array<CIMValue> & values) = 0;
291 };
292 #endif
293
294
295 #ifdef PEGASUS_INTERNALONLY
296 // This type is used in CIMClassProvider which Pegasus does not support
297 //
298 // ClassResponseHandler
299 //
300 class PEGASUS_COMMON_LINKAGE ClassResponseHandler : virtual public ResponseHandler
301 {
302 public:
303     virtual void deliver(const CIMClass & classObj) = 0;
304
305     virtual void deliver(const Array<CIMClass> & classObjs) = 0;
306 };
307 #endif
308
309 PEGASUS_NAMESPACE_END
310
311 #endif