PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
data_stream_read_message.h
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 #ifndef __DATA_STREAM_READ_MESSAGE_H__
8 #define __DATA_STREAM_READ_MESSAGE_H__
9 
10 #include "data_stream_include.h"
11 
12 
14 template<typename T>
15 struct DataStream<DataStreamIter,DataStreamMode::READ, std::vector<T> >{
17 
21  static bool data_stream(DataStreamIter & ds, std::vector<T> & data){
22  //Get the number of elements
23  size_t nbElement(0lu);
25  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
26  for(size_t i(0lu); i < nbElement && b; ++i){
27  T tmp;
29  data.push_back(tmp);
30  }
31  return b;
32  }
33 };
34 
36 template<typename T>
37 struct DataStream<DataStreamIter,DataStreamMode::READ, std::list<T> >{
39 
43  static bool data_stream(DataStreamIter & ds, std::list<T> & data){
44  //Get the number of elements
45  size_t nbElement(0lu);
47  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
48  for(size_t i(0lu); i < nbElement && b; ++i){
49  T tmp;
51  data.push_back(tmp);
52  }
53  return b;
54  }
55 };
56 
58 template<typename T, typename U>
59 struct DataStream<DataStreamIter,DataStreamMode::READ, std::map<T, U> >{
61 
65  static bool data_stream(DataStreamIter & ds, std::map<T, U> & data){
66  //Get the number of elements
67  size_t nbElement(0lu);
69  if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
70  for(size_t i(0lu); i < nbElement && b; ++i){
71  T tmpFirst;
73  U tmpSecond;
75  data[tmpFirst] = tmpSecond; //Add data in map
76  }
77  return b;
78  }
79 };
80 
82 template<typename T, typename U>
83 struct DataStream<DataStreamIter,DataStreamMode::READ, std::pair<T, U> >{
85 
89  static bool data_stream(DataStreamIter & ds, std::pair<T, U> & data){
90  T tmpFirst;
92  U tmpSecond;
94  data = std::pair<T, U>(tmpFirst, tmpSecond);
95  return b;
96  }
97 };
98 
99 
100 
101 #endif
102 
103 
DataStreamType * DataStreamIter
static bool data_stream(DataStreamIter &ds, std::list< T > &data)
Get the size of a class std::list T.
static bool data_stream(DataStreamIter &ds, std::map< T, U > &data)
Get the size of a class std::list T.
static bool data_stream(DataStreamIter &ds, std::pair< T, U > &data)
Get the size of a class std::list T.
static bool data_stream(DataStreamIter &ds, std::vector< T > &data)
Get the size of a class std::vector T.
Generic DataStream class.
static bool data_stream(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.