GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitConfigStream/CppTraitConfigStream.cpp
Date: 2026-06-23 11:27:41
Exec Total Coverage
Lines: 52 53 98.1%
Functions: 12 12 100.0%
Branches: 90 97 92.8%

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 "CppTraitConfigStream.h"
9
10 ///Consctructor of CppTraitConfigStream
11 4 CppTraitConfigStream::CppTraitConfigStream()
12 4 :PAbstractTraitBackend()
13 4 {}
14
15 ///Desctructor of CppTraitConfigStream
16 8 CppTraitConfigStream::~CppTraitConfigStream(){}
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 6 void CppTraitConfigStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 6 times.
6 if(!mode.enableConfigStream){return;}
24 6 fs << "#include \"phoenix_config_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 6 void CppTraitConfigStream::publicMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
33
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 6 times.
6 if(!mode.enableConfigStream){return;}
34
35 }
36
37 ///Implementation of public methods
38 /** @param[out] fs : file to be completed
39 * @param classConfig : PClassConfig to be used
40 * @param mode : mode of the generator
41 */
42 7 void CppTraitConfigStream::publicMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
43
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 7 times.
7 if(!mode.enableConfigStream){return;}
44
45 }
46
47 ///Declaration of protected methods
48 /** @param[out] fs : file to be completed
49 * @param classConfig : PClassConfig to be used
50 * @param mode : mode of the generator
51 */
52 6 void CppTraitConfigStream::protectedMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
53
54 6 }
55
56 ///Implementation of protected methods
57 /** @param[out] fs : file to be completed
58 * @param classConfig : PClassConfig to be used
59 * @param mode : mode of the generator
60 */
61 7 void CppTraitConfigStream::protectedMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
62
63 7 }
64
65 ///Declaration of private methods
66 /** @param[out] fs : file to be completed
67 * @param classConfig : PClassConfig to be used
68 * @param mode : mode of the generator
69 */
70 6 void CppTraitConfigStream::privateMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
71
72 6 }
73
74 ///Implementation of private methods
75 /** @param[out] fs : file to be completed
76 * @param classConfig : PClassConfig to be used
77 * @param mode : mode of the generator
78 */
79 7 void CppTraitConfigStream::privateMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
80
81 7 }
82
83 ///Declaration of extra functions
84 /** @param[out] fs : file to be completed
85 * @param classConfig : PClassConfig to be used
86 * @param mode : mode of the generator
87 */
88 7 void CppTraitConfigStream::classExtraFunctionDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
89
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 7 times.
7 if(!mode.enableConfigStream){return;}
90
2/2
✓ Branch 0 (4→5) taken 7 times.
✓ Branch 2 (5→6) taken 7 times.
7 PString name(classConfig.getName());
91
2/2
✓ Branch 0 (6→7) taken 7 times.
✓ Branch 2 (7→8) taken 7 times.
7 fs << "template<>" << std::endl;
92
7/7
✓ Branch 0 (8→9) taken 7 times.
✓ Branch 2 (9→10) taken 7 times.
✓ Branch 4 (10→11) taken 7 times.
✓ Branch 6 (11→12) taken 7 times.
✓ Branch 8 (12→13) taken 7 times.
✓ Branch 10 (13→14) taken 7 times.
✓ Branch 12 (14→15) taken 7 times.
7 fs << "bool phoenix_config_stream<"<<name<<">(ConfigNodeIter & iter, "<<name<<" & data, const GenericConfigCheck * checker);" << std::endl << std::endl;
93 7 }
94
95 ///Implementation of extra functions
96 /** @param[out] fs : file to be completed
97 * @param classConfig : PClassConfig to be used
98 * @param mode : mode of the generator
99 */
100 7 void CppTraitConfigStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
101
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 7 times.
7 if(!mode.enableConfigStream){return;}
102
103
2/2
✓ Branch 0 (4→5) taken 7 times.
✓ Branch 2 (5→6) taken 7 times.
7 PString name(classConfig.getName());
104
1/1
✓ Branch 0 (6→7) taken 7 times.
7 PString fullName(classConfig.getFullName());
105
4/4
✓ Branch 0 (7→8) taken 7 times.
✓ Branch 2 (8→9) taken 7 times.
✓ Branch 4 (9→10) taken 7 times.
✓ Branch 6 (10→11) taken 7 times.
7 fs << "///Load and save the given " << name << " depending on the ConfigNodeIter mode (interface with PhoenixConfigStream)" << std::endl;
106
2/2
✓ Branch 0 (11→12) taken 7 times.
✓ Branch 2 (12→13) taken 7 times.
7 fs << "/**\t@param[out] iter : ConfigNodeIter to be used to load and save the configuration" << std::endl;
107
4/4
✓ Branch 0 (13→14) taken 7 times.
✓ Branch 2 (14→15) taken 7 times.
✓ Branch 4 (15→16) taken 7 times.
✓ Branch 6 (16→17) taken 7 times.
7 fs << " * \t@param[out] data : " << name << " to load or save" << std::endl;
108
4/4
✓ Branch 0 (17→18) taken 7 times.
✓ Branch 2 (18→19) taken 7 times.
✓ Branch 4 (19→20) taken 7 times.
✓ Branch 6 (20→21) taken 7 times.
7 fs << " * \t@param checker : check caracteristics of the given " << name << " (eg: boundaries or size)" << std::endl;
109
2/2
✓ Branch 0 (21→22) taken 7 times.
✓ Branch 2 (22→23) taken 7 times.
7 fs << " * \t@return true on success, false otherwise" << std::endl;
110
2/2
✓ Branch 0 (23→24) taken 7 times.
✓ Branch 2 (24→25) taken 7 times.
7 fs << "*/" << std::endl;
111
1/1
✓ Branch 0 (25→26) taken 7 times.
7 const PVecString & listTemplate = classConfig.getListTemplate();
112
1/2
✓ Branch 0 (27→28) taken 7 times.
✗ Branch 1 (27→30) not taken.
7 if(listTemplate.size() == 0lu){
113
2/2
✓ Branch 0 (28→29) taken 7 times.
✓ Branch 2 (29→31) taken 7 times.
7 fs << "template<>" << std::endl;
114 }else{
115 fs << mode.templateDeclaration;
116 }
117
8/8
✓ Branch 0 (31→32) taken 7 times.
✓ Branch 2 (32→33) taken 7 times.
✓ Branch 4 (33→34) taken 7 times.
✓ Branch 6 (34→35) taken 7 times.
✓ Branch 8 (35→36) taken 7 times.
✓ Branch 10 (36→37) taken 7 times.
✓ Branch 12 (37→38) taken 7 times.
✓ Branch 14 (38→39) taken 7 times.
7 fs << "bool phoenix_config_stream<"<<fullName << mode.defTemplate<<">(ConfigNodeIter & iter, "<<fullName << mode.defTemplate<<" & data, const GenericConfigCheck * checker){" << std::endl;
118
2/2
✓ Branch 0 (39→40) taken 7 times.
✓ Branch 2 (40→41) taken 7 times.
7 fs << "\tbool b(true);" << std::endl;
119
3/3
✓ Branch 0 (41→42) taken 7 times.
✓ Branch 2 (42→43) taken 1 times.
✓ Branch 3 (42→58) taken 6 times.
7 if(classConfig.getIsEnum()){
120
2/2
✓ Branch 0 (43→44) taken 1 times.
✓ Branch 2 (44→45) taken 1 times.
1 fs << "\tPString value = iter->getString();" << std::endl;
121
2/2
✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
1 fs << "\tif(!fromString(data, value)){" << std::endl;
122
7/7
✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (48→49) taken 1 times.
✓ Branch 4 (49→50) taken 1 times.
✓ Branch 6 (50→51) taken 1 times.
✓ Branch 8 (51→52) taken 1 times.
✓ Branch 10 (52→53) taken 1 times.
✓ Branch 12 (53→54) taken 1 times.
1 fs << "\t\t*iter.getOut() << \"phoenix_config_stream<"<<fullName << mode.defTemplate<<"> : cannot load enum '"<<fullName<<"' with value '\"<<value<<\"'\" << std::endl;" << std::endl;
123
2/2
✓ Branch 0 (54→55) taken 1 times.
✓ Branch 2 (55→56) taken 1 times.
1 fs << "\t\tb = false;" << std::endl;
124
2/2
✓ Branch 0 (56→57) taken 1 times.
✓ Branch 2 (57→93) taken 1 times.
1 fs << "\t}" << std::endl;
125 }else{
126
1/1
✓ Branch 0 (58→59) taken 6 times.
6 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
127
2/2
✓ Branch 0 (91→60) taken 14 times.
✓ Branch 1 (91→92) taken 6 times.
40 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
128 //TODO : add a call to the ConfigCheck when it will be available in the pdata
129
13/13
✓ Branch 0 (60→61) taken 14 times.
✓ Branch 2 (63→64) taken 14 times.
✓ Branch 4 (64→65) taken 14 times.
✓ Branch 6 (65→66) taken 14 times.
✓ Branch 8 (68→69) taken 14 times.
✓ Branch 10 (69→70) taken 14 times.
✓ Branch 12 (70→71) taken 14 times.
✓ Branch 14 (71→72) taken 14 times.
✓ Branch 16 (74→75) taken 14 times.
✓ Branch 18 (75→76) taken 14 times.
✓ Branch 20 (76→77) taken 14 times.
✓ Branch 22 (77→78) taken 14 times.
✓ Branch 24 (78→79) taken 14 times.
56 fs << "\tb &= phoenix_config_stream<"<<it->getType()<<">(iter, data.get"<<it->getName().firstToUpper()<<"(), \""<<it->getName().toSnakeCase()<<"\", checker);" << std::endl;
130 }
131 }
132
2/2
✓ Branch 0 (93→94) taken 7 times.
✓ Branch 2 (94→95) taken 7 times.
7 fs << "\treturn b;" << std::endl;
133
3/3
✓ Branch 0 (95→96) taken 7 times.
✓ Branch 2 (96→97) taken 7 times.
✓ Branch 4 (97→98) taken 7 times.
7 fs << "}" << std::endl << std::endl;
134 7 }
135
136
137
138
139