GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixDataStream/src/data_stream_read_message.h
Date: 2025-03-14 11:54:19
Exec Total Coverage
Lines: 32 32 100.0%
Branches: 16 22 72.7%

Line Branch Exec Source
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
13 ///@brief How to write a class in a stream
14 template<typename T>
15 struct DataStream<DataStreamIter,DataStreamMode::READ, std::vector<T> >{
16 ///Get the size of a class std::vector T
17 /** @param[out] ds : stream to write the class std::vector T
18 * @param data : data to be saved
19 * @return true on success, false otherwise
20 */
21 39 static bool data_stream(DataStreamIter & ds, std::vector<T> & data){
22 //Get the number of elements
23 39 size_t nbElement(0lu);
24
1/1
✓ Branch 1 taken 13 times.
39 bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
25
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
39 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
26
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
429 for(size_t i(0lu); i < nbElement && b; ++i){
27 260 T tmp;
28
1/1
✓ Branch 1 taken 130 times.
390 b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmp);
29
1/1
✓ Branch 1 taken 130 times.
390 data.push_back(tmp);
30 }
31 39 return b;
32 }
33 };
34
35 ///@brief How to write a class in a stream
36 template<typename T>
37 struct DataStream<DataStreamIter,DataStreamMode::READ, std::list<T> >{
38 ///Get the size of a class std::list T
39 /** @param[out] ds : stream to write the class std::list T
40 * @param data : data to be saved
41 * @return true on success, false otherwise
42 */
43 39 static bool data_stream(DataStreamIter & ds, std::list<T> & data){
44 //Get the number of elements
45 39 size_t nbElement(0lu);
46
1/1
✓ Branch 1 taken 13 times.
39 bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
47
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
39 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
48
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
429 for(size_t i(0lu); i < nbElement && b; ++i){
49 260 T tmp;
50
1/1
✓ Branch 1 taken 130 times.
390 b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmp);
51
1/1
✓ Branch 1 taken 130 times.
390 data.push_back(tmp);
52 }
53 39 return b;
54 }
55 };
56
57 ///@brief How to write a class in a stream
58 template<typename T, typename U>
59 struct DataStream<DataStreamIter,DataStreamMode::READ, std::map<T, U> >{
60 ///Get the size of a class std::list T
61 /** @param[out] ds : stream to write the class std::map T U
62 * @param data : data to be saved
63 * @return true on success, false otherwise
64 */
65 13 static bool data_stream(DataStreamIter & ds, std::map<T, U> & data){
66 //Get the number of elements
67 13 size_t nbElement(0lu);
68 13 bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
69 13 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
70 143 for(size_t i(0lu); i < nbElement && b; ++i){
71 T tmpFirst;
72 130 b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmpFirst);
73 U tmpSecond;
74 130 b &= DataStream<DataStreamIter,DataStreamMode::READ, U>::data_stream(ds, tmpSecond);
75 130 data[tmpFirst] = tmpSecond; //Add data in map
76 }
77 13 return b;
78 }
79 };
80
81 ///@brief How to write a class in a stream
82 template<typename T, typename U>
83 struct DataStream<DataStreamIter,DataStreamMode::READ, std::pair<T, U> >{
84 ///Get the size of a class std::list T
85 /** @param[out] ds : stream to write the class std::pair T
86 * @param data : data to be saved
87 * @return true on success, false otherwise
88 */
89 260 static bool data_stream(DataStreamIter & ds, std::pair<T, U> & data){
90 T tmpFirst;
91 260 bool b = DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmpFirst);
92 U tmpSecond;
93 260 b &= DataStream<DataStreamIter,DataStreamMode::READ, U>::data_stream(ds, tmpSecond);
94 260 data = std::pair<T, U>(tmpFirst, tmpSecond);
95 260 return b;
96 }
97 };
98
99
100
101 #endif
102
103
104