Skip to content

Commit 44994c3

Browse files
committed
improve readability after review
1 parent 47ebb45 commit 44994c3

File tree

1 file changed

+56
-67
lines changed

1 file changed

+56
-67
lines changed

source/pdal/pdalc_pipeline.cpp

Lines changed: 56 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ extern "C"
215215

216216
void PDALSetPipelineLogLevel(PDALPipelinePtr pipeline, int level)
217217
{
218-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
219-
220218
try
221219
{
220+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
222221
if (level < 0 || level > 8)
223222
throw pdal_error("log level must be between 0 and 8!");
224223

@@ -229,14 +228,16 @@ extern "C"
229228
{
230229
printf("Found error while setting log level: %s\n", e.what());
231230
}
232-
233231
}
234232

235233
int PDALGetPipelineLogLevel(PDALPipelinePtr pipeline)
236234
{
237-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
235+
if (! pipeline)
236+
return 0;
237+
238238
try
239239
{
240+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
240241
return (ptr)
241242
? static_cast<int>(
242243
ptr->manager->log()->getLevel()
@@ -251,100 +252,88 @@ extern "C"
251252

252253
int64_t PDALExecutePipeline(PDALPipelinePtr pipeline)
253254
{
254-
int64_t result = 0;
255-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
255+
if (! pipeline)
256+
return 0;
256257

257-
if (ptr)
258+
try
258259
{
259-
try
260-
{
261-
result = ptr->manager->execute();
262-
ptr->m_executed = true;
263-
}
264-
catch (const std::exception &e)
265-
{
266-
printf("Found error while executing pipeline: %s", e.what());
267-
}
260+
int64_t result;
261+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
262+
result = ptr->manager->execute();
263+
ptr->m_executed = true;
264+
return result;
265+
}
266+
catch (const std::exception &e)
267+
{
268+
printf("Found error while executing pipeline: %s", e.what());
269+
return 0;
268270
}
269-
return result;
270271
}
271272

272273
bool PDALExecutePipelineAsStream(PDALPipelinePtr pipeline)
273274
{
274-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
275+
if (! pipeline)
276+
return false;
275277

276-
if (ptr)
278+
try
277279
{
278-
try
279-
{
280-
PipelineManager::ExecResult exec = ptr->manager->execute(ExecMode::Stream);
281-
ptr->m_executed = true;
282-
return true;
283-
}
284-
catch (const std::exception &e)
285-
{
286-
printf("Found error while executing pipeline: %s", e.what());
287-
return false;
288-
}
280+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
281+
PipelineManager::ExecResult exec = ptr->manager->execute(ExecMode::Stream);
282+
ptr->m_executed = true;
283+
return true;
284+
}
285+
catch (const std::exception &e)
286+
{
287+
printf("Found error while executing pipeline: %s", e.what());
288+
return false;
289289
}
290-
return false;
291290
}
292291

293292
bool PDALPipelineIsStreamable(PDALPipelinePtr pipeline)
294293
{
295-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
294+
if (! pipeline)
295+
return false;
296296

297-
if (ptr)
298-
{
299-
return ptr->manager->pipelineStreamable();
300-
}
301-
return false;
297+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
298+
return ptr->manager->pipelineStreamable();
302299
}
303300

304301

305302

306303
bool PDALValidatePipeline(PDALPipelinePtr pipeline)
307304
{
308-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
309-
310-
if (ptr)
305+
if (! pipeline)
306+
return false;
307+
try
311308
{
312-
try
313-
{
314-
ptr->manager->prepare();
315-
return true;
316-
}
317-
catch (const std::exception &e)
318-
{
319-
printf("Found error while validating pipeline: %s", e.what());
320-
return false;
321-
}
309+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
310+
ptr->manager->prepare();
311+
return true;
312+
}
313+
catch (const std::exception &e)
314+
{
315+
printf("Found error while validating pipeline: %s", e.what());
316+
return false;
322317
}
323-
return false;
324318
}
325319

326320
PDALPointViewIteratorPtr PDALGetPointViews(PDALPipelinePtr pipeline)
327321
{
328-
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
329-
pdal::capi::PointViewIterator *views = nullptr;
322+
if (! pipeline)
323+
return nullptr;
330324

331-
if (ptr)
325+
try
332326
{
333-
try
334-
{
335-
views = new pdal::capi::PointViewIterator(ptr->manager->views());
336-
}
337-
catch (const std::exception &e)
338-
{
339-
printf("Found error while retrieving point views: %s\n", e.what());
340-
}
327+
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
328+
return new pdal::capi::PointViewIterator(ptr->manager->views());
329+
}
330+
catch (const std::exception &e)
331+
{
332+
printf("Found error while retrieving point views: %s\n", e.what());
333+
return nullptr;
341334
}
342-
343-
return views;
344335
}
345-
} /* extern c */
346-
347-
348336

337+
} /* extern c */
349338
} /* capi */
350339
} /* pdal */

0 commit comments

Comments
 (0)