(file) Return to AnonymousPipe.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2