654b06d1f58ca7405c2caf5dc5595764264ce89d
[tpot/pegasus/.git] / src / Pegasus / ExportClient / CIMExportClient.h
1 //%/////-*-c++-*-///////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 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: Mike Brasher (mbrasher@bmc.com)
25 //
26 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
27 //
28 //              Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_Client_h
33 #define Pegasus_Client_h
34
35 #include <fstream>
36 #include <Pegasus/Common/Config.h>
37 #include <Pegasus/Common/String.h>
38 #include <Pegasus/Common/Monitor.h>
39 #include <Pegasus/Common/HTTPConnector.h>
40 #include <Pegasus/Common/CIMMessage.h>
41 #include <Pegasus/Common/MessageQueueService.h>
42 #include <Pegasus/Common/CIMObject.h>
43 #include <Pegasus/Common/Exception.h>
44 #include <Pegasus/Client/ClientAuthenticator.h>
45 #include <Pegasus/ExportClient/Linkage.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
49 class Monitor;
50 class CIMExportResponseDecoder;
51 class CIMExportRequestEncoder;
52
53 /** This class provides the interface that a client uses to communicate
54     with a CIMOM.
55 */
56 class PEGASUS_EXPORT_CLIENT_LINKAGE CIMExportClient : public MessageQueueService
57 {
58    public:
59       typedef MessageQueueService Base;
60   
61
62       enum { DEFAULT_TIMEOUT_MILLISECONDS = 20000 };
63
64       ///
65       CIMExportClient(
66          Monitor* monitor,
67          HTTPConnector* httpConnector,
68          Uint32 timeOutMilliseconds = DEFAULT_TIMEOUT_MILLISECONDS);
69
70       ///
71       ~CIMExportClient();
72
73       ///
74       virtual void handleEnqueue(Message *);
75       virtual void handleEnqueue();
76
77       /** Returns the queue name. */
78       virtual const char* getQueueName() const;
79
80       ///
81       Uint32 getTimeOut() const
82       {
83          return _timeOutMilliseconds;
84       }
85
86       ///
87       void setTimeOut(Uint32 timeOutMilliseconds)
88       {
89          _timeOutMilliseconds = timeOutMilliseconds;
90       }
91
92       ///
93       void connect(const String& address);
94
95       //
96       // Connection used by local clients
97       //
98       void connectLocal(
99          const String& address,
100          const String& userName = String::EMPTY);
101
102       ///
103       virtual void exportIndication(
104          const String& nameSpace,
105          const CIMInstance& instanceName);
106
107    private:
108
109       Message* _waitForResponse(
110          const Uint32 messageType,
111          const String& messageId,
112          const Uint32 timeOutMilliseconds = DEFAULT_TIMEOUT_MILLISECONDS);
113
114       void _checkError(const CIMResponseMessage* responseMessage);
115
116       Monitor* _monitor;
117       HTTPConnector* _httpConnector;
118       Uint32 _timeOutMilliseconds;
119       Boolean _connected;
120       CIMExportResponseDecoder* _responseDecoder;
121       CIMExportRequestEncoder* _requestEncoder;
122       ClientAuthenticator* _authenticator;
123 };
124
125 PEGASUS_NAMESPACE_END
126
127 #endif /* Pegasus_Client_h */