Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JObjectDemultiplexer.cc File Reference

Example program to test JLANG::JObjectMultiplexer and JLANG::JObjectDemultiplexer classes. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "JLang/JSTDObjectReader.hh"
#include "JLang/JSTDObjectWriter.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JLang/JObjectDemultiplexer.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JObjectMultiplexer and JLANG::JObjectDemultiplexer classes.

Author
mdejong

Definition in file JObjectDemultiplexer.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 107 of file JObjectDemultiplexer.cc.

108{
109 using namespace std;
110
111 int debug;
112
113 try {
114
115 JParser<> zap("Example program to test object multiplexing and demultiplexing.");
116
117 zap['d'] = make_field(debug) = 3;
118
119 zap(argc, argv);
120 }
121 catch(const exception &error) {
122 FATAL(error.what() << endl);
123 }
124
125
126 using namespace JPP;
127
128 vector<__A__> a_in;
129 vector<__B__> b_in;
130
131 for (int i = 1; i != 4; ++i) {
132 a_in.push_back(i);
133 b_in.push_back(i);
134 }
135
136 if (debug >= debug_t) {
137 cout << "a_in "; copy(a_in.begin(), a_in.end(), ostream_iterator<__A__>(cout, " ")); cout << endl;
138 cout << "b_in "; copy(b_in.begin(), b_in.end(), ostream_iterator<__B__>(cout, " ")); cout << endl;
139 }
140
141
142 typedef JTYPELIST<__B__, __A__>::typelist typelist; // make sure base class is at end
143
145
146 in.set(a_in);
147 in.set(b_in);
148
149
151
152 vector<__A__> a_out;
153 vector<__B__> b_out;
154
155 out.set(a_out);
156 out.set(b_out);
157
158
159 JObjectMultiplexer<typelist> multiplexer (in);
160
161 JObjectDemultiplexer<__A__, typelist> demultiplexer(out);
162
163
164 multiplexer >> demultiplexer;
165
166 if (debug >= debug_t) {
167 cout << "a_out "; copy(a_out.begin(), a_out.end(), ostream_iterator<__A__>(cout, " ")); cout << endl;
168 cout << "b_out "; copy(b_out.begin(), b_out.end(), ostream_iterator<__B__>(cout, " ")); cout << endl;
169 }
170
171 ASSERT(a_in == a_out);
172 ASSERT(b_in == b_out);
173
174 return 0;
175}
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Auxiliary class for multiplexing object iterators.
Implementation of object output from STD container.
void set(JContainer_t &buffer)
Set output buffer.
Utility class to parse command line options.
Definition JParser.hh:1698
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for demultiplexing object outputs.
Implementation of object iteration from STD container.
void set(JContainer_t &buffer)
Set input buffer.
Type list.
Definition JTypeList.hh:23