PhoenixSwarm  6.1.0
Persistent processing programs exchanging data over sockets
Loading...
Searching...
No Matches
main.cpp File Reference
#include <iostream>
#include <functional>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "Shadok.h"
#include "ProcessClass.h"
#include "Daemon.h"
#include "DaemonSlot.h"
#include "DaemonEmptyBackend.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Typedefs

typedef Daemon< DaemonEmptyBackend > TestDaemon

Functions

int main (int argc, char **argv)
void testBaseDaemonLoadConfig (const PPath &fileName)
 Test the load configuration of a Daemon.
void testDaemonSlot ()
 Test the DaemonSlot.
PUncastableBool testIntProcessing (const int &value)
 Process a Shadok.
PUncastableBool testShadokProcessing (const Shadok &shadok)
 Process a Shadok.

Typedef Documentation

◆ TestDaemon

Definition at line 19 of file main.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 95 of file main.cpp.

95 {
96 testBaseDaemonLoadConfig(PPath(DAEMON_CONFIG_OK));
98 return 0;
99}
void testBaseDaemonLoadConfig(const PPath &fileName)
Test the load configuration of a Daemon.
Definition main.cpp:46
void testDaemonSlot()
Test the DaemonSlot.
Definition main.cpp:82

References main(), testBaseDaemonLoadConfig(), and testDaemonSlot().

Here is the call graph for this function:

◆ testBaseDaemonLoadConfig()

void testBaseDaemonLoadConfig ( const PPath & fileName)

Test the load configuration of a Daemon.

Parameters
fileName: name of the configuration toml file

Definition at line 46 of file main.cpp.

46 {
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}
PUncastableBool testIntProcessing(const int &value)
Process a Shadok.
Definition main.cpp:36
Daemon< DaemonEmptyBackend > TestDaemon
Definition main.cpp:19
PUncastableBool testShadokProcessing(const Shadok &shadok)
Process a Shadok.
Definition main.cpp:25
Test ProcessClass.
Test Shadok.
Definition Shadok.h:15
void setAge(int age)
Sets the age of the Shadok.
Definition Shadok.cpp:47
void setName(const std::string &name)
Sets the name of the Shadok.
Definition Shadok.cpp:54
bool addDataCallableMethod(PUncastableBool(&function)(const _Data &), size_t nbBin, float histLowerBound, float histUpperBound)
Add a callable method of the Daemon.
Definition BaseDaemon.h:105
PLog & getLog()
Get the log of the current BaseDaemon.
bool processData(const Swarm::Data &data)
Process given data with the proper method.
void setClockMode(PClockMode::PClockMode mode)
Set the mode of the clock.
Definition Daemon_impl.h:55
void setSocketMode(PSocketMode::PSocketMode mode)
Set the mode of the sockets of the SocketManager.
Definition Daemon_impl.h:33
Basic Data exchanged in the swarm.
Swarm::Data phoenix_createData(const T &value)
Create a Data from a value.

References Swarm::BaseDaemon::addDataCallableMethod(), Swarm::BaseDaemon::getLog(), phoenix_createData(), Swarm::BaseDaemon::processData(), Shadok::setAge(), Swarm::Daemon< _TBackend >::setClockMode(), Shadok::setName(), Swarm::Daemon< _TBackend >::setSocketMode(), testBaseDaemonLoadConfig(), testIntProcessing(), and testShadokProcessing().

Referenced by main(), and testBaseDaemonLoadConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testDaemonSlot()

void testDaemonSlot ( )

Test the DaemonSlot.

Definition at line 82 of file main.cpp.

82 {
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}
class test to use a Daemon
Definition DaemonSlot.h:16
virtual void addCallMethod()
Add all call Daemon.

References DaemonSlot::addCallMethod(), Swarm::BaseDaemon::getLog(), phoenix_createData(), Swarm::BaseDaemon::processData(), Swarm::Daemon< _TBackend >::setClockMode(), Swarm::Daemon< _TBackend >::setSocketMode(), and testDaemonSlot().

Referenced by main(), and testDaemonSlot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testIntProcessing()

PUncastableBool testIntProcessing ( const int & value)

Process a Shadok.

Parameters
shadok: Shadok to be processed
Returns
true on success, false otherwise

Definition at line 36 of file main.cpp.

36 {
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}

References testIntProcessing().

Referenced by testBaseDaemonLoadConfig(), and testIntProcessing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testShadokProcessing()

PUncastableBool testShadokProcessing ( const Shadok & shadok)

Process a Shadok.

Parameters
shadok: Shadok to be processed
Returns
true on success, false otherwise

Definition at line 25 of file main.cpp.

25 {
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}

References testShadokProcessing().

Referenced by testBaseDaemonLoadConfig(), and testShadokProcessing().

Here is the call graph for this function:
Here is the caller graph for this function: