PhoenixSwarm  5.1.1
Library to ease communication between daemons
Loading...
Searching...
No Matches
Representation.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __REPRESENTATION_H__
8#define __REPRESENTATION_H__
9
10#include <string>
11#include "phoenix_data_stream.h"
12#include "phoenix_path_stream.h"
13#include "PString.h"
14#include "MessageType.h"
16
17#include "phoenix_type_stream.h"
18#include "phoenix_data_stream.h"
19#include "phoenix_check_stream.h"
20
23 public:
24 Data();
25 virtual ~Data();
26 Data(const Data & other);
27 Data & operator = (const Data & other);
28 void setName(const PString & name);
29 void setDescription(const PString & description);
30 void setType(const PString & type);
31 void setValue(const DataStreamMsg & value);
32 const PString & getName() const;
33 PString & getName();
34 const PString & getDescription() const;
35 PString & getDescription();
36 const PString & getType() const;
37 PString & getType();
38 const DataStreamMsg & getValue() const;
39 DataStreamMsg & getValue();
40
42
45 template<typename Stream, DataStreamMode::DataStreamMode Mode>
46 bool readWriteStream(Stream & ds){
47 bool b(true);
48 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_name);
49 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_description);
50 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_type);
51 b &= DataStream<Stream, Mode, DataStreamMsg >::data_stream(ds, p_value);
52 return b;
53 }
54
55 protected:
56 void copyData(const Data & other);
57 private:
58 void initialisationData();
60 PString p_name;
64 PString p_type;
66 DataStreamMsg p_value;
67};
68
69template<>
71
73template<typename Stream, DataStreamMode::DataStreamMode Mode>
74struct DataStream<Stream, Mode, Swarm::Data>{
76
80 static bool data_stream(Stream & ds, Swarm::Data & data){
81 return data.readWriteStream<Stream, Mode>(ds);
82 }
83};
84
86template<>
87struct CheckStream<Swarm::Data>{
88 static bool check_stream(const std::string & fieldDescription, const Swarm::Data & data, const Swarm::Data & reference, std::ostream & out);
89};
90
91
92
93
96 public:
97 Function();
98 virtual ~Function();
99 Function(const Function & other);
100 Function & operator = (const Function & other);
101 void setName(const PString & name);
102 void setDescription(const PString & description);
103 void setVecParam(const std::vector<Swarm::Data> & vecParam);
104 void setReturnValue(const Swarm::Data & returnValue);
105 const PString & getName() const;
106 PString & getName();
107 const PString & getDescription() const;
108 PString & getDescription();
109 const std::vector<Swarm::Data> & getVecParam() const;
110 std::vector<Swarm::Data> & getVecParam();
111 const Swarm::Data & getReturnValue() const;
113
115
118 template<typename Stream, DataStreamMode::DataStreamMode Mode>
119 bool readWriteStream(Stream & ds){
120 bool b(true);
121 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_name);
122 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_description);
123 b &= DataStream<Stream, Mode, std::vector<Swarm::Data> >::data_stream(ds, p_vecParam);
125 return b;
126 }
127
128 protected:
129 void copyFunction(const Function & other);
130 private:
133 PString p_name;
137 std::vector<Swarm::Data> p_vecParam;
140};
141
142template<>
144
146template<typename Stream, DataStreamMode::DataStreamMode Mode>
147struct DataStream<Stream, Mode, Swarm::Function>{
149
153 static bool data_stream(Stream & ds, Swarm::Function & data){
154 return data.readWriteStream<Stream, Mode>(ds);
155 }
156};
157
159template<>
160struct CheckStream<Swarm::Function>{
161 static bool check_stream(const std::string & fieldDescription, const Swarm::Function & data, const Swarm::Function & reference, std::ostream & out);
162};
163
164
165
166
169 public:
170 Message();
171 virtual ~Message();
172 Message(const Message & other);
173 Message & operator = (const Message & other);
174 void setSendTime(const time_t & sendTime);
175 void setId(size_t id);
176 void setIsConfirmationNeeded(bool isConfirmationNeeded);
177 void setSender(const PString & sender);
178 void setVecRecver(const std::vector<PString> & vecRecver);
179 void setType(const MessageType::MessageType & type);
180 void setData(const Swarm::Data & data);
181 const time_t & getSendTime() const;
182 time_t & getSendTime();
183 size_t getId() const;
184 size_t & getId();
185 bool getIsConfirmationNeeded() const;
187 const PString & getSender() const;
188 PString & getSender();
189 const std::vector<PString> & getVecRecver() const;
190 std::vector<PString> & getVecRecver();
191 const MessageType::MessageType & getType() const;
193 const Swarm::Data & getData() const;
195
197
200 template<typename Stream, DataStreamMode::DataStreamMode Mode>
201 bool readWriteStream(Stream & ds){
202 bool b(true);
203 b &= DataStream<Stream, Mode, time_t >::data_stream(ds, p_sendTime);
204 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_id);
205 b &= DataStream<Stream, Mode, bool >::data_stream(ds, p_isConfirmationNeeded);
206 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_sender);
207 b &= DataStream<Stream, Mode, std::vector<PString> >::data_stream(ds, p_vecRecver);
208 b &= DataStream<Stream, Mode, MessageType::MessageType >::data_stream(ds, p_type);
210 return b;
211 }
212
213 protected:
214 void copyMessage(const Message & other);
215 private:
220 size_t p_id;
224 PString p_sender;
226 std::vector<PString> p_vecRecver;
231};
232
233template<>
235
237template<typename Stream, DataStreamMode::DataStreamMode Mode>
238struct DataStream<Stream, Mode, Swarm::Message>{
240
244 static bool data_stream(Stream & ds, Swarm::Message & data){
245 return data.readWriteStream<Stream, Mode>(ds);
246 }
247};
248
250template<>
251struct CheckStream<Swarm::Message>{
252 static bool check_stream(const std::string & fieldDescription, const Swarm::Message & data, const Swarm::Message & reference, std::ostream & out);
253};
254
255
256
257
260 public:
261 VecStat();
262 virtual ~VecStat();
263 VecStat(const VecStat & other);
264 VecStat & operator = (const VecStat & other);
265 void setNbEvent(const std::vector<size_t> & nbEvent);
266 void setStartTimestamp(const std::vector<time_t> & startTimestamp);
267 void setEndTimestamp(const std::vector<time_t> & endTimestamp);
268 void setMin(const std::vector<float> & min);
269 void setMax(const std::vector<float> & max);
270 void setAverage(const std::vector<float> & average);
271 void setRate(const std::vector<float> & rate);
272 void setVecRateQuantile(const std::vector<std::vector<float> > & vecRateQuantile);
273 void setRateEventBelowLowerBound(const std::vector<float> & rateEventBelowLowerBound);
274 void setRateEventAboveUpperBound(const std::vector<float> & rateEventAboveUpperBound);
275 const std::vector<size_t> & getNbEvent() const;
276 std::vector<size_t> & getNbEvent();
277 const std::vector<time_t> & getStartTimestamp() const;
278 std::vector<time_t> & getStartTimestamp();
279 const std::vector<time_t> & getEndTimestamp() const;
280 std::vector<time_t> & getEndTimestamp();
281 const std::vector<float> & getMin() const;
282 std::vector<float> & getMin();
283 const std::vector<float> & getMax() const;
284 std::vector<float> & getMax();
285 const std::vector<float> & getAverage() const;
286 std::vector<float> & getAverage();
287 const std::vector<float> & getRate() const;
288 std::vector<float> & getRate();
289 const std::vector<std::vector<float> > & getVecRateQuantile() const;
290 std::vector<std::vector<float> > & getVecRateQuantile();
291 const std::vector<float> & getRateEventBelowLowerBound() const;
292 std::vector<float> & getRateEventBelowLowerBound();
293 const std::vector<float> & getRateEventAboveUpperBound() const;
294 std::vector<float> & getRateEventAboveUpperBound();
295
297
300 template<typename Stream, DataStreamMode::DataStreamMode Mode>
301 bool readWriteStream(Stream & ds){
302 bool b(true);
303 b &= DataStream<Stream, Mode, std::vector<size_t> >::data_stream(ds, p_nbEvent);
304 b &= DataStream<Stream, Mode, std::vector<time_t> >::data_stream(ds, p_startTimestamp);
305 b &= DataStream<Stream, Mode, std::vector<time_t> >::data_stream(ds, p_endTimestamp);
306 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_min);
307 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_max);
308 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_average);
309 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_rate);
310 b &= DataStream<Stream, Mode, std::vector<std::vector<float> > >::data_stream(ds, p_vecRateQuantile);
311 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_rateEventBelowLowerBound);
312 b &= DataStream<Stream, Mode, std::vector<float> >::data_stream(ds, p_rateEventAboveUpperBound);
313 return b;
314 }
315
316 protected:
317 void copyVecStat(const VecStat & other);
318 private:
321 std::vector<size_t> p_nbEvent;
323 std::vector<time_t> p_startTimestamp;
325 std::vector<time_t> p_endTimestamp;
327 std::vector<float> p_min;
329 std::vector<float> p_max;
331 std::vector<float> p_average;
333 std::vector<float> p_rate;
335 std::vector<std::vector<float> > p_vecRateQuantile;
337 std::vector<float> p_rateEventBelowLowerBound;
339 std::vector<float> p_rateEventAboveUpperBound;
340};
341
342template<>
344
346template<typename Stream, DataStreamMode::DataStreamMode Mode>
347struct DataStream<Stream, Mode, Swarm::VecStat>{
349
353 static bool data_stream(Stream & ds, Swarm::VecStat & data){
354 return data.readWriteStream<Stream, Mode>(ds);
355 }
356};
357
359template<>
360struct CheckStream<Swarm::VecStat>{
361 static bool check_stream(const std::string & fieldDescription, const Swarm::VecStat & data, const Swarm::VecStat & reference, std::ostream & out);
362};
363
364
365
366
369 public:
370 Stat();
371 virtual ~Stat();
372 Stat(const Stat & other);
373 Stat & operator = (const Stat & other);
374 void setName(const PString & name);
375 void setMapStatComputing(const std::map<PString, Swarm::VecStat > & mapStatComputing);
376 void setMapStatCommunication(const std::map<DaemonName, std::map<DataType, Swarm::VecStat > > & mapStatCommunication);
377 const PString & getName() const;
378 PString & getName();
379 const std::map<PString, Swarm::VecStat > & getMapStatComputing() const;
380 std::map<PString, Swarm::VecStat > & getMapStatComputing();
381 const std::map<DaemonName, std::map<DataType, Swarm::VecStat > > & getMapStatCommunication() const;
382 std::map<DaemonName, std::map<DataType, Swarm::VecStat > > & getMapStatCommunication();
383
385
388 template<typename Stream, DataStreamMode::DataStreamMode Mode>
389 bool readWriteStream(Stream & ds){
390 bool b(true);
391 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_name);
392 b &= DataStream<Stream, Mode, std::map<PString, Swarm::VecStat > >::data_stream(ds, p_mapStatComputing);
393 b &= DataStream<Stream, Mode, std::map<DaemonName, std::map<DataType, Swarm::VecStat > > >::data_stream(ds, p_mapStatCommunication);
394 return b;
395 }
396
397 protected:
398 void copyStat(const Stat & other);
399 private:
400 void initialisationStat();
402 PString p_name;
404 std::map<PString, Swarm::VecStat > p_mapStatComputing;
406 std::map<DaemonName, std::map<DataType, Swarm::VecStat > > p_mapStatCommunication;
407};
408
409template<>
411
413template<typename Stream, DataStreamMode::DataStreamMode Mode>
414struct DataStream<Stream, Mode, Swarm::Stat>{
416
420 static bool data_stream(Stream & ds, Swarm::Stat & data){
421 return data.readWriteStream<Stream, Mode>(ds);
422 }
423};
424
426template<>
427struct CheckStream<Swarm::Stat>{
428 static bool check_stream(const std::string & fieldDescription, const Swarm::Stat & data, const Swarm::Stat & reference, std::ostream & out);
429};
430
431
432
433
436 public:
438 virtual ~StatAccumulator();
439 StatAccumulator(const StatAccumulator & other);
441 void setNbEvent(size_t nbEvent);
442 void setSum(float sum);
443 void setMin(float min);
444 void setMax(float max);
445 void setVecHistogram(const std::vector<size_t> & vecHistogram);
446 void setHistLowerBound(float histLowerBound);
447 void setHistUpperBound(float histUpperBound);
448 void setNbEventBelowLowerBound(size_t nbEventBelowLowerBound);
449 void setNbEventAboveUpperBound(size_t nbEventAboveUpperBound);
450 size_t getNbEvent() const;
451 size_t & getNbEvent();
452 float getSum() const;
453 float & getSum();
454 float getMin() const;
455 float & getMin();
456 float getMax() const;
457 float & getMax();
458 const std::vector<size_t> & getVecHistogram() const;
459 std::vector<size_t> & getVecHistogram();
460 float getHistLowerBound() const;
461 float & getHistLowerBound();
462 float getHistUpperBound() const;
463 float & getHistUpperBound();
464 size_t getNbEventBelowLowerBound() const;
465 size_t & getNbEventBelowLowerBound();
466 size_t getNbEventAboveUpperBound() const;
467 size_t & getNbEventAboveUpperBound();
468
470
473 template<typename Stream, DataStreamMode::DataStreamMode Mode>
474 bool readWriteStream(Stream & ds){
475 bool b(true);
476 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_nbEvent);
477 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_sum);
478 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_min);
479 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_max);
480 b &= DataStream<Stream, Mode, std::vector<size_t> >::data_stream(ds, p_vecHistogram);
481 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_histLowerBound);
482 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_histUpperBound);
483 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_nbEventBelowLowerBound);
484 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_nbEventAboveUpperBound);
485 return b;
486 }
487
488 protected:
489 void copyStatAccumulator(const StatAccumulator & other);
490 private:
493 size_t p_nbEvent;
495 float p_sum;
497 float p_min;
499 float p_max;
501 std::vector<size_t> p_vecHistogram;
510};
511
512template<>
514
516template<typename Stream, DataStreamMode::DataStreamMode Mode>
517struct DataStream<Stream, Mode, Swarm::StatAccumulator>{
519
523 static bool data_stream(Stream & ds, Swarm::StatAccumulator & data){
524 return data.readWriteStream<Stream, Mode>(ds);
525 }
526};
527
529template<>
530struct CheckStream<Swarm::StatAccumulator>{
531 static bool check_stream(const std::string & fieldDescription, const Swarm::StatAccumulator & data, const Swarm::StatAccumulator & reference, std::ostream & out);
532};
533
534
535
536
539 public:
541 virtual ~DaemonStatAccumulator();
544 void setMapStatComputing(const std::map<PString, Swarm::StatAccumulator > & mapStatComputing);
545 void setMapStatCommunication(const std::map<DaemonName, std::map<DataType, Swarm::StatAccumulator > > & mapStatCommunication);
546 const std::map<PString, Swarm::StatAccumulator > & getMapStatComputing() const;
547 std::map<PString, Swarm::StatAccumulator > & getMapStatComputing();
548 const std::map<DaemonName, std::map<DataType, Swarm::StatAccumulator > > & getMapStatCommunication() const;
549 std::map<DaemonName, std::map<DataType, Swarm::StatAccumulator > > & getMapStatCommunication();
550
552
555 template<typename Stream, DataStreamMode::DataStreamMode Mode>
556 bool readWriteStream(Stream & ds){
557 bool b(true);
558 b &= DataStream<Stream, Mode, std::map<PString, Swarm::StatAccumulator > >::data_stream(ds, p_mapStatComputing);
559 b &= DataStream<Stream, Mode, std::map<DaemonName, std::map<DataType, Swarm::StatAccumulator > > >::data_stream(ds, p_mapStatCommunication);
560 return b;
561 }
562
563 protected:
565 private:
568 std::map<PString, Swarm::StatAccumulator > p_mapStatComputing;
570 std::map<DaemonName, std::map<DataType, Swarm::StatAccumulator > > p_mapStatCommunication;
571};
572
573template<>
575
577template<typename Stream, DataStreamMode::DataStreamMode Mode>
578struct DataStream<Stream, Mode, Swarm::DaemonStatAccumulator>{
580
584 static bool data_stream(Stream & ds, Swarm::DaemonStatAccumulator & data){
585 return data.readWriteStream<Stream, Mode>(ds);
586 }
587};
588
590template<>
591struct CheckStream<Swarm::DaemonStatAccumulator>{
592 static bool check_stream(const std::string & fieldDescription, const Swarm::DaemonStatAccumulator & data, const Swarm::DaemonStatAccumulator & reference, std::ostream & out);
593};
594
595
596
597
600 public:
601 DaemonConfig();
602 virtual ~DaemonConfig();
603 DaemonConfig(const DaemonConfig & other);
604 DaemonConfig & operator = (const DaemonConfig & other);
605 void setHostName(const PString & hostName);
606 void setReceivingPort(size_t receivingPort);
607 void setName(const PString & name);
608 void setDescription(const PString & description);
609 void setMapTimeout(const std::map<PString, time_t> & mapTimeout);
610 void setStatNbBin(size_t statNbBin);
611 void setStatHistLowerBound(float statHistLowerBound);
612 void setStatHistUpperBound(float statHistUpperBound);
613 void setStatTimerPeriodMs(const time_t & statTimerPeriodMs);
614 void setDaemonStatAccumulator(const Swarm::DaemonStatAccumulator & daemonStatAccumulator);
615 void setStatDaemonName(const PString & statDaemonName);
616 const PString & getHostName() const;
617 PString & getHostName();
618 size_t getReceivingPort() const;
619 size_t & getReceivingPort();
620 const PString & getName() const;
621 PString & getName();
622 const PString & getDescription() const;
623 PString & getDescription();
624 const std::map<PString, time_t> & getMapTimeout() const;
625 std::map<PString, time_t> & getMapTimeout();
626 size_t getStatNbBin() const;
627 size_t & getStatNbBin();
628 float getStatHistLowerBound() const;
629 float & getStatHistLowerBound();
630 float getStatHistUpperBound() const;
631 float & getStatHistUpperBound();
632 const time_t & getStatTimerPeriodMs() const;
633 time_t & getStatTimerPeriodMs();
636 const PString & getStatDaemonName() const;
637 PString & getStatDaemonName();
638
640
643 template<typename Stream, DataStreamMode::DataStreamMode Mode>
644 bool readWriteStream(Stream & ds){
645 bool b(true);
646 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_hostName);
647 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_receivingPort);
648 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_name);
649 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_description);
650 b &= DataStream<Stream, Mode, std::map<PString, time_t> >::data_stream(ds, p_mapTimeout);
651 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_statNbBin);
652 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_statHistLowerBound);
653 b &= DataStream<Stream, Mode, float >::data_stream(ds, p_statHistUpperBound);
654 b &= DataStream<Stream, Mode, time_t >::data_stream(ds, p_statTimerPeriodMs);
656 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_statDaemonName);
657 return b;
658 }
659
660 protected:
661 void copyDaemonConfig(const DaemonConfig & other);
662 private:
665 PString p_hostName;
669 PString p_name;
673 std::map<PString, time_t> p_mapTimeout;
686};
687
688template<>
690
692template<typename Stream, DataStreamMode::DataStreamMode Mode>
693struct DataStream<Stream, Mode, Swarm::DaemonConfig>{
695
699 static bool data_stream(Stream & ds, Swarm::DaemonConfig & data){
700 return data.readWriteStream<Stream, Mode>(ds);
701 }
702};
703
705template<>
706struct CheckStream<Swarm::DaemonConfig>{
707 static bool check_stream(const std::string & fieldDescription, const Swarm::DaemonConfig & data, const Swarm::DaemonConfig & reference, std::ostream & out);
708};
709
710
711
712
713
714
715#endif
716
std::string phoenix_getTypeName< Swarm::Data >()
std::string phoenix_getTypeName< Swarm::Function >()
std::string phoenix_getTypeName< Swarm::DaemonStatAccumulator >()
std::string phoenix_getTypeName< Swarm::Message >()
std::string phoenix_getTypeName< Swarm::DaemonConfig >()
std::string phoenix_getTypeName< Swarm::StatAccumulator >()
std::string phoenix_getTypeName< Swarm::Stat >()
std::string phoenix_getTypeName< Swarm::VecStat >()
Describe a Daemon of the Swarm.
const PString & getName() const
Gets the name of the DaemonConfig.
DaemonConfig()
Constructor of class DaemonConfig.
float p_statHistLowerBound
Lower bound for the histogram of the communication statistics.
DaemonConfig & operator=(const DaemonConfig &other)
Operator = of class DaemonConfig.
size_t getStatNbBin() const
Gets the statNbBin of the DaemonConfig.
const Swarm::DaemonStatAccumulator & getDaemonStatAccumulator() const
Gets the daemonStatAccumulator of the DaemonConfig.
void setDescription(const PString &description)
Sets the description of the DaemonConfig.
const time_t & getStatTimerPeriodMs() const
Gets the statTimerPeriodMs of the DaemonConfig.
PString p_description
Description of the Daemon.
time_t p_statTimerPeriodMs
Period (in ms) to send statistics to the stat daemon.
const PString & getStatDaemonName() const
Gets the statDaemonName of the DaemonConfig.
PString p_hostName
Name of the host where the daemon is running.
const PString & getDescription() const
Gets the description of the DaemonConfig.
void setStatHistLowerBound(float statHistLowerBound)
Sets the statHistLowerBound of the DaemonConfig.
float p_statHistUpperBound
Upper bound for the histogram of the communication statistics.
const std::map< PString, time_t > & getMapTimeout() const
Gets the mapTimeout of the DaemonConfig.
virtual ~DaemonConfig()
Destructor of class DaemonConfig.
void setStatHistUpperBound(float statHistUpperBound)
Sets the statHistUpperBound of the DaemonConfig.
float getStatHistLowerBound() const
Gets the statHistLowerBound of the DaemonConfig.
void setReceivingPort(size_t receivingPort)
Sets the receivingPort of the DaemonConfig.
Swarm::DaemonStatAccumulator p_daemonStatAccumulator
Accumulator used to create statistics of the current Daemon.
void setName(const PString &name)
Sets the name of the DaemonConfig.
void setDaemonStatAccumulator(const Swarm::DaemonStatAccumulator &daemonStatAccumulator)
Sets the daemonStatAccumulator of the DaemonConfig.
std::map< PString, time_t > p_mapTimeout
Map of the timeout for each daemon in the configuration file.
PString p_statDaemonName
Name of the Daemon which is used to gather statistics of the swarm (empty if no stat daemon is used)
size_t p_statNbBin
Number of bin for the histogram of the communication statistics.
void setStatDaemonName(const PString &statDaemonName)
Sets the statDaemonName of the DaemonConfig.
float getStatHistUpperBound() const
Gets the statHistUpperBound of the DaemonConfig.
const PString & getHostName() const
Gets the hostName of the DaemonConfig.
void copyDaemonConfig(const DaemonConfig &other)
Copy Function of class DaemonConfig.
size_t getReceivingPort() const
Gets the receivingPort of the DaemonConfig.
void initialisationDaemonConfig()
Initialisation Function of class DaemonConfig.
bool readWriteStream(Stream &ds)
Load the current DaemonConfig with a stream.
size_t p_receivingPort
Port which is used by the Daemon to receive messages.
void setHostName(const PString &hostName)
Sets the hostName of the DaemonConfig.
PString p_name
Name of the Daemon.
void setStatTimerPeriodMs(const time_t &statTimerPeriodMs)
Sets the statTimerPeriodMs of the DaemonConfig.
void setMapTimeout(const std::map< PString, time_t > &mapTimeout)
Sets the mapTimeout of the DaemonConfig.
void setStatNbBin(size_t statNbBin)
Sets the statNbBin of the DaemonConfig.
Accumulator of all events occurence on a Daemon (processing functions and communication latencies) to...
void initialisationDaemonStatAccumulator()
Initialisation Function of class DaemonStatAccumulator.
void setMapStatCommunication(const std::map< DaemonName, std::map< DataType, Swarm::StatAccumulator > > &mapStatCommunication)
Sets the mapStatCommunication of the DaemonStatAccumulator.
DaemonStatAccumulator & operator=(const DaemonStatAccumulator &other)
Operator = of class DaemonStatAccumulator.
void setMapStatComputing(const std::map< PString, Swarm::StatAccumulator > &mapStatComputing)
Sets the mapStatComputing of the DaemonStatAccumulator.
DaemonStatAccumulator()
Constructor of class DaemonStatAccumulator.
std::map< PString, Swarm::StatAccumulator > p_mapStatComputing
Map of the computing statistics (key: stat name, value vector of stat)
bool readWriteStream(Stream &ds)
Load the current DaemonStatAccumulator with a stream.
void copyDaemonStatAccumulator(const DaemonStatAccumulator &other)
Copy Function of class DaemonStatAccumulator.
std::map< DaemonName, std::map< DataType, Swarm::StatAccumulator > > p_mapStatCommunication
Map of the communication statistics (key: destination daemon name, value: {key: data type,...
const std::map< PString, Swarm::StatAccumulator > & getMapStatComputing() const
Gets the mapStatComputing of the DaemonStatAccumulator.
virtual ~DaemonStatAccumulator()
Destructor of class DaemonStatAccumulator.
const std::map< DaemonName, std::map< DataType, Swarm::StatAccumulator > > & getMapStatCommunication() const
Gets the mapStatCommunication of the DaemonStatAccumulator.
Basic Data exchanged in the swarm.
PString p_type
Type of the Data.
PString p_name
Name of the Data.
bool readWriteStream(Stream &ds)
Load the current Data with a stream.
DataStreamMsg p_value
Value of the Data.
void initialisationData()
Initialisation Function of class Data.
void setValue(const DataStreamMsg &value)
Sets the value of the Data.
const PString & getDescription() const
Gets the description of the Data.
void setType(const PString &type)
Sets the type of the Data.
PString p_description
Description of the Data.
const PString & getType() const
Gets the type of the Data.
virtual ~Data()
Destructor of class Data.
const DataStreamMsg & getValue() const
Gets the value of the Data.
Data & operator=(const Data &other)
Operator = of class Data.
void setDescription(const PString &description)
Sets the description of the Data.
const PString & getName() const
Gets the name of the Data.
void copyData(const Data &other)
Copy Function of class Data.
void setName(const PString &name)
Sets the name of the Data.
Data()
Constructor of class Data.
Basic function which can be called from an other Daemon.
void setVecParam(const std::vector< Swarm::Data > &vecParam)
Sets the vecParam of the Function.
const PString & getName() const
Gets the name of the Function.
virtual ~Function()
Destructor of class Function.
void copyFunction(const Function &other)
Copy Function of class Function.
std::vector< Swarm::Data > p_vecParam
Vector of parameters of the Function.
void setReturnValue(const Swarm::Data &returnValue)
Sets the returnValue of the Function.
bool readWriteStream(Stream &ds)
Load the current Function with a stream.
void setName(const PString &name)
Sets the name of the Function.
const std::vector< Swarm::Data > & getVecParam() const
Gets the vecParam of the Function.
PString p_description
Description of the Function.
PString p_name
Name of the Function.
Function & operator=(const Function &other)
Operator = of class Function.
void setDescription(const PString &description)
Sets the description of the Function.
void initialisationFunction()
Initialisation Function of class Function.
const PString & getDescription() const
Gets the description of the Function.
Function()
Constructor of class Function.
const Swarm::Data & getReturnValue() const
Gets the returnValue of the Function.
Swarm::Data p_returnValue
Return value of the Function.
Message exchanged by Daemons.
bool p_isConfirmationNeeded
True if the MESSAGE_CONFIRMATION is needed.
const PString & getSender() const
Gets the sender of the Message.
void setData(const Swarm::Data &data)
Sets the data of the Message.
void setVecRecver(const std::vector< PString > &vecRecver)
Sets the vecRecver of the Message.
bool readWriteStream(Stream &ds)
Load the current Message with a stream.
virtual ~Message()
Destructor of class Message.
Message & operator=(const Message &other)
Operator = of class Message.
void copyMessage(const Message &other)
Copy Function of class Message.
Message()
Constructor of class Message.
PString p_sender
Address of the Daemon which sends the message.
void setType(const MessageType::MessageType &type)
Sets the type of the Message.
const std::vector< PString > & getVecRecver() const
Gets the vecRecver of the Message.
size_t p_id
Id of the message (will be usefull to trigger method when a transmission is confirmed)
void setSendTime(const time_t &sendTime)
Sets the sendTime of the Message.
std::vector< PString > p_vecRecver
Addresses of Daemons which receive the message.
const Swarm::Data & getData() const
Gets the data of the Message.
void initialisationMessage()
Initialisation Function of class Message.
time_t p_sendTime
Time when the message was sent.
void setSender(const PString &sender)
Sets the sender of the Message.
size_t getId() const
Gets the id of the Message.
bool getIsConfirmationNeeded() const
Gets the isConfirmationNeeded of the Message.
Swarm::Data p_data
Data in the message.
void setIsConfirmationNeeded(bool isConfirmationNeeded)
Sets the isConfirmationNeeded of the Message.
void setId(size_t id)
Sets the id of the Message.
const MessageType::MessageType & getType() const
Gets the type of the Message.
const time_t & getSendTime() const
Gets the sendTime of the Message.
MessageType::MessageType p_type
Type of the message.
Accumulator of event occurence to build swarm statistics over a time period.
float getHistUpperBound() const
Gets the histUpperBound of the StatAccumulator.
void setMin(float min)
Sets the min of the StatAccumulator.
float getSum() const
Gets the sum of the StatAccumulator.
bool readWriteStream(Stream &ds)
Load the current StatAccumulator with a stream.
float p_histLowerBound
Minimum value in the histogram.
float p_histUpperBound
Maximum value in the histogram.
void setVecHistogram(const std::vector< size_t > &vecHistogram)
Sets the vecHistogram of the StatAccumulator.
void initialisationStatAccumulator()
Initialisation Function of class StatAccumulator.
float p_sum
Sum of all values.
size_t p_nbEvent
Number of events used to make this statistic.
size_t getNbEvent() const
Gets the nbEvent of the StatAccumulator.
float getMax() const
Gets the max of the StatAccumulator.
size_t getNbEventAboveUpperBound() const
Gets the nbEventAboveUpperBound of the StatAccumulator.
float getMin() const
Gets the min of the StatAccumulator.
float getHistLowerBound() const
Gets the histLowerBound of the StatAccumulator.
void setHistUpperBound(float histUpperBound)
Sets the histUpperBound of the StatAccumulator.
void setMax(float max)
Sets the max of the StatAccumulator.
StatAccumulator & operator=(const StatAccumulator &other)
Operator = of class StatAccumulator.
float p_min
Minimum value of the stat.
StatAccumulator()
Constructor of class StatAccumulator.
void copyStatAccumulator(const StatAccumulator &other)
Copy Function of class StatAccumulator.
void setNbEventAboveUpperBound(size_t nbEventAboveUpperBound)
Sets the nbEventAboveUpperBound of the StatAccumulator.
void setHistLowerBound(float histLowerBound)
Sets the histLowerBound of the StatAccumulator.
virtual ~StatAccumulator()
Destructor of class StatAccumulator.
std::vector< size_t > p_vecHistogram
Histogram to acccumulate event counts per quantile.
void setNbEventBelowLowerBound(size_t nbEventBelowLowerBound)
Sets the nbEventBelowLowerBound of the StatAccumulator.
void setSum(float sum)
Sets the sum of the StatAccumulator.
float p_max
Maximum value of the stat.
size_t p_nbEventBelowLowerBound
Number of events below the lower bound.
size_t getNbEventBelowLowerBound() const
Gets the nbEventBelowLowerBound of the StatAccumulator.
const std::vector< size_t > & getVecHistogram() const
Gets the vecHistogram of the StatAccumulator.
size_t p_nbEventAboveUpperBound
Number of events above the upper boundary.
void setNbEvent(size_t nbEvent)
Sets the nbEvent of the StatAccumulator.
Statistics of a Daemon.
virtual ~Stat()
Destructor of class Stat.
std::map< DaemonName, std::map< DataType, Swarm::VecStat > > p_mapStatCommunication
Map of the communication statistics (key: destination daemon name, value: {key: data type,...
std::map< PString, Swarm::VecStat > p_mapStatComputing
Map of the computing statistics (key: stat name, value vector of stat)
void setName(const PString &name)
Sets the name of the Stat.
void initialisationStat()
Initialisation Function of class Stat.
void copyStat(const Stat &other)
Copy Function of class Stat.
const std::map< DaemonName, std::map< DataType, Swarm::VecStat > > & getMapStatCommunication() const
Gets the mapStatCommunication of the Stat.
Stat & operator=(const Stat &other)
Operator = of class Stat.
void setMapStatCommunication(const std::map< DaemonName, std::map< DataType, Swarm::VecStat > > &mapStatCommunication)
Sets the mapStatCommunication of the Stat.
PString p_name
Name of the Daemon where the stats come from.
void setMapStatComputing(const std::map< PString, Swarm::VecStat > &mapStatComputing)
Sets the mapStatComputing of the Stat.
bool readWriteStream(Stream &ds)
Load the current Stat with a stream.
Stat()
Constructor of class Stat.
const PString & getName() const
Gets the name of the Stat.
const std::map< PString, Swarm::VecStat > & getMapStatComputing() const
Gets the mapStatComputing of the Stat.
General statistics in the swarm.
std::vector< float > p_min
Minimum value of the stat.
void setVecRateQuantile(const std::vector< std::vector< float > > &vecRateQuantile)
Sets the vecRateQuantile of the VecStat.
const std::vector< float > & getMax() const
Gets the max of the VecStat.
const std::vector< time_t > & getEndTimestamp() const
Gets the endTimestamp of the VecStat.
std::vector< float > p_average
Mean of the stat.
void setEndTimestamp(const std::vector< time_t > &endTimestamp)
Sets the endTimestamp of the VecStat.
void setMin(const std::vector< float > &min)
Sets the min of the VecStat.
const std::vector< float > & getRate() const
Gets the rate of the VecStat.
void setNbEvent(const std::vector< size_t > &nbEvent)
Sets the nbEvent of the VecStat.
void setStartTimestamp(const std::vector< time_t > &startTimestamp)
Sets the startTimestamp of the VecStat.
void setRateEventAboveUpperBound(const std::vector< float > &rateEventAboveUpperBound)
Sets the rateEventAboveUpperBound of the VecStat.
void setRate(const std::vector< float > &rate)
Sets the rate of the VecStat.
VecStat & operator=(const VecStat &other)
Operator = of class VecStat.
const std::vector< time_t > & getStartTimestamp() const
Gets the startTimestamp of the VecStat.
virtual ~VecStat()
Destructor of class VecStat.
std::vector< float > p_rateEventAboveUpperBound
Number of events above the upper boundary per second.
std::vector< time_t > p_startTimestamp
Timestamp where this stat started to be accumulated by the clock of the current daemon (TODO: need un...
const std::vector< float > & getAverage() const
Gets the average of the VecStat.
const std::vector< float > & getRateEventBelowLowerBound() const
Gets the rateEventBelowLowerBound of the VecStat.
bool readWriteStream(Stream &ds)
Load the current VecStat with a stream.
const std::vector< float > & getRateEventAboveUpperBound() const
Gets the rateEventAboveUpperBound of the VecStat.
std::vector< time_t > p_endTimestamp
Timestamp where this stat was finished to be accumulated by the clock of the current daemon (TODO: ne...
std::vector< float > p_rateEventBelowLowerBound
Number of events below the lower boundary per second.
std::vector< std::vector< float > > p_vecRateQuantile
Vector of binned event rate per quantile (quartile decile, etc)
std::vector< float > p_max
Maximum value of the stat.
std::vector< size_t > p_nbEvent
Number of events used to make this statistic.
std::vector< float > p_rate
Number of events per second.
const std::vector< float > & getMin() const
Gets the min of the VecStat.
void setRateEventBelowLowerBound(const std::vector< float > &rateEventBelowLowerBound)
Sets the rateEventBelowLowerBound of the VecStat.
void copyVecStat(const VecStat &other)
Copy Function of class VecStat.
VecStat()
Constructor of class VecStat.
void initialisationVecStat()
Initialisation Function of class VecStat.
const std::vector< size_t > & getNbEvent() const
Gets the nbEvent of the VecStat.
const std::vector< std::vector< float > > & getVecRateQuantile() const
Gets the vecRateQuantile of the VecStat.
void setMax(const std::vector< float > &max)
Sets the max of the VecStat.
void setAverage(const std::vector< float > &average)
Sets the average of the VecStat.
MessageType
Type of the Message which can be exchanged by Daemon.
Definition MessageType.h:16
static bool check_stream(const std::string &fieldDescription, const Swarm::DaemonConfig &data, const Swarm::DaemonConfig &reference, std::ostream &out)
Check Stream for a DaemonConfig.
static bool check_stream(const std::string &fieldDescription, const Swarm::DaemonStatAccumulator &data, const Swarm::DaemonStatAccumulator &reference, std::ostream &out)
Check Stream for a DaemonStatAccumulator.
static bool check_stream(const std::string &fieldDescription, const Swarm::Data &data, const Swarm::Data &reference, std::ostream &out)
Check Stream for a Data.
static bool check_stream(const std::string &fieldDescription, const Swarm::Function &data, const Swarm::Function &reference, std::ostream &out)
Check Stream for a Function.
static bool check_stream(const std::string &fieldDescription, const Swarm::Message &data, const Swarm::Message &reference, std::ostream &out)
Check Stream for a Message.
static bool check_stream(const std::string &fieldDescription, const Swarm::StatAccumulator &data, const Swarm::StatAccumulator &reference, std::ostream &out)
Check Stream for a StatAccumulator.
static bool check_stream(const std::string &fieldDescription, const Swarm::Stat &data, const Swarm::Stat &reference, std::ostream &out)
Check Stream for a Stat.
static bool check_stream(const std::string &fieldDescription, const Swarm::VecStat &data, const Swarm::VecStat &reference, std::ostream &out)
Check Stream for a VecStat.
static bool data_stream(Stream &ds, Swarm::DaemonConfig &data)
Generic function to load/save/serialise/deserialise DaemonConfig.
static bool data_stream(Stream &ds, Swarm::DaemonStatAccumulator &data)
Generic function to load/save/serialise/deserialise DaemonStatAccumulator.
static bool data_stream(Stream &ds, Swarm::Data &data)
Generic function to load/save/serialise/deserialise Data.
static bool data_stream(Stream &ds, Swarm::Function &data)
Generic function to load/save/serialise/deserialise Function.
static bool data_stream(Stream &ds, Swarm::Message &data)
Generic function to load/save/serialise/deserialise Message.
static bool data_stream(Stream &ds, Swarm::StatAccumulator &data)
Generic function to load/save/serialise/deserialise StatAccumulator.
static bool data_stream(Stream &ds, Swarm::Stat &data)
Generic function to load/save/serialise/deserialise Stat.
static bool data_stream(Stream &ds, Swarm::VecStat &data)
Generic function to load/save/serialise/deserialise VecStat.
PString DaemonName