blob: d27fd18e9c7b167978654b2f8df5550669873a9c (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "simple_sink.hh"
#include "common/tools.hh"
#include <unistd.h>
#include <sys/timeb.h>
namespace rtfl {
namespace tests {
using namespace rtfl::tools;
SimpleSink::SimpleSink ()
{
startTime = getCurrentTime ();
msg ("<init>");
}
void SimpleSink::setLinesSource (LinesSource *source)
{
msg ("setLinesSource: souce = %p", source);
}
void SimpleSink::processLine (char *line)
{
msg ("processLine: %s", line);
}
void SimpleSink::timeout (int type)
{
msg ("timeout: type = %d", type);
}
void SimpleSink::finish ()
{
msg ("finish");
}
long SimpleSink::getCurrentTime ()
{
struct timeb t;
if (ftime (&t) == -1)
syserr ("ftime() failed");
return t.time * 1000L + t.millitm;
}
void SimpleSink::msg (const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
long time = getCurrentTime () - startTime;
printf ("[SimpleSink] %2ld.%03ld -- ", time / 1000, time % 1000);
vprintf (fmt, args);
putchar ('\n');
}
} // namespace tests
} // namespace rtfl
|