https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ChainControlData.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "Restartable.h"
13#include "MooseUtils.h"
14
15class ChainControl;
16
21{
22public:
28 ChainControlDataBase(MooseApp & moose_app, const std::string & name)
29 : Restartable(moose_app, name, "chain_control", 0),
30 _name(name),
31 _declared(false),
32 _chain_control(nullptr)
33 {
34 }
35
36 virtual ~ChainControlDataBase() = default;
37
42 virtual std::string type() = 0;
43
47 const std::string & name() const { return _name; }
48
52 const ChainControl & getChainControl() const;
53
58
62 void setDeclared() { _declared = true; }
63
67 bool getDeclared() { return _declared; }
68
72 virtual void copyValuesBack() = 0;
73
74protected:
76 const std::string _name;
81};
82
87template <typename T>
89{
90public:
95 ChainControlData(MooseApp & moose_app, std::string name)
96 : ChainControlDataBase(moose_app, name),
99 {
100 }
101
105 const T & get() const { return _value; }
106
110 const T & getOld() const { return _value_old; }
111
115 T & set() { return _value; }
116
120 virtual std::string type() override;
121
122 virtual void copyValuesBack() override;
123
124private:
129};
130
131template <typename T>
132inline std::string
134{
135 return MooseUtils::prettyCppType<T>();
136}
137
138template <typename T>
139inline void
141{
142 _value_old = _value;
143}
Abstract definition of a ChainControlData value.
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front.
ChainControl * _chain_control
The control object that declared this control data.
virtual ~ChainControlDataBase()=default
const std::string & name() const
The full (unique) name of this particular piece of data.
ChainControlDataBase(MooseApp &moose_app, const std::string &name)
Constructor.
virtual void copyValuesBack()=0
Copy the current value into the old value.
bool getDeclared()
Get the declared state.
const ChainControl & getChainControl() const
Get the pointer to the control object that declared this control data.
void setChainControl(ChainControl &ctrl)
Set the pointer to the control object that declared this control data.
const std::string _name
The full (unique) name of this particular piece of data.
void setDeclared()
Mark the data as declared.
virtual std::string type()=0
String identifying the type of parameter stored.
Concrete definition of a parameter value for a specified type.
const T & get() const
const T & getOld() const
T & _value
Current value.
ChainControlData(MooseApp &moose_app, std::string name)
Constructor.
virtual void copyValuesBack() override
Copy the current value into the old value.
T & _value_old
Old value.
virtual std::string type() override
String identifying the type of parameter stored.
Control that additionally provides the capability to produce/consume data values, to allow control op...
Base class for MOOSE-based applications.
Definition MooseApp.h:110
A class for creating restricted objects.
Definition Restartable.h:29
T & declareRestartableData(const std::string &data_name, Args &&... args)
Declare a piece of data as "restartable" and initialize it.