PhoenixSwarm  6.1.0
Persistent processing programs exchanging data over sockets
Loading...
Searching...
No Matches
Shadok.h
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#ifndef __SHADOK_H__
8#define __SHADOK_H__
9
10#include <string>
11#include "phoenix_data_stream.h"
12#include "phoenix_type_stream.h"
13
15class Shadok{
16 public:
17 Shadok();
18 Shadok(const Shadok & other);
19 virtual ~Shadok();
20 Shadok & operator = (const Shadok & other);
21 void setAge(int age);
22 void setName(const std::string & name);
23 int getAge() const;
24 int & getAge();
25 const std::string & getName() const;
26 std::string & getName();
27
29
32 template<typename Stream, DataStreamMode::DataStreamMode Mode>
33 bool readWriteStream(Stream & ds){
34 bool b(true);
35 b &= DataStream<Stream, Mode, int >::data_stream(ds, p_age);
36 b &= DataStream<Stream, Mode, std::string >::data_stream(ds, p_name);
37 return b;
38 }
39
40 protected:
41 void copyShadok(const Shadok & other);
42 private:
45 int p_age;
47 std::string p_name;
48};
49
51template<typename Stream, DataStreamMode::DataStreamMode Mode>
52struct DataStream<Stream, Mode, Shadok>{
54
58 static bool data_stream(Stream & ds, Shadok & data){
59 return data.readWriteStream<Stream, Mode>(ds);
60 }
61};
62
63
64
65template<>
66std::string phoenix_getTypeName<Shadok>();
67
68
69
70#endif
71
std::string phoenix_getTypeName< Shadok >()
Get the name of the class Shadok.
Definition Shadok.cpp:14
Test Shadok.
Definition Shadok.h:15
void setAge(int age)
Sets the age of the Shadok.
Definition Shadok.cpp:47
void copyShadok(const Shadok &other)
Copy Function of class Shadok.
Definition Shadok.cpp:89
const std::string & getName() const
Gets the name of the Shadok.
Definition Shadok.cpp:75
int p_age
Age of the Shadok.
Definition Shadok.h:45
Shadok & operator=(const Shadok &other)
Operator = of class Shadok.
Definition Shadok.cpp:39
int getAge() const
Gets the age of the Shadok.
Definition Shadok.cpp:61
void initialisationShadok()
Initialisation Function of class Shadok.
Definition Shadok.cpp:95
std::string p_name
Name of the Shadok.
Definition Shadok.h:47
void setName(const std::string &name)
Sets the name of the Shadok.
Definition Shadok.cpp:54
Shadok()
Constructor of class Shadok.
Definition Shadok.cpp:19
bool readWriteStream(Stream &ds)
Load the current Shadok with a stream.
Definition Shadok.h:33
static bool data_stream(Stream &ds, Shadok &data)
Generic function to load/save/serialise/deserialise Shadok.
Definition Shadok.h:58