| 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 | 26 | static bool data_stream(DataStreamIter & ds, std::vector<T> & data){ | |
| 22 | //Get the number of elements | ||
| 23 | 26 | size_t nbElement(0lu); | |
| 24 |
1/1✓ Branch 0 (2→3) taken 26 times.
|
26 | bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
| 25 |
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 |
| 26 |
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){ |
| 27 | 130 | T tmp; | |
| 28 |
1/1✓ Branch 0 (7→8) taken 260 times.
|
260 | b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmp); |
| 29 |
1/1✓ Branch 0 (8→9) taken 260 times.
|
260 | data.push_back(tmp); |
| 30 | } | ||
| 31 | 26 | 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 | 26 | static bool data_stream(DataStreamIter & ds, std::list<T> & data){ | |
| 44 | //Get the number of elements | ||
| 45 | 26 | size_t nbElement(0lu); | |
| 46 |
1/1✓ Branch 0 (2→3) taken 26 times.
|
26 | bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
| 47 |
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 |
| 48 |
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){ |
| 49 | 130 | T tmp; | |
| 50 |
1/1✓ Branch 0 (7→8) taken 260 times.
|
260 | b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmp); |
| 51 |
1/1✓ Branch 0 (8→9) taken 260 times.
|
260 | data.push_back(tmp); |
| 52 | } | ||
| 53 | 26 | 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 |
1/1✓ Branch 0 (2→3) taken 13 times.
|
13 | bool b = DataStream<DataStreamIter,DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
| 69 |
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 |
| 70 |
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){ |
| 71 | T tmpFirst; | ||
| 72 |
1/1✓ Branch 0 (7→8) taken 130 times.
|
130 | b &= DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmpFirst); |
| 73 | U tmpSecond; | ||
| 74 |
1/1✓ Branch 0 (8→9) taken 130 times.
|
130 | b &= DataStream<DataStreamIter,DataStreamMode::READ, U>::data_stream(ds, tmpSecond); |
| 75 |
1/1✓ Branch 0 (9→10) taken 130 times.
|
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 |
1/1✓ Branch 0 (2→3) taken 260 times.
|
260 | bool b = DataStream<DataStreamIter,DataStreamMode::READ, T>::data_stream(ds, tmpFirst); |
| 92 | U tmpSecond; | ||
| 93 |
1/1✓ Branch 0 (3→4) taken 260 times.
|
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 |