R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BParView.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <string_view>
5
6namespace R3B
7{
8
9 template <typename ParType>
10 class ParView
11 {
12 public:
13 using Type = ParType;
14
20 explicit ParView(std::string_view par_name)
21 : name_{ par_name }
22 {
23 }
24
31 auto get() const -> Type* { return parameter_; }
32
38 [[nodiscard]] auto get_name() const -> std::string_view { return name_; }
39
45 auto set(Type* par) -> Type* { return parameter_ = par; }
46
47 auto operator->() -> Type* { return parameter_; }
48
49 auto operator*() -> Type& { return *parameter_; }
50
51 private:
52 std::string name_;
53 ParType* parameter_ = nullptr;
54 };
55
56 template <typename ParType>
57 class InputParView : public ParView<ParType>
58 {
59 public:
63 explicit InputParView(std::string_view par_name)
64 : ParView<ParType>{ par_name }
65 {
66 }
67
75 template <typename TaskType>
76 void init(TaskType* task)
77 {
78 auto* par = task->template AddInputPar<ParType>(this->get_name());
79 this->set(par);
80 }
81 };
82
83 template <typename ParType>
84 class OutputParView : public ParView<ParType>
85 {
86 public:
90 explicit OutputParView(std::string_view par_name)
91 : ParView<ParType>{ par_name }
92 {
93 }
94
103 template <typename TaskType>
104 void init(TaskType* task)
105 {
106 auto* par = task->template AddOutputPar<ParType>(this->get_name());
107 this->set(par);
108 }
109 };
110
111} // namespace R3B
InputParView(std::string_view par_name)
Constructor.
Definition R3BParView.h:63
void init(TaskType *task)
Initialization of input parameter.
Definition R3BParView.h:76
void init(TaskType *task)
Initialization of output parameter.
Definition R3BParView.h:104
OutputParView(std::string_view par_name)
Constructor.
Definition R3BParView.h:90
ParType * parameter_
Definition R3BParView.h:53
ParView(std::string_view par_name)
Constructor.
Definition R3BParView.h:20
auto operator*() -> Type &
Definition R3BParView.h:49
auto set(Type *par) -> Type *
Set the pointer of the parameter.
Definition R3BParView.h:45
std::string name_
Definition R3BParView.h:52
ParType Type
Definition R3BParView.h:13
auto get_name() const -> std::string_view
Get the name of the paramter.
Definition R3BParView.h:38
auto get() const -> Type *
Get the parameter pointer.
Definition R3BParView.h:31
auto operator->() -> Type *
Definition R3BParView.h:47