HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_NamedPipe.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_NamedPipe.h ( UT Library, C++)
7  *
8  * COMMENTS: This is a read pipe which gets around the problem of having a
9  * broken pipe if you close before reading all of the input from
10  * the pipe command.
11  */
12 
13 #ifndef __UT_NamedPipe__
14 #define __UT_NamedPipe__
15 
16 #include "UT_API.h"
17 #include "UT_String.h"
18 
19 #include <SYS/SYS_Handle.h>
20 
21 #if defined(LINUX) || defined(MBSD)
22  #include <stdio.h>
23 #endif
24 
26 public:
27  explicit UT_NamedPipe(SYS_Handle *filehandle);
28 
29  // If the pipe is open and destructed, the process will be killed.
30  ~UT_NamedPipe();
31 
32  // Returns 1 if the pipe is open, 0 otherwise.
33  int isOpen();
34 
35  // Create a named pipe of the given name. Returns 0 on error, 1 on success.
36  // Created pipes are all write-only.
37  int create(const char *filename);
38 
39  // Open a named pipe ofh the given name. Returns 0 on error, 1 on success.
40  // Opened pipes are all read only.
41  int open(const char *filename);
42 
43  // Close the pipe.
44  void close();
45 
46  // Read up to the specified number of bytes. Returns the number of bytes
47  // actually read. This call never blocks.
48  int read(char *data, int len);
49 
50  // Prepare named pipe for writing. Call this before doing a block
51  // of writes. Under NT it makes sure the pipe is connected. Does
52  // nothing under SGI.
53  void prepWrite();
54 
55  // Write the specified number of bytes. Returns the number of bytes
56  // actually read. This call blocks until all bytes have been written.
57  int write(const char *data, int len);
58 
59  // Flush input or output.
60  void flush();
61 
62  // Returns 1 if there is data to be read, 0 if not, and less
63  // than 0 if error.
64  int dataAvailable();
65 
66 private:
67 
68  SYS_Handle *myFileHandle;
69 
70  int myCreated;
71  UT_String myFileName;
72  int myBytePending;
73  char myNextByte;
74 #ifndef WIN32
75  FILE *myPipe;
76 #endif
77 };
78 
79 #endif
#define UT_API
Definition: UT_API.h:12
void read(T &in, bool &v)
Definition: ImfXdr.h:611
GLboolean * data
Definition: glcorearb.h:130
virtual int open(float queuesize)
virtual void close()
void write(T &out, bool v)
Definition: ImfXdr.h:332