1 //%/////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
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:
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.
22 //==============================================================================
24 // Author: Chip Vincent (cvincent@us.ibm.com)
26 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
28 //%/////////////////////////////////////////////////////////////////////////////
30 #ifndef Pegasus_ResponseHandler_h
31 #define Pegasus_ResponseHandler_h
33 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/Array.h>
35 #include <Pegasus/Common/Linkage.h>
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>
47 PEGASUS_NAMESPACE_BEGIN
49 class ResponseHandlerRep;
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
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>
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>
75 class PEGASUS_COMMON_LINKAGE ResponseHandler
82 virtual ~ResponseHandler(void);
84 // This method is defined in subclasses, specialized for
85 // the appropriate data type.
86 //virtual void deliver(const T & object);
88 // This method is defined in subclasses, specialized for
89 // the appropriate data type.
90 //virtual void deliver(const Array<T> & objects);
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>.
97 virtual void processing(void) = 0;
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>
105 virtual void complete(void) = 0;
107 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
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:
120 ContentLanguageListContainer: used to set the ContentLanguages of the
124 <p>Implementation Note: This method is concrete to preserve
125 binary compatibility with previous releases of the CIMServer</p>
127 void setContext(const OperationContext & context);
128 #endif // PEGASUS_USE_EXPERIMENTAL_INTERFACES
134 ResponseHandler(const ResponseHandler& handler);
136 ResponseHandler& operator=(const ResponseHandler& handler);
139 // Gets the context for the results delivered to the CIM Server.
141 OperationContext getContext(void) const;
143 ResponseHandlerRep* _rep;
148 // InstanceResponseHandler
150 class PEGASUS_COMMON_LINKAGE InstanceResponseHandler : virtual public ResponseHandler
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>
163 virtual void deliver(const CIMInstance & instance) = 0;
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>
172 virtual void deliver(const Array<CIMInstance> & instances) = 0;
177 // ObjectPathResponseHandler
179 class PEGASUS_COMMON_LINKAGE ObjectPathResponseHandler : virtual public ResponseHandler
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>
192 virtual void deliver(const CIMObjectPath & objectPath) = 0;
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>
201 virtual void deliver(const Array<CIMObjectPath> & objectPaths) = 0;
206 // MethodResultResponseHandler
208 class PEGASUS_COMMON_LINKAGE MethodResultResponseHandler : virtual public ResponseHandler
212 virtual void deliverParamValue(const CIMParamValue & outParamValue) = 0;
215 virtual void deliverParamValue(const Array<CIMParamValue> & outParamValues) = 0;
218 virtual void deliver(const CIMValue & returnValue) = 0;
223 // IndicationResponseHandler
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
231 virtual void deliver(const CIMIndication & indication) = 0;
233 virtual void deliver(const Array<CIMIndication> & indications) = 0;
235 virtual void deliver(
236 const OperationContext & context,
237 const CIMIndication & indication) = 0;
239 virtual void deliver(
240 const OperationContext & context,
241 const Array<CIMIndication> & indications) = 0;
246 // ObjectResponseHandler
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.
254 class PEGASUS_COMMON_LINKAGE ObjectResponseHandler : virtual public ResponseHandler
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>
267 virtual void deliver(const CIMObject & object) = 0;
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>
276 virtual void deliver(const Array<CIMObject> & objects) = 0;
280 #ifdef PEGASUS_INTERNALONLY
281 // This type is used in CIMPropertyProvider which Pegasus does not support
283 // ValueResponseHandler
285 class PEGASUS_COMMON_LINKAGE ValueResponseHandler : virtual public ResponseHandler
288 virtual void deliver(const CIMValue & value) = 0;
290 virtual void deliver(const Array<CIMValue> & values) = 0;
295 #ifdef PEGASUS_INTERNALONLY
296 // This type is used in CIMClassProvider which Pegasus does not support
298 // ClassResponseHandler
300 class PEGASUS_COMMON_LINKAGE ClassResponseHandler : virtual public ResponseHandler
303 virtual void deliver(const CIMClass & classObj) = 0;
305 virtual void deliver(const Array<CIMClass> & classObjs) = 0;
309 PEGASUS_NAMESPACE_END