14#include "arcane/utils/ArcanePrecomp.h"
15#include "arcane/utils/ITraceMng.h"
16#include "arcane/utils/InvalidArgumentException.h"
17#include "arcane/utils/IStackTraceService.h"
18#include "arcane/utils/TraceInfo.h"
19#include "arcane/utils/PlatformUtils.h"
21#include "arcane/core/VariableRef.h"
22#include "arcane/core/VariableBuildInfo.h"
23#include "arcane/core/ISubDomain.h"
24#include "arcane/core/IModule.h"
25#include "arcane/core/IVariableMng.h"
26#include "arcane/core/ArcaneException.h"
56 typedef void (*ChangedFunc)();
60 UpdateNotifyFunctorList()
61 : m_is_destroyed(
false)
66 std::set<ChangedFunc> m_funcs;
73 std::set<ChangedFunc>::const_iterator begin = m_funcs.begin();
74 std::set<ChangedFunc>::const_iterator end = m_funcs.end();
75 for (; begin != end; ++begin) {
76 ChangedFunc f = *begin;
85 m_is_destroyed =
true;
90 void add(ChangedFunc f)
95 void remove(ChangedFunc f)
103 static void* _add(
VariableRef* var,
void (*func)())
110 if (!var->m_notify_functor_list) {
113 var->m_notify_functor_list->add(func);
114 return var->m_notify_functor_list;
116 static void _remove(UpdateNotifyFunctorList* functor_list,
122 functor_list->remove(func);
129 if (m_is_destroyed && m_funcs.empty())
140, m_reference_property(vbi.
property())
144 _setAssignmentStackTrace();
153, m_reference_property(var->
property())
157 _setAssignmentStackTrace();
180: m_variable(from.m_variable)
181, m_module(from.m_module)
182, m_reference_property(from.m_reference_property)
184 _setAssignmentStackTrace();
200 if (rhs.m_variable != m_variable)
201 _internalAssignVariable(rhs);
215 if (m_notify_functor_list)
216 m_notify_functor_list->destroy();
225_setAssignmentStackTrace()
227 m_assignment_stack_trace =
String();
228 if (hasTraceCreation()) {
243 m_variable->removeVariableRef(
this);
244 m_is_registered =
false;
254 m_variable->addVariableRef(
this);
255 m_is_registered =
true;
280 return m_variable->dataType();
287print(std::ostream& o)
const
290 m_variable->print(o);
300 return m_variable->name();
310 return m_variable->property();
320 return m_variable->subDomain();
330 return m_variable->variableMng();
340 return m_variable->checkIfSync(max_print);
350 return m_variable->checkIfSameOnAllReplica(max_print);
359 return m_reference_property;
376 String msg(
"Using a reference on a uninitialized variable");
386 if (!_checkValidPropertyChanged(
property))
389 m_variable->notifyReferencePropertyChanged();
398 if (!_checkValidPropertyChanged(
property))
401 m_variable->notifyReferencePropertyChanged();
411_checkValidPropertyChanged(
int property)
443 m_variable->update();
452 m_variable->setUpToDate();
461 return m_variable->modifiedTime();
470 m_variable->addDepend(var.
variable(), IVariable::DPT_CurrentTime);
479 m_variable->addDepend(var.
variable(), IVariable::DPT_PreviousTime);
488 m_variable->addDepend(var.
variable(), IVariable::DPT_CurrentTime, tinfo);
497 m_variable->addDepend(var.
variable(), IVariable::DPT_PreviousTime, tinfo);
506 m_variable->removeDepend(var.
variable());
524 m_variable->addTag(tagname, tagvalue);
533 m_variable->removeTag(tagname);
542 return m_variable->hasTag(tagname);
551 return m_variable->tagValue(tagname);
560 return m_previous_reference;
569 return m_next_reference;
578 m_previous_reference = v;
585setNextReference(VariableRef* v)
587 m_next_reference = v;
596bool VariableRef::m_static_has_trace_creation =
false;
602setTraceCreation(
bool v)
604 m_static_has_trace_creation = v;
613 return m_static_has_trace_creation;
620_executeUpdateFunctors()
622 if (m_notify_functor_list)
623 m_notify_functor_list->execute();
632 _setAssignmentStackTrace();
635 m_module = var.m_module;
636 m_variable = var.m_variable;
637 m_reference_property = var.m_reference_property;
654extern "C" ARCANE_CORE_EXPORT
void*
655_AddVariableChangedDelegate(
VariableRef* var,
void (*func)())
657 return VariableRef::UpdateNotifyFunctorList::_add(var, func);
664extern "C" ARCANE_CORE_EXPORT
void
668 VariableRef::UpdateNotifyFunctorList::_remove(functor_list, func);
virtual StackTrace stackTrace(int first_function=0)=0
Character string indicating the call stack.
Interface of the subdomain manager.
Interface of the functor class for recalculating a variable.
Variable manager interface.
@ PSubDomainDepend
Indicates that the variable value is dependent on the subdomain.
@ PNoExchange
Indicates that the variable should not be exchanged.
@ PNoReplicaSync
Indicates that the variable does not necessarily have the same value across replicas.
@ PExecutionDepend
Indicates that the variable value is dependent on the execution.
@ PHasTrace
Indicates that the variable is traced (only in trace mode).
@ PPrivate
Indicates that the variable is private.
@ PPersistant
Indicates that the variable is persistent.
@ PNoRestore
Indicates that the variable should not be restored.
@ PSubDomainPrivate
Indicates that the variable is private to the subdomain.
@ PNoNeedSync
Indicates that the variable is not necessarily synchronized.
@ PNoDump
Indicates that the variable should not be saved.
@ PDumpNull
Indicates that the save will be null for this variable and for this subdomain.
virtual void setComputeFunction(IVariableComputeFunction *v)=0
Sets the variable's recalculation function.
Exception when a fatal error has occurred.
const String & toString() const
String indicating the call stack.
Unicode character string.
Parameters necessary for building a variable.
Internal class to manage functors called when the variable is updated.
virtual Integer checkIfSameOnAllReplica(int max_print=0)
Checks if the variable has the same values on all replicas.
virtual void updateFromInternal()
Updates from the internal part.
VariableRef(const VariableBuildInfo &vbi)
Constructs a reference to a variable with the infos vbi.
VariableRef & operator=(const VariableRef &from)
Copy assignment operator.
virtual void setProperty(int property)
Sets the property property.
VariableRef()
Default constructor.
virtual eDataType dataType() const
Variable type (Real, Integer, ...).
void removeTag(const String &tagname)
Removes the tag tagname.
virtual Integer checkIfSync(int max_print=0)
Checks if the variable is synchronized.
virtual void print(std::ostream &o) const
Prints the variable value.
virtual int property() const
Variable properties.
virtual void unsetProperty(int property)
Unsets the property property.
void addTag(const String &tagname, const String &tagvalue)
Adds the tag tagname with the value tagvalue.
Int64 modifiedTime()
Time when the variable was updated.
virtual IModule * module() const
Module associated with the variable (or nullptr, if none).
VariableRef * previousReference()
Previous reference (or null) to variable().
String tagValue(const String &tagname) const
Value of the tag tagname. The string is null if the tag does not exist.
void setUpToDate()
Indicates that the variable has just been updated.
void addDependCurrentTime(const VariableRef &var)
Adds var to the dependency list at the current time.
IVariable * variable() const
Associated variable.
void update()
Recalculates the variable if necessary.
void _internalInit(IVariable *)
Internal initialization of the variable.
virtual void unregisterVariable()
Unregisters the variable (internal).
String name() const
Variable name.
ISubDomain * subDomain() const
Sub-domain associated with the variable (TODO deprecate end of 2023).
virtual void registerVariable()
Registers the variable (internal).
virtual int referenceProperty() const
Reference properties (internal).
bool hasTag(const String &tagname) const
true if the variable has the tag tagname
void removeDepend(const VariableRef &var)
Removes var from the dependency list.
IVariableMng * variableMng() const
Variable manager associated with the variable.
void addDependPreviousTime(const VariableRef &var)
Adds var to the dependency list at the previous time.
virtual ~VariableRef()
Releases resources.
VariableRef * nextReference()
Next reference (or null) to variable().
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
@ IK_Unknown
Unknown or uninitialized mesh entity.