PhoenixSwarm  3.5.0
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>
17class Daemon : public BaseDaemon{
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 Message & message);
29 bool sendMessage(const PString & destinationName, const 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 Data & data, bool isConfirmationNeeded);
43
44 virtual void extraLoopProcessing();
45 virtual void executeOnStop();
46
47 protected:
49 _TBackend p_backend;
54
55 void processInputMessage(Message & message);
56
57 private:
60 void sendStatToStatDaemon(time_t currentTime);
61
62};
63
64#include "Daemon_impl.h"
65
66
67#endif
68
BaseDaemon()
Default constructor of BaseDaemon.
_TBackend p_backend
Full backend of the Daemon (for Socket and clock)
Definition Daemon.h:49
bool sendValue(const PString &destinationName, const T &data, bool isConfirmationNeeded=true)
Send data to other Daemon.
Definition Daemon.h:38
PTimer p_statTimer
Timer to send statistics to the Stat Daemon.
Definition Daemon.h:51
Daemon()
Default constructor of Daemon.
Definition Daemon_impl.h:15
virtual void executeOnStop()
Method which is called on stop of the Daemon.
void sendStatToStatDaemon(time_t currentTime)
Send the statistics of the Daemon to the Stat Daemon.
PRecvStatus::PRecvStatus checkRecvStatus(PRecvStatus::PRecvStatus recvStatus)
Check the status of recv sockets.
Definition Daemon_impl.h:75
time_t p_startTimestamp
Start timestamp of the current accumulation of statistics.
Definition Daemon.h:53
virtual ~Daemon()
Destructor of Daemon.
Definition Daemon_impl.h:23
void setSocketMode(PSocketMode::PSocketMode mode)
Set the mode of the sockets of the SocketManager.
Definition Daemon_impl.h:31
bool sendData(const PString &destinationName, const Data &data, bool isConfirmationNeeded)
Send data to other Daemon (specialization for Data)
bool sendMessage(const Message &message)
Send message to other Daemon.
void processInputMessage(Message &message)
Process an input message.
virtual void extraLoopProcessing()
Computing Method for each event loop (when receiving message from other Daemon)
void setClockMode(PClockMode::PClockMode mode)
Set the mode of the clock.
Definition Daemon_impl.h:53
void initialisationDaemon()
Initialisation function of the class Daemon.
bool run()
Run the Daemon.
void initialisationDaemonSocket()
Initialise the Daemon Sockets.
void checkSendStatus(PSendStatus::PSendStatus sendStatus)
Check the status of recv sockets.
Basic Data exchanged in the swarm.
Message exchanged by Daemons.
Data phoenix_createData(const T &value)
Create a Data from a value.