(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           // Author: Carol Ann Krug Graves, Hewlett-Packard Company
 33           //             (carolann_graves@hp.com)
 34 kumpf 1.1 //
 35 david.dillard 1.3 // Modified By: David Dillard, VERITAS Software Corp.
 36                   //                  (david.dillard@veritas.com)
 37 kumpf         1.1 //
 38                   //%/////////////////////////////////////////////////////////////////////////////
 39                   
 40                   #ifndef Pegasus_AnonymousPipe_h
 41                   #define Pegasus_AnonymousPipe_h
 42                   
 43                   #include <Pegasus/Common/Config.h>
 44                   #include <Pegasus/Common/Linkage.h>
 45                   #include <Pegasus/Common/String.h>
 46                   #include <Pegasus/Common/CIMMessage.h>
 47                   
 48                   
 49                   PEGASUS_NAMESPACE_BEGIN
 50                   
 51                   /** 
 52                       The AnonymousPipe class implements an anonymous pipe.
 53                   
 54                       @author  Hewlett-Packard Company
 55                   
 56                   */
 57                   class PEGASUS_COMMON_LINKAGE AnonymousPipe
 58 kumpf         1.1 {
 59                   public:
 60                       /**
 61                           Constructs an AnonymousPipe instance.
 62                   
 63 carolann.graves 1.5         @exception   Exception (Failed to create pipe)
 64 kumpf           1.1     */
 65                         AnonymousPipe ();
 66                     
 67                         /**
 68                             Constructs an AnonymousPipe instance, given the read and/or write handle
 69                             in char form.
 70                     
 71                             NOTE: before using this form of the constructor, the pipe must already 
 72                             exist (a previous invocation of the AnonymousPipe () form of the 
 73                             constructor), and the specified handle(s) should be open for the 
 74                             specified operation (read or write).  The read or write handle 
 75                             should be obtained via a call to exportReadHandle () or 
 76                             exportWriteHandle (), respectively.
 77                     
 78                             @param   readHandle       char [] representation of the read handle to 
 79                                                         the pipe
 80                             @param   writeHandle      char [] representation of the write handle to
 81                                                         the pipe
 82                     
 83 carolann.graves 1.5         @exception   Exception (Failed to create pipe)
 84 kumpf           1.1     */
 85                         AnonymousPipe (
 86                             const char * readHandle,
 87                             const char * writeHandle);
 88                     
 89                         /**
 90                             Destructs the AnonymousPipe instance.
 91                     
 92                             Closes the open pipe handles.
 93                         */
 94                         ~AnonymousPipe ();
 95                     
 96                         /**
 97                             Defines symbolic constants for return values from read and write
 98                             methods.
 99                         */
100                         enum Status {STATUS_INTERRUPT = -2, 
101                                      STATUS_ERROR     = -1, 
102                                      STATUS_CLOSED    =  0, 
103                                      STATUS_SUCCESS   =  1};
104                     
105 kumpf           1.1     /**
106                             Writes data from a buffer to the AnonymousPipe.  
107                     
108                             @param   buffer           pointer to the input data buffer
109                             @param   bytesToWrite     Number of bytes to write
110                     
111                             @return  STATUS_SUCCESS   on success; 
112                                      STATUS_CLOSED    on closed connection; 
113                                      STATUS_ERROR     on error;
114                         */
115                         Status writeBuffer (
116 david.dillard   1.3         const void * buffer,
117 kumpf           1.1         Uint32 bytesToWrite);
118                     
119                         /**
120                             Writes a CIM message to the AnonymousPipe.  
121                     
122                             The message is serialized, then written to the pipe.
123                     
124                             @param   message          pointer to the message
125                     
126                             @return  STATUS_SUCCESS   on success; 
127                                      STATUS_CLOSED    on closed connection; 
128                                      STATUS_ERROR     on error;
129                         */
130                         Status writeMessage (
131                             CIMMessage * message);
132                     
133                         /**
134                             Reads data into a buffer from the AnonymousPipe.  
135                     
136                             @param   buffer           pointer to the output data buffer
137                             @param   bytesToRead      Number of bytes to read
138 kumpf           1.1 
139                             @return  STATUS_SUCCESS   on success; 
140                                      STATUS_CLOSED    on closed connection; 
141                                      STATUS_ERROR     on error;
142                                      STATUS_INTERRUPT on interrupt
143                         */
144                         Status readBuffer (
145 david.dillard   1.3         void * buffer,
146 kumpf           1.1         Uint32 bytesToRead);
147                     
148                         /**
149                             Reads a CIM message from the AnonymousPipe.  
150                     
151                             A message is read from the pipe, then de-serialized.
152                     
153                             @param   message          pointer to the message (output parameter)
154                     
155                             @return  STATUS_SUCCESS   on success; 
156                                      STATUS_CLOSED    on closed connection; 
157                                      STATUS_ERROR     on error;
158                                      STATUS_INTERRUPT on interrupt
159                         */
160                         Status readMessage (
161                         CIMMessage * & message);
162                     
163                         /**
164                             Gets a char [] form of the pipe handle for reading from the 
165                             AnonymousPipe instance.  
166                     
167 kumpf           1.1         NOTE: the caller must supply the buffer.  The buffer size must be at 
168                                   least 32.
169                         */
170                         void exportReadHandle (
171                             char * buffer) const;
172                     
173                         /**
174                             Gets a char [] form of the pipe handle for writing to the 
175                             AnonymousPipe instance.  
176                     
177                             NOTE: the caller must supply the buffer.  The buffer size must be at 
178                                   least 32.
179                         */
180                         void exportWriteHandle (
181                             char * buffer) const;
182                     
183                         /**
184                             Closes the pipe handle for reading from the AnonymousPipe instance.  
185                         */
186                         void closeReadHandle ();
187                     
188 kumpf           1.1     /**
189                             Closes the pipe handle for writing to the AnonymousPipe instance.  
190                         */
191                         void closeWriteHandle ();
192                     
193                     private:
194                     
195                         /**
196                             Private, unimplemented copy constructor to avoid implicit use of
197                             the default copy constructor
198                         */
199 kumpf           1.6     AnonymousPipe (const AnonymousPipe & anonymousPipe);
200 kumpf           1.1 
201                         /**
202                             Private, unimplemented assignment operator to avoid implicit use of 
203                             the default assignment operator
204                         */
205 kumpf           1.6     AnonymousPipe & operator= (const AnonymousPipe & anonymousPipe);
206 kumpf           1.1 
207                     #if defined (PEGASUS_OS_TYPE_WINDOWS)
208                         typedef HANDLE AnonymousPipeHandle;
209                     #else
210                         typedef int AnonymousPipeHandle;
211                     #endif
212                     
213                         /**
214                             Stores the read pipe handle.
215                         */
216                         AnonymousPipeHandle _readHandle;
217                     
218                         /**
219                             Stores the write pipe handle.
220                         */
221                         AnonymousPipeHandle _writeHandle;
222                     
223                         /**
224                             Indicates whether the read handle is open.
225                         */
226                         Boolean _readOpen;
227 kumpf           1.1 
228                         /**
229                             Indicates whether the write handle is open.
230                         */
231                         Boolean _writeOpen;
232                     };
233                     
234                     PEGASUS_NAMESPACE_END
235                     
236                     #endif /* Pegasus_AnonymousPipe_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2