PhoenixSwarm  5.1.1
Library to ease communication between daemons
Loading...
Searching...
No Matches
Daemon.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 __DAEMON_H__
8#define __DAEMON_H__
9
11#include "DaemonEmptyBackend.h"
12#include "BaseDaemon.h"
13#include "PTimer.h"
14
16template<class _TBackend>
18 public:
19 Daemon();
20 virtual ~Daemon();
21
22 void setSocketMode(PSocketMode::PSocketMode mode);
23 void setClockMode(PClockMode::PClockMode mode);
24 PRecvStatus::PRecvStatus checkRecvStatus(PRecvStatus::PRecvStatus recvStatus);
25 void checkSendStatus(PSendStatus::PSendStatus sendStatus);
26 bool run();
27
28 bool sendMessage(const Swarm::Message & message);
29 bool sendMessage(const PString & destinationName, const Swarm::Message & message);
30
32
37 template<typename T>
38 bool sendValue(const PString & destinationName, const T & data, bool isConfirmationNeeded = true){
39 return sendData(destinationName, phoenix_createData(data), isConfirmationNeeded);
40 }
41
42 bool sendData(const PString & destinationName, const Swarm::Data & data, bool isConfirmationNeeded);
43
44 virtual void extraLoopProcessing();
45 virtual void executeOnStop();
46
47 protected:
49 _TBackend p_backend;
54
55 void processInputMessage(Swarm::Message & message);
56
57 private:
60 void sendStatToStatDaemon(time_t currentTime);
61
62};
63
64#include "Daemon_impl.h"
65
66
67#endif
68
Daemon which help communication between processes and thread.
Definition BaseDaemon.h:54
Class which describes a Daemon with connections to other daemons.
Definition Daemon.h:17
virtual void extraLoopProcessing()
Computing Method for each event loop (when receiving message from other Daemon)
bool sendMessage(const Swarm::Message &message)
Send message to other Daemon.
void initialisationDaemonSocket()
Initialise the Daemon Sockets.
Daemon()
Default constructor of Daemon.
Definition Daemon_impl.h:17
virtual void executeOnStop()
Method which is called on stop of the Daemon.
bool sendData(const PString &destinationName, const Swarm::Data &data, bool isConfirmationNeeded)
Send data to other Daemon (specialization for Data)
void setClockMode(PClockMode::PClockMode mode)
Set the mode of the clock.
Definition Daemon_impl.h:55
void initialisationDaemon()
Initialisation function of the class Daemon.
void setSocketMode(PSocketMode::PSocketMode mode)
Set the mode of the sockets of the SocketManager.
Definition Daemon_impl.h:33
void checkSendStatus(PSendStatus::PSendStatus sendStatus)
Check the status of recv sockets.
PTimer p_statTimer
Timer to send statistics to the Stat Daemon.
Definition Daemon.h:51
void processInputMessage(Swarm::Message &message)
Process an input message.
PRecvStatus::PRecvStatus checkRecvStatus(PRecvStatus::PRecvStatus recvStatus)
Check the status of recv sockets.
Definition Daemon_impl.h:77
bool sendValue(const PString &destinationName, const T &data, bool isConfirmationNeeded=true)
Send data to other Daemon.
Definition Daemon.h:38
_TBackend p_backend
Full backend of the Daemon (for Socket and clock)
Definition Daemon.h:49
time_t p_startTimestamp
Start timestamp of the current accumulation of statistics.
Definition Daemon.h:53
bool run()
Run the Daemon.
virtual ~Daemon()
Destructor of Daemon.
Definition Daemon_impl.h:25
void sendStatToStatDaemon(time_t currentTime)
Send the statistics of the Daemon to the Stat Daemon.
Basic Data exchanged in the swarm.
Message exchanged by Daemons.
Swarm::Data phoenix_createData(const T &value)
Create a Data from a value.