PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "phoenix_data_stream.h"
8 
9 
10 namespace ShadokType{
12  enum ShadokType{
13  NONE = 0, //Nothing to do
14  HAUT = 1, //Shadok from the top of the planet
15  BAS = 2 //Shadok from the bottom of the planet
16  };
17 }
18 
20 template<typename Stream>
23 
27  static bool data_stream(Stream & ds, ShadokType::ShadokType & data){
28  int value(0);
30  data = (ShadokType::ShadokType)value;
31  return b;
32  }
33 };
34 
36 template<typename Stream>
39 
43  static bool data_stream(Stream & ds, ShadokType::ShadokType & data){
44  int value = (int)data;
46  }
47 };
48 
49 
53  size_t shadokSize(data_size(type));
54  data_stream_assert(checkValue("testShadokTypeSize", shadokSize, 4lu));
55 }
56 
60 
61  DataStreamMsg messageIn(data_size(type));
62  DataStreamIter iter = (DataStreamIter)messageIn.data();
64 
67  DataStreamIter iterOut = (DataStreamIter)messageIn.data();
69 
70  data_stream_assert(checkValue("testShadokMessage", out, type));
71 }
72 
76  std::string fileName("ShadokType.data");
77  data_save(fileName, type);
78 
81  data_load(fileName, out);
82 
83  data_stream_assert(checkValue("testShadokFile", out, type));
84 }
85 
86 
87 int main(int argc, char** argv){
91  return 0;
92 }
93 
int main(int argc, char **argv)
Definition: main.cpp:228
void testShadokTypeFile()
Test the Shadok message.
Definition: main.cpp:74
void testShadokTypeMessage()
Test the Shadok message.
Definition: main.cpp:58
void testShadokTypeSize()
Test the Shadok size.
Definition: main.cpp:51
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
bool data_message_save(DataStreamIter &iter, T &data)
Save data in a message.
Definition: data_message.h:18
bool data_message_load(DataStreamIter &iter, T &data)
Load data from a message.
Definition: data_message.h:60
size_t data_size(T &data)
Get size of data.
Definition: data_size.h:17
#define data_stream_assert(isOk)
bool checkValue(const std::string &testName, const T &givenSize, const T &referenceSize)
Check given value compare to the reference value.
std::vector< DataStreamType > DataStreamMsg
DataStreamType * DataStreamIter
ShadokType
Type of the Shadok we want to serialized.
Definition: main.cpp:12
@ HAUT
Definition: main.cpp:14
@ NONE
Definition: main.cpp:13
static bool data_stream(Stream &ds, ShadokType::ShadokType &data)
Generic function to load/deserialise ShadokType.
Definition: main.cpp:27
static bool data_stream(Stream &ds, ShadokType::ShadokType &data)
Generic function to save/serialise ShadokType.
Definition: main.cpp:43
Generic DataStream class.
static bool data_stream(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.