msl 1.3.0
Loading...
Searching...
No Matches
AbstractNode.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 _c98760d2_f8bf_472c_9671_9d8322e26b0e
5#define _c98760d2_f8bf_472c_9671_9d8322e26b0e
6
7#include <cstddef>
8#include <memory>
9
10#include <MrMeasSrv/MeasUtils/NLSStatus.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"
18
19namespace msl
20{
21
23namespace graph
24{
25
28{
29public:
31
32 virtual ~AbstractNode() = default;
33
35 virtual NLSStatus prepare(
36 MrProt & protocol, SeqLim & limits, SeqExpo & exports) = 0;
37
39 virtual NLSStatus run(
40 MrProt & protocol, SeqLim & limits, SeqExpo & exports) = 0;
41
44
47
50
52 virtual void reset();
53
61 virtual uint64_t duration() const = 0;
62
64 virtual MrProtocolData::SeqExpoRFInfo rfInfo() const = 0;
65
67 template<typename T>
68 T const & get(std::string const & key) const
69 {
70 return this->_registry->get<T>(key);
71 }
72
74 template<typename T>
75 T & get(std::string const & key)
76 {
77 return this->_registry->get<T>(key);
78 }
79
81 template<typename T>
82 AbstractNode & set(std::string const & key, T && value)
83 {
84 this->_registry->set(key, value);
85 return *this;
86 }
87
89 boost::typeindex::type_info const & type(std::string const & key) const;
90
91protected:
94
97 AbstractNode(AbstractNode const &) = default;
98 AbstractNode(AbstractNode &&) = default;
99 AbstractNode & operator=(AbstractNode const &) = default;
100 AbstractNode & operator=(AbstractNode &&) = default;
101};
102
104template<typename T, typename U>
105std::shared_ptr<T> NodeCast(std::shared_ptr<U> const & p)
106{
107 return std::dynamic_pointer_cast<T>(p);
108}
109
110}
111
112}
113
114#endif // _c98760d2_f8bf_472c_9671_9d8322e26b0e
std::shared_ptr< Dictionary const > ConstPointer
Reference-counted constant pointer to Dictionary.
Definition Dictionary.h:34
std::shared_ptr< Dictionary > Pointer
Reference-counted pointer to Dictionary.
Definition Dictionary.h:34
Base class for all graph nodes.
Definition AbstractNode.h:28
virtual void reset()
Reset to a default state.
virtual NLSStatus run(MrProt &protocol, SeqLim &limits, SeqExpo &exports)=0
Run the node.
Dictionary::Pointer & registry()
Return the registry.
T & get(std::string const &key)
Return an object from the dictionary.
Definition AbstractNode.h:75
boost::typeindex::type_info const & type(std::string const &key) const
Return the type of an object in the dictionary.
virtual uint64_t duration() const =0
Return the duration in microseconds, requires preparation.
Dictionary::ConstPointer registry() const
Return the registry.
Dictionary::Pointer _registry
Registry attached to this node.
Definition AbstractNode.h:93
T const & get(std::string const &key) const
Return an object from the dictionary.
Definition AbstractNode.h:68
virtual AbstractNode & setRegistry(Dictionary::Pointer registry)
Set the registry.
virtual NLSStatus prepare(MrProt &protocol, SeqLim &limits, SeqExpo &exports)=0
Prepare the node.
AbstractNode(Dictionary::Pointer registry={})
Create a node with the given registry.
virtual MrProtocolData::SeqExpoRFInfo rfInfo() const =0
Return the RF information for SAR computation, requires preparation.
AbstractNode & set(std::string const &key, T &&value)
Store an object in the dictionary, create it if needed.
Definition AbstractNode.h:82
#define DECLARE_POINTERS(name)
Declare pointer type aliases.
Definition helpers.h:83
Graph-related objects and functions.
Definition AbstractNode.h:24
std::shared_ptr< T > NodeCast(std::shared_ptr< U > const &p)
Up- or down-cast node pointers.
Definition AbstractNode.h:105
Top-level namespace of the msl library.
Definition acceleration.h:17