HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_ReadWritePipe.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_ReadWritePipe.h (UT Library, C++)
7
*
8
* COMMENTS: This class spawns a program and allows bidirectional
9
* communication between this process and the program by using
10
* two pipes. The program only has to use stdin and stdout.
11
* This process must use the pipe files.
12
*/
13
14
#ifndef __UT_ReadWritePipe_h__
15
#define __UT_ReadWritePipe_h__
16
17
#include "
UT_API.h
"
18
#include "
UT_NonCopyable.h
"
19
#include "
UT_Spawn.h
"
20
#include <stdio.h>
21
22
class
UT_API
UT_ReadWritePipe
23
{
24
public
:
25
// Note that the constructor does not open the pipe. Instead, you must
26
// call open().
27
UT_ReadWritePipe
();
28
29
// If the pipe is still open when this object is destructed, the
30
// child process will be killed.
31
~
UT_ReadWritePipe
();
32
33
UT_NON_COPYABLE
(
UT_ReadWritePipe
)
34
35
// If the command could not be run for any reason, open() will return
36
// false. The reason for the failure can be determined with getErrno().
37
bool
open
(
const
char
*cmd);
38
int
getErrno
()
const
{
return
myErrno; }
39
40
// If the pipe was already closed, close() will return false. If the child
41
// is still running, close() will kill the child with a SIGINT.
42
bool
close
();
43
44
// If close() succeeds, you can get the exit status of the child process
45
// with this method.
46
int
getChildExitStatus
()
const
{
return
myChildExitStatus; }
47
48
// Use these files to read from and write to the pipe. Note that if you
49
// try to write to the pipe when the child has exited, you will get a
50
// SIGPIPE. When you write, you should call fflush() to force the
51
// pipe to be flushed.
52
FILE *
getReadFile
() {
return
myReadFile; }
53
FILE *
getWriteFile
() {
return
myWriteFile; }
54
55
// This method will return the process id of the command that was executed.
56
pid_t
getChildPid
()
const
{
return
myChildPid; }
57
58
private
:
59
FILE *myReadFile;
60
FILE *myWriteFile;
61
62
pid_t myChildPid;
63
int
myChildExitStatus;
64
int
myErrno;
65
66
#ifdef WIN32
67
void
*myReadPipe;
68
void
*myWritePipe;
69
void
*myHProcess;
70
#endif
71
};
72
73
#endif
UT_ReadWritePipe::getErrno
int getErrno() const
Definition:
UT_ReadWritePipe.h:38
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
UT_ReadWritePipe
Definition:
UT_ReadWritePipe.h:22
close
void close() override
open
int open(float queuesize) override
UT_ReadWritePipe::getChildPid
pid_t getChildPid() const
Definition:
UT_ReadWritePipe.h:56
UT_ReadWritePipe::getReadFile
FILE * getReadFile()
Definition:
UT_ReadWritePipe.h:52
UT_NON_COPYABLE
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition:
UT_NonCopyable.h:31
UT_NonCopyable.h
UT_ReadWritePipe::getChildExitStatus
int getChildExitStatus() const
Definition:
UT_ReadWritePipe.h:46
UT_Spawn.h
UT_ReadWritePipe::getWriteFile
FILE * getWriteFile()
Definition:
UT_ReadWritePipe.h:53
UT
UT_ReadWritePipe.h
Generated on Sun Nov 17 2024 03:03:48 for HDK by
1.8.6