msl 1.3.0
Loading...
Searching...
No Matches
helpers.h
Go to the documentation of this file.
1// Copyright 2023-2026 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
9#include <MrMeasSrv/SeqIF/libRT/sGRAD_PULSE.h>
10
11#include <MrProtSrv/Domain/MrProtData/MrProt/MrProt.h>
12#include <MrProtSrv/Domain/CoreNative/SeqLim.h>
13
14
16#define ON_ERROR_RETURN_FALSE(S) \
17{ \
18 MrResult const __status = (S); \
19 if(!MrSucceeded(__status)) \
20 { \
21 return false; \
22 } \
23}
24
26#define ON_ERROR_RETURN_STATUS(S) \
27{ \
28 MrResult const __status = (S); \
29 if(!MrSucceeded(__status)) \
30 { \
31 return __status; \
32 } \
33}
34
39#define ON_ERROR_SET_STATUS_AND_RETURN_FALSE(S) \
40{\
41 MrResult const __status = (S); \
42 if(!MrSucceeded(__status)) \
43 { \
44 this->setNLSStatus(__status); \
45 return false; \
46 } \
47}
48
50#define ON_FALSE_RETURN_FALSE(S) \
51if(!(S)) \
52{ \
53 return false; \
54}
55
57#define ON_FALSE_RETURN_STATUS(O, S) \
58if(!(O).S) \
59{ \
60 return (O).getNLSStatus(); \
61}
62
67#define ON_FALSE_SET_STATUS_AND_RETURN_FALSE(O, S) \
68if(!(O).S) \
69{ \
70 this->setNLSStatus((O).getNLSStatus()); \
71 return false; \
72}
73
74#ifdef _WIN32
76#define MSL_DEPRECATED __declspec(deprecated)
77#else
79#define MSL_DEPRECATED __attribute__((deprecated))
80#endif
81
83#define DECLARE_POINTERS(name) \
84 \
85 using Pointer = std::shared_ptr<name>; \
86 \
87 using ConstPointer = std::shared_ptr<name const>;
88
89namespace msl
90{
91
93double roundUp(double value, double base);
94
96long roundUpGRT(double value);
97
99double roundDown(double value, double base);
100
102long roundDownGRT(double value);
103
105template<typename T>
106long endTime(T const & x)
107{
108 return x.getStartTime() + x.getDuration();
109}
110
112long endTime(sGRAD_PULSE const & x);
113
115NLSStatus setGain(MrProt & protocol, SeqLim & limits, double thickness);
116
117}
118
119#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.
NLSStatus setGain(MrProt &protocol, SeqLim &limits, double thickness)
Set the gain to high for slices thinner than given thickness.
long endTime(T const &x)
Get the end time of an non-GRAD_PULSE IDEA object.
Definition helpers.h:106
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.