| 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_WRITE_MESSAGE_H__ | ||
| 8 | #define __DATA_STREAM_WRITE_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::WRITE, 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 | //Save the size of the data | ||
| 23 | 26 | size_t nbElement(data.size()); | |
| 24 |
1/1✓ Branch 0 (3→4) taken 26 times.
|
26 | bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
| 25 |
2/4✓ Branch 0 (4→5) taken 26 times.
✗ Branch 1 (4→6) not taken.
✗ Branch 2 (5→6) not taken.
✓ Branch 3 (5→7) taken 26 times.
|
26 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
| 26 |
2/2✓ Branch 0 (21→8) taken 260 times.
✓ Branch 1 (21→22) taken 26 times.
|
572 | for(typename std::vector<T>::iterator it(data.begin()); it != data.end(); ++it){ |
| 27 |
1/1✓ Branch 0 (10→11) taken 260 times.
|
260 | b &= DataStream<DataStreamIter, DataStreamMode::WRITE, T>::data_stream(ds, *it); |
| 28 | } | ||
| 29 | 26 | return b; | |
| 30 | } | ||
| 31 | }; | ||
| 32 | |||
| 33 | ///@brief How to write a class in a stream | ||
| 34 | template<typename T> | ||
| 35 | struct DataStream<DataStreamIter, DataStreamMode::WRITE, std::list<T> >{ | ||
| 36 | ///Get the size of a class std::list T | ||
| 37 | /** @param[out] ds : stream to write the class std::list T | ||
| 38 | * @param data : data to be saved | ||
| 39 | * @return true on success, false otherwise | ||
| 40 | */ | ||
| 41 | 26 | static bool data_stream(DataStreamIter & ds, std::list<T> & data){ | |
| 42 | //Save the size of the data | ||
| 43 | 26 | size_t nbElement(data.size()); | |
| 44 |
1/1✓ Branch 0 (3→4) taken 26 times.
|
26 | bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
| 45 |
2/4✓ Branch 0 (4→5) taken 26 times.
✗ Branch 1 (4→6) not taken.
✗ Branch 2 (5→6) not taken.
✓ Branch 3 (5→7) taken 26 times.
|
26 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
| 46 |
2/2✓ Branch 0 (13→8) taken 260 times.
✓ Branch 1 (13→14) taken 26 times.
|
286 | for(typename std::list<T>::iterator it(data.begin()); it != data.end(); ++it){ |
| 47 |
1/1✓ Branch 0 (9→10) taken 260 times.
|
260 | b &= DataStream<DataStreamIter, DataStreamMode::WRITE, T>::data_stream(ds, *it); |
| 48 | } | ||
| 49 | 26 | return b; | |
| 50 | } | ||
| 51 | }; | ||
| 52 | |||
| 53 | ///@brief How to write a class in a stream | ||
| 54 | template<typename T, typename U> | ||
| 55 | struct DataStream<DataStreamIter, DataStreamMode::WRITE, std::map<T, U> >{ | ||
| 56 | ///Get the size of a class std::list T | ||
| 57 | /** @param[out] ds : stream to write the class std::map T U | ||
| 58 | * @param data : data to be saved | ||
| 59 | * @return true on success, false otherwise | ||
| 60 | */ | ||
| 61 | 13 | static bool data_stream(DataStreamIter & ds, std::map<T, U> & data){ | |
| 62 | //Save the size of the data | ||
| 63 | 13 | size_t nbElement(data.size()); | |
| 64 |
1/1✓ Branch 0 (3→4) taken 13 times.
|
13 | bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
| 65 |
2/4✓ Branch 0 (4→5) taken 13 times.
✗ Branch 1 (4→6) not taken.
✗ Branch 2 (5→6) not taken.
✓ Branch 3 (5→7) taken 13 times.
|
13 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
| 66 |
2/2✓ Branch 0 (15→8) taken 130 times.
✓ Branch 1 (15→16) taken 13 times.
|
143 | for(typename std::map<T, U>::iterator it(data.begin()); it != data.end(); ++it){ |
| 67 |
1/1✓ Branch 0 (9→10) taken 130 times.
|
130 | b &= DataStream<DataStreamIter, DataStreamMode::WRITE, T>::data_stream(ds, (T&)it->first); |
| 68 |
1/1✓ Branch 0 (11→12) taken 130 times.
|
130 | b &= DataStream<DataStreamIter, DataStreamMode::WRITE, U>::data_stream(ds, it->second); |
| 69 | } | ||
| 70 | 13 | return b; | |
| 71 | } | ||
| 72 | }; | ||
| 73 | |||
| 74 | ///@brief How to write a class in a stream | ||
| 75 | template<typename T, typename U> | ||
| 76 | struct DataStream<DataStreamIter, DataStreamMode::WRITE, std::pair<T, U> >{ | ||
| 77 | ///Get the size of a class std::list T | ||
| 78 | /** @param[out] ds : stream to write the class std::pair T | ||
| 79 | * @param data : data to be saved | ||
| 80 | * @return true on success, false otherwise | ||
| 81 | */ | ||
| 82 | 260 | static bool data_stream(DataStreamIter & ds, std::pair<T, U> & data){ | |
| 83 | 260 | bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, T>::data_stream(ds, (T&)data.first); | |
| 84 | 260 | b &= DataStream<DataStreamIter, DataStreamMode::WRITE, U>::data_stream(ds, data.second); | |
| 85 | 260 | return b; | |
| 86 | } | ||
| 87 | }; | ||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | #endif | ||
| 92 | |||
| 93 | |||
| 94 |