libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Pipe.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // $Id: Pipe.h,v 1.3 2005/10/08 02:42:00 vlg Exp $
4 //------------------------------------------------------------------------------
5 // Pipe.h
6 //------------------------------------------------------------------------------
7 // Copyright (C) 1997-2002 Vladislav Grinchenko
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
13 //------------------------------------------------------------------------------
14 #ifndef PIPE_H
15 #define PIPE_H
16 
17 #include <stdio.h>
18 #include <string>
19 
20 #include "assa/Logger.h"
21 
22 namespace ASSA {
23 
28 class Pipe
29 {
30 public:
34  Pipe ();
35 
39  ~Pipe ();
40 
56  FILE* open (const string& cmd_, const string& type_);
57 
65  int close ();
66 
74  int kill ();
75 
77  pid_t pid () const;
78 
80  FILE* fp () const;
81 
83  int fd () const;
84 
85 private:
86  Pipe (const Pipe&);
87  Pipe& operator= (const Pipe&);
88 
89 private:
93  FILE* m_fp;
94 
98  pid_t m_child_pid;
99 };
100 
101 inline pid_t
102 Pipe::pid () const { return m_child_pid; }
103 
104 inline int
105 Pipe::fd () const { return fileno (m_fp); }
106 
107 inline FILE*
108 Pipe::fp () const { return m_fp; }
109 
110 } // end namespace ASSA
111 
112 #endif // PIPE_H
113