| 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 <string> | ||
| 11 | #include "phoenix_data_stream.h" | ||
| 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 | 3 | bool readWriteStream(Stream & ds){ | |
| 34 | 3 | bool b(true); | |
| 35 | 3 | b &= DataStream<Stream, Mode, int >::data_stream(ds, p_age); | |
| 36 | 3 | b &= DataStream<Stream, Mode, std::string >::data_stream(ds, p_name); | |
| 37 | 3 | 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[out] ds : stream to be used | ||
| 55 | * @param data : Shadok to be used | ||
| 56 | * @return true on success, false otherwise | ||
| 57 | */ | ||
| 58 | 3 | static bool data_stream(Stream & ds, Shadok & data){ | |
| 59 | 3 | return data.readWriteStream<Stream, Mode>(ds); | |
| 60 | } | ||
| 61 | }; | ||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | template<> | ||
| 66 | std::string phoenix_getTypeName<Shadok>(); | ||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | #endif | ||
| 71 | |||
| 72 |