Line |
Branch |
Exec |
Source |
1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __SHADOK_H__ |
8 |
|
|
#define __SHADOK_H__ |
9 |
|
|
|
10 |
|
|
#include "data_all.h" |
11 |
|
|
|
12 |
|
|
#include "phoenix_type_stream.h" |
13 |
|
|
|
14 |
|
|
///@brief Test Shadok |
15 |
|
|
class 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 |
|
|
|
28 |
|
|
///Load the current Shadok with a stream |
29 |
|
|
/** @param[out] ds : stream to be used |
30 |
|
|
* @return true on success, false otherwise |
31 |
|
|
*/ |
32 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
33 |
|
6 |
bool readWriteStream(Stream & ds){ |
34 |
|
6 |
bool b(true); |
35 |
|
6 |
b &= DataStream<Stream, Mode, int >::data_stream(ds, p_age); |
36 |
|
6 |
b &= DataStream<Stream, Mode, std::string >::data_stream(ds, p_name); |
37 |
|
6 |
return b; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
protected: |
41 |
|
|
void copyShadok(const Shadok & other); |
42 |
|
|
private: |
43 |
|
|
void initialisationShadok(); |
44 |
|
|
///Age of the Shadok |
45 |
|
|
int p_age; |
46 |
|
|
///Name of the Shadok |
47 |
|
|
std::string p_name; |
48 |
|
|
}; |
49 |
|
|
|
50 |
|
|
///@brief Generic Shadok serialisation/deserialisation, load/save and size function |
51 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
52 |
|
|
struct DataStream<Stream, Mode, Shadok>{ |
53 |
|
|
///Generic function to load/save/serialise/deserialise Shadok |
54 |
|
|
/** @param data : Shadok to be used |
55 |
|
|
* @return true on success, false otherwise |
56 |
|
|
*/ |
57 |
|
3 |
static bool data_stream(Stream & ds, Shadok & data){ |
58 |
|
3 |
return data.readWriteStream<Stream, Mode>(ds); |
59 |
|
|
} |
60 |
|
|
}; |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
template<> |
65 |
|
|
std::string phoenix_getTypeName<Shadok>(); |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
#endif |
70 |
|
|
|
71 |
|
|
|