4#ifndef _c1c4f441_160f_46bf_869e_1bf9c199aa91
5#define _c1c4f441_160f_46bf_869e_1bf9c199aa91
7#include <unordered_map>
9#include <MrMeasSrv/MeasUtils/NLSStatus.h>
10#include <MrMeasSrv/SeqIF/Sequence/sequmsg.h>
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>
37 using Map = std::unordered_map<T, AbstractNode::Pointer>;
46 std::string
const & key,
Map const & cases,
59 MrProt & protocol, SeqLim & limits, SeqExpo & exports)
override
61 auto child = this->_child(protocol, limits, exports);
65 this->_duration = child->duration();
66 this->_rfInfo = child->rfInfo();
68 return MRI_SEQ_SEQU_NORMAL;
78 MrProt & protocol, SeqLim & limits, SeqExpo & exports)
override
80 auto child = this->_child(protocol, limits, exports);
81 return child->run(protocol, limits, exports);
88 for(
auto && item: this->_cases)
90 auto & child = item.second;
91 child->setRegistry(this->_registry);
102 return this->_duration;
109 MrProtocolData::SeqExpoRFInfo
rfInfo()
const override
111 return this->_rfInfo;
119 mutable uint64_t _duration;
120 mutable MrProtocolData::SeqExpoRFInfo _rfInfo;
123 std::string
const & key,
Map const & cases,
125 : AbstractNode(
registry), _key(key), _cases(cases)
131 MrProt & protocol, SeqLim & limits, SeqExpo & exports)
const
133 auto const child = this->_cases.at(
134 this->
type(this->_key) ==
typeid(T)
135 ? this->get<T>(this->_key)
137 protocol, limits, exports, this->_registry));
143 MrProt & protocol, SeqLim & limits, SeqExpo & exports)
145 auto const child = this->_cases.at(
146 this->
type(this->_key) ==
typeid(T)
147 ? this->get<T>(this->_key)
149 protocol, limits, exports, this->_registry));
#define DECLARE_POINTERS(name)
Declare pointer type aliases.
Definition Dictionary.h:18
std::shared_ptr< Dictionary > Pointer
Reference-counted pointer to Dictionary
Definition Dictionary.h:39
Base class for all graph nodes.
Definition AbstractNode.h:28
std::shared_ptr< AbstractNode > Pointer
Reference-counted pointer to AbstractNode
Definition AbstractNode.h:30
boost::typeindex::type_info const & type(std::string const &key) const
Return the type of an object in the dictionary.
Dictionary::ConstPointer registry() const
Return the registry.
T const & get(std::string const &key) const
Return an object from the dictionary.
Definition AbstractNode.h:65
virtual AbstractNode & setRegistry(Dictionary::Pointer registry)
Set the registry.
std::shared_ptr< AbstractNode const > ConstPointer
Reference-counted constant pointer to AbstractNode
Definition AbstractNode.h:30
Node encapsulating a switch/case structure based on a boolean key or a function key.
Definition Case.h:34
static Pointer New(std::string const &key, Map const &cases, Dictionary::Pointer registry={})
Create a case node pointing to a key in the registry.
Definition Case.h:45
NLSStatus prepare(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Prepare the selected child, throw an exception if unknown value.
Definition Case.h:58
NLSStatus run(MrProt &protocol, SeqLim &limits, SeqExpo &exports) override
Run the selected child, throw an exception if unknown value.
Definition Case.h:77
FlexibleFunction< T > Function
Case function.
Definition Case.h:40
Case & setRegistry(Dictionary::Pointer registry) override
Set the registry to this node and its children.
Definition Case.h:85
std::shared_ptr< Case< T > > Pointer
Reference-counted pointer to Case<T>
Definition Case.h:42
std::unordered_map< T, AbstractNode::Pointer > Map
Dictionary to dispatch key to function.
Definition Case.h:37
MrProtocolData::SeqExpoRFInfo rfInfo() const override
Return the RF information of the selected child, throw an exception if unknown value.
Definition Case.h:109
uint64_t duration() const override
Return the duration of the selected child, throw an exception if unknown value.
Definition Case.h:100
#define ON_ERROR_RETURN_STATUS(S)
Execute statement S, and, if not MRRESULT_SUCCESS, return the status.
Definition helpers.h:21
boost::variant< std::function< T()>, std::function< T(Dictionary::Pointer)>, std::function< T(MrProt &)>, std::function< T(MrProt &, Dictionary::Pointer)>, std::function< T(MrProt &, SeqLim &, SeqExpo &)>, std::function< T(MrProt &, SeqLim &, SeqExpo &, Dictionary::Pointer)> > FlexibleFunction
A graph function (e.g. Case or If), with flexible arguments.
Definition FlexibleFunction.h:35
std::function< T(MrProt &, SeqLim &, SeqExpo &, Dictionary::Pointer)> function_adapter(FlexibleFunction< T > const &f)
Adapt a FlexibleFunction to its nominal form.
Definition FlexibleFunction.h:96
Top-level namespace of the msl library.
Definition acceleration.h:17