PhoenixSwarm
6.1.0
Persistent processing programs exchanging data over sockets
Toggle main menu visibility
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : LGPL-3.0-only
5
****************************************/
6
7
#include <iostream>
8
#include <functional>
9
#include "phoenix_assert.h"
10
#include "phoenix_check.h"
11
12
#include "
Shadok.h
"
13
#include "
ProcessClass.h
"
14
#include "
Daemon.h
"
15
#include "
DaemonSlot.h
"
16
17
#include "
DaemonEmptyBackend.h
"
18
19
typedef
Daemon<DaemonEmptyBackend>
TestDaemon
;
20
22
25
PUncastableBool
testShadokProcessing
(
const
Shadok
& shadok){
26
//Let's do something
27
std::cout <<
"testShadokProcessing : we are processing a Shadok"
<< std::endl;
28
//I do not know what it was, but is was OK
29
return
UNCASTABLE_TRUE;
30
}
31
33
36
PUncastableBool
testIntProcessing
(
const
int
& value){
37
//Let's do something
38
std::cout <<
"testIntProcessing : we are processing an int"
<< std::endl;
39
//I do not know what it was, but is was OK
40
return
UNCASTABLE_TRUE;
41
}
42
44
46
void
testBaseDaemonLoadConfig
(
const
PPath & fileName){
47
TestDaemon
daemon;
48
daemon.
setSocketMode
(PSocketMode::MOCK);
49
daemon.
setClockMode
(PClockMode::MOCK);
50
daemon.
getLog
().setLogLevel(PLog::DEBUG);
51
daemon.
getLog
().setFileName(PPath(
"Daemon.log"
));
52
phoenix_assert(daemon.
getLog
().open());
53
phoenix_assert(daemon.
addDataCallableMethod
(
testShadokProcessing
, 0, 0.f, 0.f));
54
phoenix_assert(daemon.
addDataCallableMethod
(
testIntProcessing
, 0, 0.f, 0.f));
55
//Add a non static method
56
ProcessClass
processClass;
57
phoenix_assert(daemon.
addDataCallableMethod
(ProcessClass::SWARM_SLOT(fillLong), processClass, 10lu, 0.0, 1e6));
58
phoenix_assert(daemon.
addDataCallableMethod
(ProcessClass::SWARM_SLOT(fillShort), processClass, 0, 0.f, 0.f));
59
//The function is added already
60
// phoenix_assert(!daemon.addCallableMethod(testCallFunction, "testCallFunction"));
61
62
int
value(42);
63
Data
dataInt(
phoenix_createData
(value));
64
phoenix_assert(daemon.
processData
(dataInt));
65
66
Shadok
shadok;
67
shadok.
setAge
(42);
68
shadok.
setName
(
"Shadoko"
);
69
Data
data(
phoenix_createData
(shadok));
70
phoenix_assert(daemon.
processData
(data));
71
72
long
longValue(42);
73
Data
dataLong(
phoenix_createData
(longValue));
74
phoenix_assert(daemon.
processData
(dataLong));
75
76
short
shortValue(42);
77
Data
dataShort(
phoenix_createData
(shortValue));
78
phoenix_assert(daemon.
processData
(dataShort));
79
}
80
82
void
testDaemonSlot
(){
83
DaemonSlot
daemon;
84
daemon.
setSocketMode
(PSocketMode::MOCK);
85
daemon.
setClockMode
(PClockMode::MOCK);
86
daemon.
getLog
().setLogLevel(PLog::DEBUG);
87
daemon.
getLog
().setFileName(PPath(
"DaemonSlot.log"
));
88
phoenix_assert(daemon.
getLog
().open());
89
daemon.
addCallMethod
();
90
int
value(42);
91
Data
dataInt(
phoenix_createData
(value));
92
phoenix_assert(daemon.
processData
(dataInt));
93
}
94
95
int
main
(
int
argc,
char
** argv){
96
testBaseDaemonLoadConfig
(PPath(DAEMON_CONFIG_OK));
97
testDaemonSlot
();
98
return
0;
99
}
100
101
DaemonEmptyBackend.h
DaemonSlot.h
Daemon.h
ProcessClass.h
Shadok.h
main
int main(int argc, char **argv)
Definition
main.cpp:21
testBaseDaemonLoadConfig
void testBaseDaemonLoadConfig(const PPath &fileName)
Test the load configuration of a Daemon.
Definition
main.cpp:46
testDaemonSlot
void testDaemonSlot()
Test the DaemonSlot.
Definition
main.cpp:82
testIntProcessing
PUncastableBool testIntProcessing(const int &value)
Process a Shadok.
Definition
main.cpp:36
TestDaemon
Daemon< DaemonEmptyBackend > TestDaemon
Definition
main.cpp:19
testShadokProcessing
PUncastableBool testShadokProcessing(const Shadok &shadok)
Process a Shadok.
Definition
main.cpp:25
DaemonSlot
class test to use a Daemon
Definition
DaemonSlot.h:16
DaemonSlot::addCallMethod
virtual void addCallMethod()
Add all call Daemon.
Definition
DaemonSlot.cpp:32
ProcessClass
Test ProcessClass.
Definition
ProcessClass.h:16
Shadok
Test Shadok.
Definition
Shadok.h:15
Shadok::setAge
void setAge(int age)
Sets the age of the Shadok.
Definition
Shadok.cpp:47
Shadok::setName
void setName(const std::string &name)
Sets the name of the Shadok.
Definition
Shadok.cpp:54
Swarm::BaseDaemon::addDataCallableMethod
bool addDataCallableMethod(PUncastableBool(&function)(const _Data &), size_t nbBin, float histLowerBound, float histUpperBound)
Add a callable method of the Daemon.
Definition
BaseDaemon.h:105
Swarm::BaseDaemon::getLog
PLog & getLog()
Get the log of the current BaseDaemon.
Definition
BaseDaemon.cpp:160
Swarm::BaseDaemon::processData
bool processData(const Swarm::Data &data)
Process given data with the proper method.
Definition
BaseDaemon.cpp:282
Swarm::Daemon
Class which describes a Daemon with connections to other daemons.
Definition
Daemon.h:17
Swarm::Daemon::setClockMode
void setClockMode(PClockMode::PClockMode mode)
Set the mode of the clock.
Definition
Daemon_impl.h:55
Swarm::Daemon::setSocketMode
void setSocketMode(PSocketMode::PSocketMode mode)
Set the mode of the sockets of the SocketManager.
Definition
Daemon_impl.h:33
Swarm::Data
Basic Data exchanged in the swarm.
Definition
Representation.h:22
phoenix_createData
Swarm::Data phoenix_createData(const T &value)
Create a Data from a value.
Definition
phoenix_createData_impl.h:20
platex
TESTS
TEST_FUNCTIONS
TEST_DATA_PROCESSING
main.cpp
Generated by
1.18.0