~dominik-burgdoerfer/webplodder/0.4

« back to all changes in this revision

Viewing changes to src/wesl/process/process.hpp

  • Committer: Dominik Burgdörfer
  • Date: 2010-07-07 14:35:20 UTC
  • Revision ID: dominik@domachine-20100707143520-wpywl29fsg9quz54
restructured sources

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// =======================================================================
2
 
// 
3
 
//       Filename:  process.hpp
4
 
// 
5
 
//    Description:  
6
 
// 
7
 
//        Version:  1.0
8
 
//        Created:  03.05.2010 17:59:52
9
 
//       Revision:  none
10
 
//       Compiler:  g++
11
 
// 
12
 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
13
 
//        Company:  -
14
 
// 
15
 
// =======================================================================
16
 
 
17
 
 
18
 
#ifndef  PROCESS_INC
19
 
#define  PROCESS_INC
20
 
#include <iostream>
21
 
#include <cstring>
22
 
 
23
 
namespace wesl {
24
 
    namespace process {
25
 
        /**
26
 
         * @brief Interface to spawn a system process
27
 
         * and communicate with it.
28
 
         */
29
 
        class Process {
30
 
        public:
31
 
            /**
32
 
             * @brief Constructs a Process object.
33
 
             * @param command The system command
34
 
             */
35
 
            Process(const std::string& command);
36
 
 
37
 
            /**
38
 
             * @brief Spawns the process and opens read
39
 
             * and write channel.
40
 
             */
41
 
            pid_t launch();
42
 
 
43
 
            /**
44
 
             * @brief Reads one character from the process
45
 
             * output and stores it in <i>ch</i>.
46
 
             * @param[out] ch The read character will be stored in it
47
 
             */
48
 
            bool operator>>(char& ch);
49
 
 
50
 
            /**
51
 
             * @brief Writes <i>ch</ch> to the process input device.
52
 
             * @param[in] ch The character to write
53
 
             */
54
 
            Process& operator<<(char ch);
55
 
 
56
 
            /**
57
 
             * @brief Closes read channel.
58
 
             */
59
 
            void closeReadChannel();
60
 
 
61
 
            /**
62
 
             * @brief Closes write channel.
63
 
             */
64
 
            void closeWriteChannel();
65
 
 
66
 
            /**
67
 
             * @brief Closes read and write channel.
68
 
             */
69
 
            void close();
70
 
 
71
 
        private:
72
 
            std::string m_command;
73
 
            int m_fileDescriptors[2];
74
 
        };
75
 
    }
76
 
}
77
 
#endif   // ----- #ifndef PROCESS_INC  -----