summaryrefslogtreecommitdiff
path: root/tests/test_tools_5.cc
blob: 9f5f957e8e717a4fbba95f4645bc56453d49203f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "simple_sink.hh"
#include "testtools.hh"

using namespace rtfl::tools;
using namespace rtfl::tests;

class NotSoSimpleSink: public SimpleSink
{
private:
   LinesSource *source;
   
public:
   NotSoSimpleSink (LinesSource *source);
   void processLine (char *line);
};

NotSoSimpleSink::NotSoSimpleSink (LinesSource *source)
{
   this->source = source;
}

void NotSoSimpleSink::processLine (char *line)
{
   SimpleSink::processLine (line);
   if (strcmp (line, "create") == 0)
      source->addTimeout (2, 0);
}

int main (int argc, char *argv[])
{
   int fd = openPipe ("echo create; echo msg; sleep 5");
   BlockingLinesSource source (fd);
   NotSoSimpleSink sink (&source);
   source.setup (&sink);

   return 0;
}