msl 1.3.0
Loading...
Searching...
No Matches
helpers.h
Go to the documentation of this file.
1// Copyright 2023-2025 Julien Lamy, ICube, Université de Strasbourg-CNRS.
2// Part of msl, distributed under the terms of the MIT license.
3
4#ifndef _4e0b8fa0_8cc9_43da_a9cc_1ff601e2829d
5#define _4e0b8fa0_8cc9_43da_a9cc_1ff601e2829d
6
7#include <MrGlobalDefinitions/MrResult.h>
8#include <MrMeasSrv/SeqIF/libRT/sGRAD_PULSE.h>
9
11#define ON_ERROR_RETURN_FALSE(S) \
12{ \
13 MrResult const __status = (S); \
14 if(!MrSucceeded(__status)) \
15 { \
16 return false; \
17 } \
18}
19
21#define ON_ERROR_RETURN_STATUS(S) \
22{ \
23 MrResult const __status = (S); \
24 if(!MrSucceeded(__status)) \
25 { \
26 return __status; \
27 } \
28}
29
34#define ON_ERROR_SET_STATUS_AND_RETURN_FALSE(S) \
35{\
36 MrResult const __status = (S); \
37 if(!MrSucceeded(__status)) \
38 { \
39 this->setNLSStatus(__status); \
40 return false; \
41 } \
42}
43
45#define ON_FALSE_RETURN_FALSE(S) \
46if(!(S)) \
47{ \
48 return false; \
49}
50
52#define ON_FALSE_RETURN_STATUS(O, S) \
53if(!(O).S) \
54{ \
55 return (O).getNLSStatus(); \
56}
57
62#define ON_FALSE_SET_STATUS_AND_RETURN_FALSE(O, S) \
63if(!(O).S) \
64{ \
65 this->setNLSStatus((O).getNLSStatus()); \
66 return false; \
67}
68
69namespace msl
70{
71
73double roundUp(double value, double base);
74
76long roundUpGRT(double value);
77
79double roundDown(double value, double base);
80
82long roundDownGRT(double value);
83
85template<typename T>
86long endTime(T const & x)
87{
88 return x.getStartTime() + x.getDuration();
89}
90
92long endTime(sGRAD_PULSE const & x);
93
94}
95
96#endif // _4e0b8fa0_8cc9_43da_a9cc_1ff601e2829d
Top-level namespace of the msl library.
Definition acceleration.h:17
long roundDownGRT(double value)
Round down the value to the nearest multiple of GRAD_RASTER_TIME.
long roundUpGRT(double value)
Round up the value to the nearest multiple of GRAD_RASTER_TIME.
long endTime(T const &x)
Get the end time of an non-GRAD_PULSE IDEA object.
Definition helpers.h:86
double roundUp(double value, double base)
Round up the value to the nearest multiple of base.
double roundDown(double value, double base)
Round down the value to the nearest multiple of base.