msl 1.1.0
 
Loading...
Searching...
No Matches
If.h
Go to the documentation of this file.
1// Copyright 2024-2025 Julien Lamy, ICube, Université de Strasbourg-CNRS.
2// Part of msl, distributed under the terms of the MIT license.
3
4#ifndef _29882abf_80e7_4434_8f2c_b5109dd75ef7
5#define _29882abf_80e7_4434_8f2c_b5109dd75ef7
6
7#include <functional>
8#include <string>
9
10#include <boost/variant/variant.hpp>
11
12#include <MrMeasSrv/MeasUtils/NLSStatus.h>
13#include <MrMeasSrv/SeqIF/libRT/sSLICE_POS.h>
14
15#include <MrProtSrv/Domain/CoreNative/SeqLim.h>
16#include <MrProtSrv/Domain/MrProtData/MrProt/MrProt.h>
17#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpo.h>
18#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpoRFBlockInfo.h>
19
20#include "msl/Dictionary.h"
21#include "msl/graph/Node.h"
22
23namespace msl
24{
25namespace graph
26{
27
29class If: public Node
30{
31public:
33
34 // NOTE: most of the Siemens API is not const-correct
35 using Function = boost::variant<
36 std::function<bool()>,
37 std::function<bool(MrProt &)>,
38 std::function<bool(MrProt &, SeqLim &, SeqExpo &)>>;
39
41 static Pointer New(
42 std::string const & key, Dictionary::Pointer registry={});
43
45 template<typename T>
46 static Pointer New(
47 std::string const & key, T const & child,
48 Dictionary::Pointer registry={})
49 {
50 return Pointer(new If(key, child, registry));
51 }
52
54 static Pointer New(
55 std::string const & key, Siblings const & siblings,
56 Dictionary::Pointer registry={});
57
58 virtual ~If() = default;
59
61 NLSStatus prepare(
62 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
63
65 NLSStatus run(
66 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
67
75 uint64_t duration() const override;
76
84 MrProtocolData::SeqExpoRFInfo rfInfo() const override;
85
86private:
87 std::string _key;
88
89 // NOTE: SeqLim is an abstract class. Since the concrete object may change
90 // between calls to ::prepare or ::run, it can only be stored in a pointer.
91 mutable bool _hasCache;
92 mutable MrProt * _protocol;
93 mutable SeqLim * _limits;
94 mutable SeqExpo * _exports;
95
96 If(std::string const & key, Dictionary::Pointer registry={});
97
98 template<typename T>
99 If(
100 std::string const & key, T const & child,
101 Dictionary::Pointer registry={})
102 : Node(child, registry), _key(key)
103 {
104 // Nothing else
105 }
106
107 If(
108 std::string const & key, Siblings const & siblings,
109 Dictionary::Pointer registry={});
110
111 If(If const &) = default;
112 If(If &&) = default;
113 If & operator=(If const &) = default;
114 If & operator=(If &&) = default;
115
116 bool _condition() const;
117 bool _condition(MrProt & protocol, SeqLim & limits, SeqExpo & exports) const;
118};
119}
120}
121
122#endif // _29882abf_80e7_4434_8f2c_b5109dd75ef7
Dictionary::ConstPointer registry() const
Return the registry.
Node running its children based on a boolean key or a function key.
Definition If.h:30
virtual ~If()=default
NLSStatus run(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Run the children if the boolean is true.
static Pointer New(std::string const &key, Siblings const &siblings, Dictionary::Pointer registry={})
Create an If node with multiple children.
static Pointer New(std::string const &key, T const &child, Dictionary::Pointer registry={})
Create an If node with a single child.
Definition If.h:46
uint64_t duration() const override
Return the sum of the duration of the children if the boolean is true, 0 otherwise.
boost::variant< std::function< bool()>, std::function< bool(MrProt &)>, std::function< bool(MrProt &, SeqLim &, SeqExpo &)> > Function
Definition If.h:35
static Pointer New(std::string const &key, Dictionary::Pointer registry={})
Create an If node without children.
MrProtocolData::SeqExpoRFInfo rfInfo() const override
Return the sum of the RF information of the children if the boolean is true, empty RF information oth...
NLSStatus prepare(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Prepare the children if the boolean is true.
std::vector< AbstractNode::Pointer > Siblings
Definition Node.h:32
Node(Dictionary::Pointer registry={})
AbstractNode::ConstPointer child(std::size_t index) const
Return a child at given position.
Definition AbstractNode.h:23
Definition acceleration.h:17