Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMessageScheduler.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
10
11#include "Jeep/JParser.hh"
12#include "Jeep/JMessage.hh"
13
14
15/**
16 * \file
17 *
18 * Example program to test message scheduling.
19 * \author mdejong
20 */
21int main(int argc, char* argv[])
22{
23 using namespace std;
24
25 string message_logger;
26 bool use_cout;
27 int log_s;
28 int numberOfMessages;
29 int debug;
30
31 try {
32
33 JParser<> zap("Example program to test message scheduling.");
34
35 zap['M'] = make_field(message_logger) = "localhost";
36 zap['c'] = make_field(use_cout);
37 zap['T'] = make_field(log_s);
38 zap['n'] = make_field(numberOfMessages);
39 zap['d'] = make_field(debug) = 3;
40
41 zap(argc, argv);
42 }
43 catch(const exception &error) {
44 FATAL(error.what() << endl);
45 }
46
47 using namespace JPP;
48
49
50 JLogger* out = NULL;
51
52 if (use_cout)
53 out = new JStreamLogger(cout);
54 else
55 out = new JControlHostLogger(message_logger);
56
57 JMessageLogger logger(out, argv[0], debug);
58 JMessageScheduler scheduler(logger, JTimekeeper(log_s * 1000000));
59
60 scheduler.setCredit(3);
61
62 for (int i = 0; i != numberOfMessages; ++i) {
63
64 cout << "sleep [s] " << i * log_s << endl;
65
66 usleep(i * log_s * 1000000);
67
68 for (int i = 0; i != numberOfMessages; ++i) {
69 JErrorStream(scheduler) << i;
70 }
71 }
72}
General purpose message reporting.
int main(int argc, char *argv[])
Message reporting compatible with STL output stream operations.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Time keeper.
Message logging based on ControlHost.
Interface for logging messages.
Definition JLogger.hh:22
Message logger with time scheduler.
void setCredit(const int credit)
Set credit.
Message logging based on std::ostream.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).