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())
144 _setAssignmentStackTrace();
157 _setAssignmentStackTrace();
184 _setAssignmentStackTrace();
201 _internalAssignVariable(rhs);
215 if (m_notify_functor_list)
216 m_notify_functor_list->destroy();
225_setAssignmentStackTrace()
228 if (hasTraceCreation()) {
287print(std::ostream& o)
const
350 return m_variable->checkIfSameOnAllReplica(max_print);
376 String msg(
"Using a reference on a uninitialized variable");
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();
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);
Interface of a function call tracing service.
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 an internal error occurs.
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.
IModule * m_module
Associated module (or 0 if none).
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.
bool _checkValidPropertyChanged(int property)
Checks if a property can be changed dynamically.
VariableRef & operator=(const VariableRef &from)
Copy assignment operator.
virtual void setProperty(int property)
Sets the property property.
VariableRef()
Default constructor.
bool m_is_registered
true if the variable has been registered
virtual eDataType dataType() const
Variable type (Real, Integer, ...).
void removeTag(const String &tagname)
Removes the tag tagname.
VariableRef * m_previous_reference
Previous reference on m_variable.
virtual Integer checkIfSync(int max_print=0)
Checks if the variable is synchronized.
virtual void print(std::ostream &o) const
Prints the variable value.
void setPreviousReference(VariableRef *v)
Sets the previous reference.
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.
int m_reference_property
Reference properties.
String m_assignment_stack_trace
Call stack during variable assignment.
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.
VariableRef * m_next_reference
Next reference on m_variable.
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.
IVariable * m_variable
Associated variable.
IVariableMng * variableMng() const
Variable manager associated with the variable.
void addDependPreviousTime(const VariableRef &var)
Adds var to the dependency list at the previous time.
void setNextReference(VariableRef *v)
Sets the next reference.
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.