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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2