msl 1.1.0
 
Loading...
Searching...
No Matches
Node.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 _b88cfdce_0b38_4b24_b5c6_5b69be24d9d8
5#define _b88cfdce_0b38_4b24_b5c6_5b69be24d9d8
6
7#include <vector>
8
9#include <MrMeasSrv/MeasUtils/NLSStatus.h>
10#include <MrMeasSrv/SeqIF/libRT/sSLICE_POS.h>
11
12#include <MrProtSrv/Domain/CoreNative/SeqLim.h>
13#include <MrProtSrv/Domain/MrProtData/MrProt/MrProt.h>
14#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpo.h>
15#include <MrProtSrv/Domain/MrProtData/MrProt/SeqIF/SeqExpoRFBlockInfo.h>
16
17#include "msl/Dictionary.h"
19
20namespace msl
21{
22
23namespace graph
24{
25
27class Node: public AbstractNode
28{
29public:
31
32 using Siblings = std::vector<AbstractNode::Pointer>;
33
35 static Pointer New(Dictionary::Pointer registry={});
36
38 template<typename T>
39 static Pointer New(T const & child, Dictionary::Pointer registry={})
40 {
41 return Pointer(new Node(child, registry));
42 }
43
45 static Pointer New(
46 Siblings const & siblings, Dictionary::Pointer registry={});
47
48 virtual ~Node() = default;
49
51 NLSStatus prepare(
52 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
53
55 NLSStatus run(
56 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
57
59 Node & setRegistry(Dictionary::Pointer registry) override;
60
62 uint64_t duration() const override;
63
65 MrProtocolData::SeqExpoRFInfo rfInfo() const override;
66
68 bool empty() const;
70 std::size_t size() const;
71
73 template<typename T>
74 T & appendChild(std::shared_ptr<T> const & child)
75 {
76 this->_children.push_back(child);
77 this->_children.back()->setRegistry(this->_registry);
78 return *child;
79 }
80
82 Node & deleteChild(std::size_t index);
83
86
91 AbstractNode::ConstPointer child(std::size_t index) const;
92
97 AbstractNode::Pointer child(std::size_t index);
98
99protected:
101
102 Node(Dictionary::Pointer registry={});
103
104 template<typename T>
105 Node(T const & child, Dictionary::Pointer registry={})
106 : Node(registry)
107 {
108 this->appendChild(child);
109 }
110
111 Node(Siblings const & siblings, Dictionary::Pointer registry={});
112
113 Node(Node const &) = default;
114 Node(Node &&) = default;
115 Node & operator=(Node const &) = default;
116 Node & operator=(Node &&) = default;
117};
118
119}
120
121}
122
123#endif // _b88cfdce_0b38_4b24_b5c6_5b69be24d9d8
Dictionary::ConstPointer registry() const
Return the registry.
Dictionary::Pointer _registry
Definition AbstractNode.h:80
AbstractNode(Dictionary::Pointer registry={})
Container node, prepare and run its children sequentially.
Definition Node.h:28
virtual ~Node()=default
Node(Node const &)=default
Node & operator=(Node const &)=default
bool empty() const
Check whether this node has children.
std::size_t size() const
Return the number of children.
std::vector< AbstractNode::Pointer > Siblings
Definition Node.h:32
Node & setRegistry(Dictionary::Pointer registry) override
Set the registry to this node and its children.
NLSStatus prepare(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Prepare all children in order.
Node(Dictionary::Pointer registry={})
static Pointer New(T const &child, Dictionary::Pointer registry={})
Create a node with a single child.
Definition Node.h:39
MrProtocolData::SeqExpoRFInfo rfInfo() const override
Return the sum of the RF information of the children.
Node & deleteChild(std::size_t index)
Remove a child.
Node & clearChildren()
Remove all children.
Node & operator=(Node &&)=default
static Pointer New(Dictionary::Pointer registry={})
Create a node with no child.
Siblings _children
Definition Node.h:100
Node(Siblings const &siblings, Dictionary::Pointer registry={})
static Pointer New(Siblings const &siblings, Dictionary::Pointer registry={})
Create a node with multiple children.
Node(T const &child, Dictionary::Pointer registry={})
Definition Node.h:105
AbstractNode::ConstPointer child(std::size_t index) const
Return a child at given position.
AbstractNode::Pointer child(std::size_t index)
Return a child at given position.
T & appendChild(std::shared_ptr< T > const &child)
Append a child in last position, return the child.
Definition Node.h:74
Node(Node &&)=default
uint64_t duration() const override
Return the sum of the duration of the children.
NLSStatus run(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Run all children in order.
Definition AbstractNode.h:23
Definition acceleration.h:17