https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ChainControlDataBase Class Referenceabstract

Abstract definition of a ChainControlData value. More...

#include <ChainControlData.h>

Inheritance diagram for ChainControlDataBase:
[legend]

Public Member Functions

 ChainControlDataBase (MooseApp &moose_app, const std::string &name)
 Constructor. More...
 
virtual ~ChainControlDataBase ()=default
 
virtual std::string type ()=0
 String identifying the type of parameter stored. More...
 
const std::string & name () const
 The full (unique) name of this particular piece of data. More...
 
const ChainControlgetChainControl () const
 Get the pointer to the control object that declared this control data. More...
 
void setChainControl (ChainControl &ctrl)
 Set the pointer to the control object that declared this control data. More...
 
void setDeclared ()
 Mark the data as declared. More...
 
bool getDeclared ()
 Get the declared state. More...
 
virtual void copyValuesBack ()=0
 Copy the current value into the old value. More...
 

Protected Member Functions

template<typename T , typename... Args>
T & declareRestartableData (const std::string &data_name, Args &&... args)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T , typename... Args>
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 Declares a piece of "managed" restartable data and initialize it. More...
 
template<typename T , typename... Args>
const T & getRestartableData (const std::string &data_name) const
 Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but returns a const reference to the object. More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T , typename... Args>
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 Declare a piece of data as "recoverable" and initialize it. More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 Declare a piece of data as "restartable". More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 Declare a piece of data as "restartable". More...
 
std::string restartableName (const std::string &data_name) const
 Gets the name of a piece of restartable data given a data name, adding the system name and object name prefix. More...
 

Protected Attributes

const std::string _name
 The full (unique) name of this particular piece of data. More...
 
bool _declared
 true if the data was declared by calling declareControlData. All data must be declared up front. More...
 
ChainControl_chain_control
 The control object that declared this control data. More...
 
MooseApp_restartable_app
 Reference to the application. More...
 
const std::string _restartable_system_name
 The system name this object is in. More...
 
const THREAD_ID _restartable_tid
 The thread ID for this object. More...
 
const bool _restartable_read_only
 Flag for toggling read only status (see ReporterData) More...
 

Detailed Description

Abstract definition of a ChainControlData value.

Definition at line 20 of file ChainControlData.h.

Constructor & Destructor Documentation

◆ ChainControlDataBase()

ChainControlDataBase::ChainControlDataBase ( MooseApp moose_app,
const std::string &  name 
)
inline

Constructor.

Parameters
moose_appMooseApp object this object belong to
nameThe full (unique) name for this piece of data.

Definition at line 28 of file ChainControlData.h.

29  : Restartable(moose_app, name, "chain_control", 0),
30  _name(name),
31  _declared(false),
32  _chain_control(nullptr)
33  {
34  }
const std::string _name
The full (unique) name of this particular piece of data.
const std::string & name() const
The full (unique) name of this particular piece of data.
Restartable(const MooseObject *moose_object, const std::string &system_name)
Class constructor.
Definition: Restartable.C:18
ChainControl * _chain_control
The control object that declared this control data.
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front...

◆ ~ChainControlDataBase()

virtual ChainControlDataBase::~ChainControlDataBase ( )
virtualdefault

Member Function Documentation

◆ copyValuesBack()

virtual void ChainControlDataBase::copyValuesBack ( )
pure virtual

Copy the current value into the old value.

Implemented in ChainControlData< T >, ChainControlData< bool >, and ChainControlData< Real >.

◆ declareManagedRestartableDataWithContext()

template<typename T , typename... Args>
Restartable::ManagedValue< T > Restartable::declareManagedRestartableDataWithContext ( const std::string &  data_name,
void context,
Args &&...  args 
)
protectedinherited

Declares a piece of "managed" restartable data and initialize it.

Here, "managed" restartable data means that the caller can destruct this data upon destruction of the return value of this method. Therefore, this ManagedValue<T> wrapper should survive after the final calls to dataStore() for it. That is... at the very end.

This is needed for objects whose destruction ordering is important, and enables natural c++ destruction in reverse construction order of the object that declares it.

See delcareRestartableData and declareRestartableDataWithContext for more information.

Definition at line 276 of file Restartable.h.

279 {
280  auto & data_ptr =
281  declareRestartableDataHelper<T>(data_name, context, std::forward<Args>(args)...);
282  return Restartable::ManagedValue<T>(data_ptr);
283 }
Wrapper class for restartable data that is "managed.
Definition: Restartable.h:42

◆ declareRecoverableData()

template<typename T , typename... Args>
T & Restartable::declareRecoverableData ( const std::string &  data_name,
Args &&...  args 
)
protectedinherited

Declare a piece of data as "recoverable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

Note - this data will NOT be restored on Restart!

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
argsArguments to forward to the constructor of the data

Definition at line 351 of file Restartable.h.

352 {
353  const auto full_name = restartableName(data_name);
354 
356 
357  return declareRestartableDataWithContext<T>(data_name, nullptr, std::forward<Args>(args)...);
358 }
std::string restartableName(const std::string &data_name) const
Gets the name of a piece of restartable data given a data name, adding the system name and object nam...
Definition: Restartable.C:66
void registerRestartableNameWithFilterOnApp(const std::string &name, Moose::RESTARTABLE_FILTER filter)
Helper function for actually registering the restartable data.
Definition: Restartable.C:59

◆ declareRestartableData()

template<typename T , typename... Args>
T & Restartable::declareRestartableData ( const std::string &  data_name,
Args &&...  args 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
argsArguments to forward to the constructor of the data

Definition at line 269 of file Restartable.h.

270 {
271  return declareRestartableDataWithContext<T>(data_name, nullptr, std::forward<Args>(args)...);
272 }

◆ declareRestartableDataWithContext()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithContext ( const std::string &  data_name,
void context,
Args &&...  args 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
contextContext pointer that will be passed to the load and store functions
argsArguments to forward to the constructor of the data

Definition at line 294 of file Restartable.h.

297 {
298  return declareRestartableDataHelper<T>(data_name, context, std::forward<Args>(args)...).set();
299 }

◆ declareRestartableDataWithObjectName()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithObjectName ( const std::string &  data_name,
const std::string &  object_name,
Args &&...  args 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.
argsArguments to forward to the constructor of the data

Definition at line 323 of file Restartable.h.

326 {
327  return declareRestartableDataWithObjectNameWithContext<T>(
328  data_name, object_name, nullptr, std::forward<Args>(args)...);
329 }

◆ declareRestartableDataWithObjectNameWithContext()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithObjectNameWithContext ( const std::string &  data_name,
const std::string &  object_name,
void context,
Args &&...  args 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.
contextContext pointer that will be passed to the load and store functions
argsArguments to forward to the constructor of the data

Definition at line 333 of file Restartable.h.

337 {
338  std::string old_name = _restartable_name;
339 
340  _restartable_name = object_name;
341 
342  T & value = declareRestartableDataWithContext<T>(data_name, context, std::forward<Args>(args)...);
343 
344  _restartable_name = old_name;
345 
346  return value;
347 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:243
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ getChainControl()

const ChainControl & ChainControlDataBase::getChainControl ( ) const

Get the pointer to the control object that declared this control data.

Definition at line 13 of file ChainControlData.C.

14 {
15  if (!_chain_control)
16  mooseError("No chain control has been set for chain control data '", name(), "'.");
17 
18  return *_chain_control;
19 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
const std::string & name() const
The full (unique) name of this particular piece of data.
ChainControl * _chain_control
The control object that declared this control data.

◆ getDeclared()

bool ChainControlDataBase::getDeclared ( )
inline

Get the declared state.

Definition at line 67 of file ChainControlData.h.

67 { return _declared; }
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front...

◆ getRestartableData()

template<typename T , typename... Args>
const T & Restartable::getRestartableData ( const std::string &  data_name) const
protectedinherited

Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but returns a const reference to the object.

Forwarded arguments are not allowed in this case because we assume that the object is restarted and we won't need different constructors to initialize it.

NOTE: This returns a const reference! Make sure you store it in a const reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 287 of file Restartable.h.

288 {
289  return declareRestartableDataHelper<T>(data_name, nullptr).get();
290 }

◆ name()

const std::string& ChainControlDataBase::name ( ) const
inline

The full (unique) name of this particular piece of data.

Definition at line 47 of file ChainControlData.h.

Referenced by getChainControl().

47 { return _name; }
const std::string _name
The full (unique) name of this particular piece of data.

◆ restartableName()

std::string Restartable::restartableName ( const std::string &  data_name) const
protectedinherited

Gets the name of a piece of restartable data given a data name, adding the system name and object name prefix.

This should only be used in this interface and in testing.

Definition at line 66 of file Restartable.C.

Referenced by Restartable::declareRecoverableData(), and Restartable::declareRestartableDataHelper().

67 {
68  return _restartable_system_name + "/" + _restartable_name + "/" + data_name;
69 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:243
const std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:230

◆ setChainControl()

void ChainControlDataBase::setChainControl ( ChainControl ctrl)
inline

Set the pointer to the control object that declared this control data.

Definition at line 57 of file ChainControlData.h.

57 { _chain_control = &ctrl; }
ChainControl * _chain_control
The control object that declared this control data.

◆ setDeclared()

void ChainControlDataBase::setDeclared ( )
inline

Mark the data as declared.

Definition at line 62 of file ChainControlData.h.

62 { _declared = true; }
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front...

◆ type()

virtual std::string ChainControlDataBase::type ( )
pure virtual

String identifying the type of parameter stored.

Must be reimplemented in derived classes.

Implemented in ChainControlData< T >, ChainControlData< bool >, and ChainControlData< Real >.

Member Data Documentation

◆ _chain_control

ChainControl* ChainControlDataBase::_chain_control
protected

The control object that declared this control data.

Definition at line 80 of file ChainControlData.h.

Referenced by getChainControl(), and setChainControl().

◆ _declared

bool ChainControlDataBase::_declared
protected

true if the data was declared by calling declareControlData. All data must be declared up front.

Definition at line 78 of file ChainControlData.h.

Referenced by getDeclared(), and setDeclared().

◆ _name

const std::string ChainControlDataBase::_name
protected

The full (unique) name of this particular piece of data.

Definition at line 76 of file ChainControlData.h.

Referenced by name().

◆ _restartable_app

MooseApp& Restartable::_restartable_app
protectedinherited

Reference to the application.

Definition at line 227 of file Restartable.h.

Referenced by Restartable::registerRestartableDataOnApp(), and Restartable::registerRestartableNameWithFilterOnApp().

◆ _restartable_read_only

const bool Restartable::_restartable_read_only
protectedinherited

Flag for toggling read only status (see ReporterData)

Definition at line 236 of file Restartable.h.

Referenced by Restartable::registerRestartableDataOnApp().

◆ _restartable_system_name

const std::string Restartable::_restartable_system_name
protectedinherited

The system name this object is in.

Definition at line 230 of file Restartable.h.

Referenced by Restartable::restartableName().

◆ _restartable_tid

const THREAD_ID Restartable::_restartable_tid
protectedinherited

The thread ID for this object.

Definition at line 233 of file Restartable.h.

Referenced by Restartable::declareRestartableDataHelper().


The documentation for this class was generated from the following files: