GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitConfigStream/CppTraitConfigStream.cpp
Date: 2026-09-08 15:48:42
Exec Total Coverage
Lines: 55 56 98.2%
Functions: 12 12 100.0%
Branches: 101 108 93.5%

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