Line |
Branch |
Exec |
Source |
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 |
|
|
|
10 |
|
|
#include "DaemonEmptyBackend.h" |
11 |
|
|
#include "BaseDaemon.h" |
12 |
|
|
|
13 |
|
|
///@brief Class which describes a Daemon with connections to other daemons |
14 |
|
|
template<class _TBackend> |
15 |
|
|
class Daemon : public BaseDaemon{ |
16 |
|
|
public: |
17 |
|
|
Daemon(); |
18 |
|
|
virtual ~Daemon(); |
19 |
|
|
|
20 |
|
|
void setSocketMode(PSocketMode::PSocketMode mode); |
21 |
|
|
void setClockMode(PClockMode::PClockMode mode); |
22 |
|
|
bool run(); |
23 |
|
|
|
24 |
|
|
bool recieveData(const PString & senderName, const Data & data); |
25 |
|
|
bool sendMessage(const Message & message); |
26 |
|
|
bool sendMessage(const PString & destinationName, const Message & message); |
27 |
|
|
|
28 |
|
|
///Send data to other Daemon |
29 |
|
|
/** @param destinationName : name of the destination Daemon of the data |
30 |
|
|
* @param data : data to be sent |
31 |
|
|
* @param isConfirmationNeeded : true if a confirmation is needed |
32 |
|
|
* @return true on success, false otherwise (maybe recieved method does not exist) |
33 |
|
|
*/ |
34 |
|
|
template<typename T> |
35 |
|
✗ |
bool sendValue(const PString & destinationName, const T & data, bool isConfirmationNeeded = false){ |
36 |
|
✗ |
return sendData(destinationName, phoenix_createData(data), isConfirmationNeeded); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
bool sendData(const PString & destinationName, const Data & data, bool isConfirmationNeeded = false); |
40 |
|
|
|
41 |
|
|
virtual void extraLoopProcessing(); |
42 |
|
|
virtual void executeOnStop(); |
43 |
|
|
|
44 |
|
|
private: |
45 |
|
|
void initialisationDaemon(); |
46 |
|
|
void initialisationDaemonSocket(); |
47 |
|
|
void processInputMessage(Message & message); |
48 |
|
|
|
49 |
|
|
///Full backend of the Daemon (for Socket and clock) |
50 |
|
|
_TBackend p_backend; |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
#include "Daemon_impl.h" |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
#endif |
59 |
|
|
|
60 |
|
|
|