msl 1.3.0
Loading...
Searching...
No Matches
Block.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 _27135a4d_ad34_43b2_b032_c9745dc65fca
5#define _27135a4d_ad34_43b2_b032_c9745dc65fca
6
7#include <numeric>
8#include <string>
9
10#include <MrImagingFW/libSeqUtilFW/libSeqUtilFW.h>
11
12#include <MrMeasSrv/MeasUtils/NLSStatus.h>
13#include <MrMeasSrv/SeqIF/libRT/sSLICE_POS.h>
14#include <MrMeasSrv/SeqIF/Sequence/sequmsg.h>
15
16#include <MrProtSrv/Domain/CoreNative/SeqLim.h>
17#include <MrProtSrv/Domain/MrProtData/MrProt/MrProt.h>
18#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpo.h>
19#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpoRFBlockInfo.h>
20
21#include "msl/Counter.h"
23#include "msl/helpers.h"
24#include "msl/Iterator.h"
25
26namespace msl
27{
28namespace graph
29{
30
46template<typename T, typename Slices=std::vector<sSLICE_POS>>
47class Block: public AbstractNode
48{
49public:
51 using Pointer = std::shared_ptr<Block<T, Slices>>;
53 using ConstPointer = std::shared_ptr<Block<T const, Slices>>;
54
57
59 template<typename ... Args>
60 static Pointer New(std::string const & slice, Args && ... args)
61 {
62 return Pointer(new Block<T>(slice, args ...));
63 }
64
65 virtual ~Block() = default;
66
68 NLSStatus prepare(
69 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override
70 {
71 ON_FALSE_RETURN_STATUS(this->block, prep(protocol, limits, exports));
72 return MRI_SEQ_SEQU_NORMAL;
73 }
74
76 NLSStatus run(
77 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override
78 {
79 auto slice = this->get<msl::ConstIterator<Slices>>(this->_slice).item();
81 this->block, run(protocol, limits, exports, &slice));
82 return MRI_SEQ_SEQU_NORMAL;
83 }
84
86 uint64_t duration() const override
87 {
88 // WARNING: SeqBuildBlock::getDurationPerRequest is not const.
89 return const_cast<T&>(this->block).getDurationPerRequest();
90 }
91
93 MrProtocolData::SeqExpoRFInfo rfInfo() const override
94 {
95 // WARNING: SeqBuildBlock::getDurationPerRequest is not const.
96 return const_cast<T&>(this->block).getRFInfoPerRequest();
97 }
98
99private:
100 std::string _slice;
101
102 template<typename ... Args>
103 Block(std::string const & slice, Args && ... args)
104 : AbstractNode(), block(args ...), _slice(slice)
105 {
106 // Nothing else.
107 }
108 Block(Block<T, Slices> const &) = default;
109 Block(Block<T, Slices> &&) = default;
110 Block & operator=(Block<T, Slices> const &) = default;
111 Block & operator=(Block<T, Slices> &&) = default;
112};
113
114}
115}
116
117#endif // _27135a4d_ad34_43b2_b032_c9745dc65fca
Base class for all graph nodes.
Definition AbstractNode.h:28
T const & get(std::string const &key) const
Return an object from the dictionary.
Definition AbstractNode.h:68
AbstractNode(Dictionary::Pointer registry={})
Create a node with the given registry.
Node encapsulating a block (anything respecting the API of SeqBuildBlock).
Definition Block.h:48
T block
Encapsulated block.
Definition Block.h:56
NLSStatus prepare(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Prepare the block.
Definition Block.h:68
uint64_t duration() const override
Return the duration of the block.
Definition Block.h:86
MrProtocolData::SeqExpoRFInfo rfInfo() const override
Return the RF information of the block.
Definition Block.h:93
NLSStatus run(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Run the block with the slice referenced by the counter.
Definition Block.h:76
std::shared_ptr< Block< T, Slices > > Pointer
Reference-counted pointer to Block.
Definition Block.h:51
std::shared_ptr< Block< T const, Slices > > ConstPointer
Reference-counted constant pointer to Block.
Definition Block.h:53
static Pointer New(std::string const &slice, Args &&... args)
Create a Block node by passing arguments to the encapsulated block.
Definition Block.h:60
#define ON_FALSE_RETURN_STATUS(O, S)
Execute statement O.S, and, if false, return the status of object O.
Definition helpers.h:57
Graph-related objects and functions.
Definition AbstractNode.h:24
Top-level namespace of the msl library.
Definition acceleration.h:17