| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | |||
| 2 | /*************************************** | ||
| 3 | Auteur : Pierre Aubert | ||
| 4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 5 | Licence : CeCILL-C | ||
| 6 | ****************************************/ | ||
| 7 | |||
| 8 | #include "CppTraitDataStream.h" | ||
| 9 | |||
| 10 | ///Consctructor of CppTraitDataStream | ||
| 11 | 3 | CppTraitDataStream::CppTraitDataStream() | |
| 12 | 3 | :PAbstractTraitBackend() | |
| 13 | 3 | {} | |
| 14 | |||
| 15 | ///Desctructor of CppTraitDataStream | ||
| 16 | 6 | CppTraitDataStream::~CppTraitDataStream(){} | |
| 17 | |||
| 18 | ///Add extra include on the header | ||
| 19 | /** @param[out] fs : file to be completed | ||
| 20 | * @param mode : mode of the generator | ||
| 21 | */ | ||
| 22 | 4 | void CppTraitDataStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{ | |
| 23 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
|
4 | if(!mode.enableDataStream){return;} |
| 24 | 4 | fs << "#include \"phoenix_data_stream.h\"" << std::endl; | |
| 25 | } | ||
| 26 | |||
| 27 | ///Declaration of public methods | ||
| 28 | /** @param[out] fs : file to be completed | ||
| 29 | * @param classConfig : PClassConfig to be used | ||
| 30 | * @param mode : mode of the generator | ||
| 31 | */ | ||
| 32 | 4 | void CppTraitDataStream::publicMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 33 |
4/7✓ Branch 0 (2→3) taken 4 times.
✗ Branch 1 (2→5) not taken.
✓ Branch 2 (3→4) taken 4 times.
✗ Branch 4 (4→5) not taken.
✓ Branch 5 (4→6) taken 4 times.
✗ Branch 6 (7→8) not taken.
✓ Branch 7 (7→9) taken 4 times.
|
4 | if(!mode.enableDataStream || classConfig.getIsEnum()){return;} |
| 34 |
2/2✓ Branch 0 (9→10) taken 4 times.
✓ Branch 2 (10→11) taken 4 times.
|
4 | PString name(classConfig.getName()); |
| 35 |
1/1✓ Branch 0 (11→12) taken 4 times.
|
4 | fs << std::endl; |
| 36 |
4/4✓ Branch 0 (12→13) taken 4 times.
✓ Branch 2 (13→14) taken 4 times.
✓ Branch 4 (14→15) taken 4 times.
✓ Branch 6 (15→16) taken 4 times.
|
4 | fs << "\t\t///Load the current "<<name<<" with a stream" << std::endl; |
| 37 |
2/2✓ Branch 0 (16→17) taken 4 times.
✓ Branch 2 (17→18) taken 4 times.
|
4 | fs << "\t\t/** @param[out] ds : stream to be used" << std::endl; |
| 38 |
2/2✓ Branch 0 (18→19) taken 4 times.
✓ Branch 2 (19→20) taken 4 times.
|
4 | fs << "\t\t * @return true on success, false otherwise" << std::endl; |
| 39 |
2/2✓ Branch 0 (20→21) taken 4 times.
✓ Branch 2 (21→22) taken 4 times.
|
4 | fs << "\t\t*/" << std::endl; |
| 40 |
2/2✓ Branch 0 (22→23) taken 4 times.
✓ Branch 2 (23→24) taken 4 times.
|
4 | fs << "\t\ttemplate<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl; |
| 41 |
2/2✓ Branch 0 (24→25) taken 4 times.
✓ Branch 2 (25→26) taken 4 times.
|
4 | fs << "\t\tbool readWriteStream(Stream & ds){" << std::endl; |
| 42 |
2/2✓ Branch 0 (26→27) taken 4 times.
✓ Branch 2 (27→28) taken 4 times.
|
4 | fs << "\t\t\tbool b(true);" << std::endl; |
| 43 | |||
| 44 |
1/1✓ Branch 0 (28→29) taken 4 times.
|
4 | const PVecClassAttribute & vecAttr(classConfig.getListAttribute()); |
| 45 |
2/2✓ Branch 0 (52→30) taken 9 times.
✓ Branch 1 (52→53) taken 4 times.
|
26 | for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){ |
| 46 |
8/8✓ Branch 0 (30→31) taken 9 times.
✓ Branch 2 (33→34) taken 9 times.
✓ Branch 4 (34→35) taken 9 times.
✓ Branch 6 (35→36) taken 9 times.
✓ Branch 8 (38→39) taken 9 times.
✓ Branch 10 (39→40) taken 9 times.
✓ Branch 12 (40→41) taken 9 times.
✓ Branch 14 (41→42) taken 9 times.
|
27 | fs << "\t\t\tb &= DataStream<Stream, Mode, "<<it->getType()<<" >::data_stream(ds, p_" << it->getName() << ");" << std::endl; |
| 47 | } | ||
| 48 | |||
| 49 |
2/2✓ Branch 0 (53→54) taken 4 times.
✓ Branch 2 (54→55) taken 4 times.
|
4 | fs << "\t\t\treturn b;" << std::endl; |
| 50 |
3/3✓ Branch 0 (55→56) taken 4 times.
✓ Branch 2 (56→57) taken 4 times.
✓ Branch 4 (57→58) taken 4 times.
|
4 | fs << "\t\t}" << std::endl << std::endl; |
| 51 | 4 | } | |
| 52 | |||
| 53 | ///Implementation of public methods | ||
| 54 | /** @param[out] fs : file to be completed | ||
| 55 | * @param classConfig : PClassConfig to be used | ||
| 56 | * @param mode : mode of the generator | ||
| 57 | */ | ||
| 58 | 5 | void CppTraitDataStream::publicMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 59 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 5 times.
|
5 | if(!mode.enableDataStream){return;} |
| 60 | |||
| 61 | } | ||
| 62 | |||
| 63 | ///Declaration of protected methods | ||
| 64 | /** @param[out] fs : file to be completed | ||
| 65 | * @param classConfig : PClassConfig to be used | ||
| 66 | * @param mode : mode of the generator | ||
| 67 | */ | ||
| 68 | 4 | void CppTraitDataStream::protectedMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 69 | |||
| 70 | 4 | } | |
| 71 | |||
| 72 | ///Implementation of protected methods | ||
| 73 | /** @param[out] fs : file to be completed | ||
| 74 | * @param classConfig : PClassConfig to be used | ||
| 75 | * @param mode : mode of the generator | ||
| 76 | */ | ||
| 77 | 5 | void CppTraitDataStream::protectedMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 78 | |||
| 79 | 5 | } | |
| 80 | |||
| 81 | ///Declaration of private methods | ||
| 82 | /** @param[out] fs : file to be completed | ||
| 83 | * @param classConfig : PClassConfig to be used | ||
| 84 | * @param mode : mode of the generator | ||
| 85 | */ | ||
| 86 | 4 | void CppTraitDataStream::privateMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 87 | |||
| 88 | 4 | } | |
| 89 | |||
| 90 | ///Implementation of private methods | ||
| 91 | /** @param[out] fs : file to be completed | ||
| 92 | * @param classConfig : PClassConfig to be used | ||
| 93 | * @param mode : mode of the generator | ||
| 94 | */ | ||
| 95 | 5 | void CppTraitDataStream::privateMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 96 | |||
| 97 | 5 | } | |
| 98 | |||
| 99 | ///Declaration of extra functions | ||
| 100 | /** @param[out] fs : file to be completed | ||
| 101 | * @param classConfig : PClassConfig to be used | ||
| 102 | * @param mode : mode of the generator | ||
| 103 | */ | ||
| 104 | 5 | void CppTraitDataStream::classExtraFunctionDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 105 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 5 times.
|
6 | if(!mode.enableDataStream){return;} |
| 106 |
2/2✓ Branch 0 (4→5) taken 5 times.
✓ Branch 2 (5→6) taken 5 times.
|
5 | PString name(classConfig.getName()); |
| 107 |
3/3✓ Branch 0 (6→7) taken 5 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 3 (7→16) taken 4 times.
|
5 | if(classConfig.getIsEnum()){ |
| 108 |
7/7✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✓ Branch 4 (10→11) taken 1 times.
✓ Branch 6 (11→12) taken 1 times.
✓ Branch 8 (12→13) taken 1 times.
✓ Branch 10 (13→14) taken 1 times.
✓ Branch 12 (14→15) taken 1 times.
|
1 | fs << "PHOENIX_DATA_STREAM_ENUM("<<name<<"::"<<name<<")" << std::endl << std::endl; |
| 109 | 1 | return; | |
| 110 | } | ||
| 111 |
4/4✓ Branch 0 (16→17) taken 4 times.
✓ Branch 2 (17→18) taken 4 times.
✓ Branch 4 (18→19) taken 4 times.
✓ Branch 6 (19→20) taken 4 times.
|
4 | fs << "///@brief Generic "<<name<<" serialisation/deserialisation, load/save and size function for PhoenixDataStream" << std::endl; |
| 112 |
2/2✓ Branch 0 (20→21) taken 4 times.
✓ Branch 2 (21→22) taken 4 times.
|
4 | fs << "template<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl; |
| 113 |
4/4✓ Branch 0 (22→23) taken 4 times.
✓ Branch 2 (23→24) taken 4 times.
✓ Branch 4 (24→25) taken 4 times.
✓ Branch 6 (25→26) taken 4 times.
|
4 | fs << "struct DataStream<Stream, Mode, "<<name<<">{" << std::endl; |
| 114 |
3/3✓ Branch 0 (26→27) taken 4 times.
✓ Branch 2 (27→28) taken 4 times.
✓ Branch 4 (28→29) taken 4 times.
|
4 | fs << "\t///Generic function to load/save/serialise/deserialise "<<name << std::endl; |
| 115 |
2/2✓ Branch 0 (29→30) taken 4 times.
✓ Branch 2 (30→31) taken 4 times.
|
4 | fs << "\t/**\t@param[out] ds : stream to be used" << std::endl; |
| 116 |
4/4✓ Branch 0 (31→32) taken 4 times.
✓ Branch 2 (32→33) taken 4 times.
✓ Branch 4 (33→34) taken 4 times.
✓ Branch 6 (34→35) taken 4 times.
|
4 | fs << "\t * \t@param data : "<<name<<" to be used" << std::endl; |
| 117 |
2/2✓ Branch 0 (35→36) taken 4 times.
✓ Branch 2 (36→37) taken 4 times.
|
4 | fs << "\t * \t@return true on success, false otherwise" << std::endl; |
| 118 |
2/2✓ Branch 0 (37→38) taken 4 times.
✓ Branch 2 (38→39) taken 4 times.
|
4 | fs << "\t*/" << std::endl; |
| 119 |
4/4✓ Branch 0 (39→40) taken 4 times.
✓ Branch 2 (40→41) taken 4 times.
✓ Branch 4 (41→42) taken 4 times.
✓ Branch 6 (42→43) taken 4 times.
|
4 | fs << "\tstatic bool data_stream(Stream & ds, "<<name<<" & data){" << std::endl; |
| 120 |
2/2✓ Branch 0 (43→44) taken 4 times.
✓ Branch 2 (44→45) taken 4 times.
|
4 | fs << "\t\treturn data.readWriteStream<Stream, Mode>(ds);" << std::endl; |
| 121 |
2/2✓ Branch 0 (45→46) taken 4 times.
✓ Branch 2 (46→47) taken 4 times.
|
4 | fs << "\t}" << std::endl; |
| 122 |
3/3✓ Branch 0 (47→48) taken 4 times.
✓ Branch 2 (48→49) taken 4 times.
✓ Branch 4 (49→50) taken 4 times.
|
4 | fs << "};" << std::endl << std::endl; |
| 123 | 5 | } | |
| 124 | |||
| 125 | ///Implementation of extra functions | ||
| 126 | /** @param[out] fs : file to be completed | ||
| 127 | * @param classConfig : PClassConfig to be used | ||
| 128 | * @param mode : mode of the generator | ||
| 129 | */ | ||
| 130 | 5 | void CppTraitDataStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{ | |
| 131 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 5 times.
|
5 | if(!mode.enableDataStream){return;} |
| 132 | |||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 |