1 martin 1.9 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.10 //
|
3 martin 1.9 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.10 //
|
10 martin 1.9 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.10 //
|
17 martin 1.9 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.10 //
|
20 martin 1.9 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.10 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.9 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.10 //
|
28 martin 1.9 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_AnonymousPipe_h
33 #define Pegasus_AnonymousPipe_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/Linkage.h>
37 #include <Pegasus/Common/String.h>
38 #include <Pegasus/Common/CIMMessage.h>
39
40
41 PEGASUS_NAMESPACE_BEGIN
42
|
43 kumpf 1.8 /**
|
44 kumpf 1.1 The AnonymousPipe class implements an anonymous pipe.
45
46 @author Hewlett-Packard Company
47
48 */
49 class PEGASUS_COMMON_LINKAGE AnonymousPipe
50 {
51 public:
52 /**
53 Constructs an AnonymousPipe instance.
54
|
55 carolann.graves 1.5 @exception Exception (Failed to create pipe)
|
56 kumpf 1.1 */
57 AnonymousPipe ();
58
59 /**
60 Constructs an AnonymousPipe instance, given the read and/or write handle
61 in char form.
62
|
63 kumpf 1.8 NOTE: before using this form of the constructor, the pipe must already
64 exist (a previous invocation of the AnonymousPipe () form of the
65 constructor), and the specified handle(s) should be open for the
66 specified operation (read or write). The read or write handle
67 should be obtained via a call to exportReadHandle () or
|
68 kumpf 1.1 exportWriteHandle (), respectively.
69
|
70 kumpf 1.8 @param readHandle char [] representation of the read handle to
|
71 kumpf 1.1 the pipe
72 @param writeHandle char [] representation of the write handle to
73 the pipe
74
|
75 carolann.graves 1.5 @exception Exception (Failed to create pipe)
|
76 kumpf 1.1 */
77 AnonymousPipe (
78 const char * readHandle,
79 const char * writeHandle);
80
81 /**
82 Destructs the AnonymousPipe instance.
83
84 Closes the open pipe handles.
85 */
86 ~AnonymousPipe ();
87
88 /**
89 Defines symbolic constants for return values from read and write
90 methods.
91 */
|
92 kumpf 1.8 enum Status {STATUS_INTERRUPT = -2,
93 STATUS_ERROR = -1,
94 STATUS_CLOSED = 0,
|
95 kumpf 1.1 STATUS_SUCCESS = 1};
96
97 /**
|
98 kumpf 1.8 Writes data from a buffer to the AnonymousPipe.
|
99 kumpf 1.1
100 @param buffer pointer to the input data buffer
101 @param bytesToWrite Number of bytes to write
102
|
103 kumpf 1.8 @return STATUS_SUCCESS on success;
104 STATUS_CLOSED on closed connection;
|
105 kumpf 1.1 STATUS_ERROR on error;
106 */
107 Status writeBuffer (
|
108 david.dillard 1.3 const void * buffer,
|
109 kumpf 1.1 Uint32 bytesToWrite);
110
111 /**
|
112 kumpf 1.8 Writes a CIM message to the AnonymousPipe.
|
113 kumpf 1.1
114 The message is serialized, then written to the pipe.
115
116 @param message pointer to the message
117
|
118 kumpf 1.8 @return STATUS_SUCCESS on success;
119 STATUS_CLOSED on closed connection;
|
120 kumpf 1.1 STATUS_ERROR on error;
121 */
122 Status writeMessage (
123 CIMMessage * message);
124
125 /**
|
126 kumpf 1.8 Reads data into a buffer from the AnonymousPipe.
|
127 kumpf 1.1
128 @param buffer pointer to the output data buffer
129 @param bytesToRead Number of bytes to read
130
|
131 kumpf 1.8 @return STATUS_SUCCESS on success;
132 STATUS_CLOSED on closed connection;
|
133 kumpf 1.1 STATUS_ERROR on error;
134 STATUS_INTERRUPT on interrupt
135 */
136 Status readBuffer (
|
137 david.dillard 1.3 void * buffer,
|
138 kumpf 1.1 Uint32 bytesToRead);
139
140 /**
|
141 kumpf 1.8 Reads a CIM message from the AnonymousPipe.
|
142 kumpf 1.1
143 A message is read from the pipe, then de-serialized.
144
145 @param message pointer to the message (output parameter)
146
|
147 kumpf 1.8 @return STATUS_SUCCESS on success;
148 STATUS_CLOSED on closed connection;
|
149 kumpf 1.1 STATUS_ERROR on error;
150 STATUS_INTERRUPT on interrupt
151 */
152 Status readMessage (
153 CIMMessage * & message);
154
155 /**
|
156 kumpf 1.8 Gets a char [] form of the pipe handle for reading from the
157 AnonymousPipe instance.
|
158 kumpf 1.1
|
159 kumpf 1.8 NOTE: the caller must supply the buffer. The buffer size must be at
|
160 kumpf 1.1 least 32.
161 */
162 void exportReadHandle (
163 char * buffer) const;
164
165 /**
|
166 kumpf 1.8 Gets a char [] form of the pipe handle for writing to the
167 AnonymousPipe instance.
|
168 kumpf 1.1
|
169 kumpf 1.8 NOTE: the caller must supply the buffer. The buffer size must be at
|
170 kumpf 1.1 least 32.
171 */
172 void exportWriteHandle (
173 char * buffer) const;
174
175 /**
|
176 kumpf 1.8 Closes the pipe handle for reading from the AnonymousPipe instance.
|
177 kumpf 1.1 */
178 void closeReadHandle ();
179
180 /**
|
181 kumpf 1.8 Closes the pipe handle for writing to the AnonymousPipe instance.
|
182 kumpf 1.1 */
183 void closeWriteHandle ();
184
185 private:
186
187 /**
188 Private, unimplemented copy constructor to avoid implicit use of
189 the default copy constructor
190 */
|
191 kumpf 1.6 AnonymousPipe (const AnonymousPipe & anonymousPipe);
|
192 kumpf 1.1
193 /**
|
194 kumpf 1.8 Private, unimplemented assignment operator to avoid implicit use of
|
195 kumpf 1.1 the default assignment operator
196 */
|
197 kumpf 1.6 AnonymousPipe & operator= (const AnonymousPipe & anonymousPipe);
|
198 kumpf 1.1
199 #if defined (PEGASUS_OS_TYPE_WINDOWS)
200 typedef HANDLE AnonymousPipeHandle;
201 #else
202 typedef int AnonymousPipeHandle;
203 #endif
204
205 /**
206 Stores the read pipe handle.
207 */
208 AnonymousPipeHandle _readHandle;
209
210 /**
211 Stores the write pipe handle.
212 */
213 AnonymousPipeHandle _writeHandle;
214
215 /**
216 Indicates whether the read handle is open.
217 */
218 Boolean _readOpen;
219 kumpf 1.1
220 /**
221 Indicates whether the write handle is open.
222 */
223 Boolean _writeOpen;
224 };
225
226 PEGASUS_NAMESPACE_END
227
228 #endif /* Pegasus_AnonymousPipe_h */
|