msl 1.3.0
Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1// Copyright 2024-2026 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
33 using Siblings = std::vector<AbstractNode::Pointer>;
34
37
39 template<typename T>
41 {
42 return Pointer(new Node(child, registry));
43 }
44
46 static Pointer New(
47 Siblings const & siblings, Dictionary::Pointer registry={});
48
49 virtual ~Node() = default;
50
52 NLSStatus prepare(
53 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
54
56 NLSStatus run(
57 MrProt & protocol, SeqLim & limits, SeqExpo & exports) override;
58
61
63 void reset() override;
64
66 uint64_t duration() const override;
67
69 MrProtocolData::SeqExpoRFInfo rfInfo() const override;
70
72 bool empty() const;
74 std::size_t size() const;
75
77 template<typename T>
78 T & appendChild(std::shared_ptr<T> const & child)
79 {
80 this->_children.push_back(child);
81 this->_children.back()->setRegistry(this->_registry);
82 return *child;
83 }
84
86 void appendChildren(Siblings const & siblings);
87
89 Node & deleteChild(std::size_t index);
90
93
98 AbstractNode::ConstPointer child(std::size_t index) const;
99
104 AbstractNode::Pointer child(std::size_t index);
105
106protected:
109
112
114 template<typename T>
116 : Node(registry)
117 {
118 this->appendChild(child);
119 }
120
123
124 Node(Node const &) = default;
125 Node(Node &&) = default;
126 Node & operator=(Node const &) = default;
127 Node & operator=(Node &&) = default;
128};
129
130}
131
132}
133
134#endif // _b88cfdce_0b38_4b24_b5c6_5b69be24d9d8
std::shared_ptr< Dictionary > Pointer
Reference-counted pointer to Dictionary.
Definition Dictionary.h:34
std::shared_ptr< AbstractNode > Pointer
Reference-counted pointer to AbstractNode.
Definition AbstractNode.h:30
std::shared_ptr< AbstractNode const > ConstPointer
Reference-counted constant pointer to AbstractNode.
Definition AbstractNode.h:30
Dictionary::ConstPointer registry() const
Return the registry.
Dictionary::Pointer _registry
Registry attached to this node.
Definition AbstractNode.h:93
AbstractNode(Dictionary::Pointer registry={})
Create a node with the given registry.
Container node, prepare and run its children sequentially.
Definition Node.h:28
void reset() override
Reset children to a default state.
bool empty() const
Check whether this node has children.
std::size_t size() const
Return the number of children.
std::vector< AbstractNode::Pointer > Siblings
Child container.
Definition Node.h:33
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={})
Create a node with no child.
static Pointer New(T const &child, Dictionary::Pointer registry={})
Create a node with a single child.
Definition Node.h:40
void appendChildren(Siblings const &siblings)
Append children after the last position.
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.
static Pointer New(Dictionary::Pointer registry={})
Create a node with no child.
Siblings _children
Children of this node.
Definition Node.h:108
Node(Siblings const &siblings, Dictionary::Pointer registry={})
Create a node with multiple children.
std::shared_ptr< Node > Pointer
Reference-counted pointer to Node.
Definition Node.h:30
static Pointer New(Siblings const &siblings, Dictionary::Pointer registry={})
Create a node with multiple children.
Node(T const &child, Dictionary::Pointer registry={})
Create a node with a single child.
Definition Node.h:115
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:78
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.
#define DECLARE_POINTERS(name)
Declare pointer type aliases.
Definition helpers.h:83
Graph-related objects and functions.
Definition AbstractNode.h:24
Top-level namespace of the msl library.
Definition acceleration.h:17