Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 8aefff8

Browse files
committed
Formatting code with clang-format
Signed-off-by: Thomas Cahuzac <[email protected]>
1 parent 3b22ab8 commit 8aefff8

File tree

268 files changed

+6409
-6078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+6409
-6078
lines changed

bindings/c/ParameterFramework.cpp

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ using std::string;
4747
/** Rename long pfw types to short ones in pfw namespace. */
4848
namespace pfw
4949
{
50-
typedef ISelectionCriterionInterface Criterion;
51-
typedef std::map<string, Criterion *> Criteria;
52-
typedef CParameterMgrPlatformConnector Pfw;
50+
typedef ISelectionCriterionInterface Criterion;
51+
typedef std::map<string, Criterion *> Criteria;
52+
typedef CParameterMgrPlatformConnector Pfw;
5353
}
5454

5555
/** Class to abstract the boolean+string status api. */
@@ -59,16 +59,27 @@ class Status
5959
/** Fail without an instance of status. */
6060
static bool failure() { return false; }
6161
/** Fail with the given error msg. */
62-
bool failure(const string &msg) { mMsg = msg; return false; }
62+
bool failure(const string &msg)
63+
{
64+
mMsg = msg;
65+
return false;
66+
}
6367
/** Success (no error message). */
64-
bool success() { mMsg.clear(); return true; }
68+
bool success()
69+
{
70+
mMsg.clear();
71+
return true;
72+
}
6573

6674
/** Forward a status operation.
6775
* @param success[in] the operaton status to forward
6876
* or forward a previous failure if omitted
6977
*/
70-
bool forward(bool success = false) {
71-
if (success) { mMsg.clear(); }
78+
bool forward(bool success = false)
79+
{
80+
if(success) {
81+
mMsg.clear();
82+
}
7283
return success;
7384
}
7485
/** Error message accessors.
@@ -78,6 +89,7 @@ class Status
7889
* will be added to the error message on failure.
7990
*/
8091
string &msg() { return mMsg; }
92+
8193
private:
8294
string mMsg;
8395
};
@@ -87,8 +99,9 @@ class Status
8799
///////////////////////////////
88100

89101
/** Default log callback. Log to cout or cerr depending on level. */
90-
static void defaultLogCb(void *, PfwLogLevel level, const char *logLine) {
91-
switch (level) {
102+
static void defaultLogCb(void *, PfwLogLevel level, const char *logLine)
103+
{
104+
switch(level) {
92105
case pfwLogInfo:
93106
std::cout << logLine << std::endl;
94107
break;
@@ -98,18 +111,19 @@ static void defaultLogCb(void *, PfwLogLevel level, const char *logLine) {
98111
};
99112
}
100113

101-
static PfwLogger defaultLogger = { NULL, &defaultLogCb };
114+
static PfwLogger defaultLogger = {NULL, &defaultLogCb};
102115

103116
class LogWrapper : public CParameterMgrPlatformConnector::ILogger
104117
{
105118
public:
106119
LogWrapper(const PfwLogger &logger) : mLogger(logger) {}
107120
LogWrapper() : mLogger() {}
108121
virtual ~LogWrapper() {}
122+
109123
private:
110124
void info(const string &msg) override { log(pfwLogInfo, msg); }
111125

112-
void warning(const string &msg) override { log(pfwLogWarning, msg); }
126+
void warning(const string &msg) override { log(pfwLogWarning, msg); }
113127

114128
void log(PfwLogLevel level, const string &strLog)
115129
{
@@ -137,14 +151,12 @@ struct PfwHandler_ : private utility::NonCopyable
137151
* Is mutable because even a const function can fail.
138152
*/
139153
mutable Status lastStatus;
154+
140155
private:
141156
LogWrapper mLogger;
142157
};
143158

144-
PfwHandler *pfwCreate()
145-
{
146-
return new PfwHandler();
147-
}
159+
PfwHandler *pfwCreate() { return new PfwHandler(); }
148160

149161
void pfwDestroy(PfwHandler *handle)
150162
{
@@ -154,40 +166,38 @@ void pfwDestroy(PfwHandler *handle)
154166

155167
void PfwHandler::setLogger(const PfwLogger *logger)
156168
{
157-
if (logger != NULL and logger->logCb == NULL) {
169+
if(logger != NULL and logger->logCb == NULL) {
158170
return; // There is no callback, do not log => do not add a logger
159171
}
160172
mLogger = logger != NULL ? *logger : defaultLogger;
161173
pfw->setLogger(&mLogger);
162174
}
163175

164-
165176
bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t criterionNb)
166177
{
167178
Status &status = lastStatus;
168179
// Add criteria
169-
for (size_t criterionIndex = 0; criterionIndex < criterionNb; ++criterionIndex) {
180+
for(size_t criterionIndex = 0; criterionIndex < criterionNb; ++criterionIndex) {
170181
const PfwCriterion &criterion = criteriaArray[criterionIndex];
171-
if (criterion.name == NULL) {
182+
if(criterion.name == NULL) {
172183
return status.failure("Criterion name is NULL");
173184
}
174-
if (criterion.values == NULL) {
185+
if(criterion.values == NULL) {
175186
return status.failure("Criterion values is NULL");
176187
}
177188
// Check that the criterion does not exist
178-
if (criteria.find(criterion.name) != criteria.end()) {
179-
return status.failure("Criterion \"" + string(criterion.name) +
180-
"\" already exist");
189+
if(criteria.find(criterion.name) != criteria.end()) {
190+
return status.failure("Criterion \"" + string(criterion.name) + "\" already exist");
181191
}
182192

183193
// Create criterion type
184194
ISelectionCriterionTypeInterface *type =
185195
pfw->createSelectionCriterionType(criterion.inclusive);
186196
assert(type != NULL);
187197
// Add criterion values
188-
for (size_t valueIndex = 0; criterion.values[valueIndex] != NULL; ++valueIndex) {
198+
for(size_t valueIndex = 0; criterion.values[valueIndex] != NULL; ++valueIndex) {
189199
int value;
190-
if (criterion.inclusive) {
200+
if(criterion.inclusive) {
191201
// Check that (int)1 << valueIndex would not overflow (UB)
192202
if(std::numeric_limits<int>::max() >> valueIndex == 0) {
193203
return status.failure("Too many values for criterion " +
@@ -197,9 +207,9 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
197207
} else {
198208
value = static_cast<int>(valueIndex);
199209
}
200-
const char * valueName = criterion.values[valueIndex];
210+
const char *valueName = criterion.values[valueIndex];
201211
string error;
202-
if (not type->addValuePair(value, valueName, error)) {
212+
if(not type->addValuePair(value, valueName, error)) {
203213
return status.failure("Could not add value " + string(valueName) +
204214
" to criterion " + criterion.name + ": " + error);
205215
}
@@ -210,36 +220,33 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
210220
return status.success();
211221
}
212222

213-
214-
bool pfwStart(PfwHandler *handle, const char *configPath,
215-
const PfwCriterion criteria[], size_t criterionNb,
223+
bool pfwStart(PfwHandler *handle,
224+
const char *configPath,
225+
const PfwCriterion criteria[],
226+
size_t criterionNb,
216227
const PfwLogger *logger)
217228
{
218229
// Check that the api is correctly used
219230
Status &status = handle->lastStatus;
220231

221-
if (handle->pfw != NULL) {
232+
if(handle->pfw != NULL) {
222233
return status.failure("Can not start an already started parameter framework");
223234
}
224235
// Create a pfw
225236
handle->pfw = new CParameterMgrPlatformConnector(configPath);
226237

227238
handle->setLogger(logger);
228239

229-
if (not handle->createCriteria(criteria, criterionNb)) {
240+
if(not handle->createCriteria(criteria, criterionNb)) {
230241
return status.failure();
231242
}
232243

233244
return status.forward(handle->pfw->start(status.msg()));
234245
}
235246

236-
const char *pfwGetLastError(const PfwHandler *handle)
237-
{
238-
return handle->lastStatus.msg().c_str();
239-
}
247+
const char *pfwGetLastError(const PfwHandler *handle) { return handle->lastStatus.msg().c_str(); }
240248

241-
static pfw::Criterion *getCriterion(const pfw::Criteria &criteria,
242-
const string &name)
249+
static pfw::Criterion *getCriterion(const pfw::Criteria &criteria, const string &name)
243250
{
244251
pfw::Criteria::const_iterator it = criteria.find(name);
245252
return it == criteria.end() ? NULL : it->second;
@@ -248,12 +255,12 @@ static pfw::Criterion *getCriterion(const pfw::Criteria &criteria,
248255
bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
249256
{
250257
Status &status = handle->lastStatus;
251-
if (handle->pfw == NULL) {
258+
if(handle->pfw == NULL) {
252259
return status.failure("Can not set criterion \"" + string(name) +
253260
"\" as the parameter framework is not started.");
254261
}
255262
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
256-
if (criterion == NULL) {
263+
if(criterion == NULL) {
257264
return status.failure("Can not set criterion " + string(name) + " as does not exist");
258265
}
259266
criterion->setCriterionState(value);
@@ -262,12 +269,12 @@ bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
262269
bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
263270
{
264271
Status &status = handle->lastStatus;
265-
if (handle->pfw == NULL) {
272+
if(handle->pfw == NULL) {
266273
return status.failure("Can not get criterion \"" + string(name) +
267274
"\" as the parameter framework is not started.");
268275
}
269276
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
270-
if (criterion == NULL) {
277+
if(criterion == NULL) {
271278
return status.failure("Can not get criterion " + string(name) + " as it does not exist");
272279
}
273280
*value = criterion->getCriterionState();
@@ -277,7 +284,7 @@ bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
277284
bool pfwApplyConfigurations(const PfwHandler *handle)
278285
{
279286
Status &status = handle->lastStatus;
280-
if (handle->pfw == NULL) {
287+
if(handle->pfw == NULL) {
281288
return status.failure("Can not commit criteria "
282289
"as the parameter framework is not started.");
283290
}
@@ -298,15 +305,16 @@ struct PfwParameterHandler_
298305
PfwParameterHandler *pfwBindParameter(PfwHandler *handle, const char path[])
299306
{
300307
Status &status = handle->lastStatus;
301-
if (handle->pfw == NULL) {
308+
if(handle->pfw == NULL) {
302309
status.failure("The parameter framework is not started, "
303-
"while trying to bind parameter \"" + string(path) + "\")");
310+
"while trying to bind parameter \"" +
311+
string(path) + "\")");
304312
return NULL;
305313
}
306314

307315
CParameterHandle *paramHandle;
308316
paramHandle = handle->pfw->createParameterHandle(path, status.msg());
309-
if (paramHandle == NULL) {
317+
if(paramHandle == NULL) {
310318
return NULL;
311319
}
312320

@@ -321,7 +329,6 @@ void pfwUnbindParameter(PfwParameterHandler *handle)
321329
delete handle;
322330
}
323331

324-
325332
bool pfwGetIntParameter(const PfwParameterHandler *handle, int32_t *value)
326333
{
327334
Status &status = handle->pfw.lastStatus;
@@ -339,7 +346,9 @@ bool pfwGetStringParameter(const PfwParameterHandler *handle, char *value[])
339346
*value = NULL;
340347
string retValue;
341348
bool success = handle->parameter.getAsString(retValue, status.msg());
342-
if (not success) { return status.forward(); }
349+
if(not success) {
350+
return status.forward();
351+
}
343352

344353
*value = strdup(retValue.c_str());
345354
return status.success();
@@ -352,4 +361,3 @@ bool pfwSetStringParameter(PfwParameterHandler *handle, const char value[])
352361
}
353362

354363
void pfwFree(void *ptr) { std::free(ptr); }
355-

0 commit comments

Comments
 (0)