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