GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitConfigStream/CppTraitConfigStream.cpp
Date: 2025-12-15 11:32:44
Exec Total Coverage
Lines: 51 52 98.1%
Functions: 12 12 100.0%
Branches: 89 96 92.7%

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