Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableComputeFunction.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* VariableComputeFunction.h (C) 2000-2025 */
9/* */
10/* Functor class for variable recalculation. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLECOMPUTEFUNCTION_H
13#define ARCANE_CORE_VARIABLECOMPUTEFUNCTION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Functor.h"
18#include "arcane/utils/TraceInfo.h"
19
20#include "arcane/core/IVariableComputeFunction.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
34class VariableComputeFunction
36{
37 public:
38
39 template <typename ClassType>
40 VariableComputeFunction(ClassType* instance, void (ClassType::*func)())
41 : m_functor(new FunctorT<ClassType>(instance, func))
42 {
43 }
44 template <typename ClassType>
45 VariableComputeFunction(ClassType* instance, void (ClassType::*func)(), const TraceInfo& tinfo)
46 : m_functor(new FunctorT<ClassType>(instance, func))
47 , m_trace_info(tinfo)
48 {
49 }
50
53 {
54 delete m_functor;
55 }
56
57 public:
58
60 void execute() override { m_functor->executeFunctor(); }
61
62 const TraceInfo& traceInfo() const override { return m_trace_info; }
63
64 private:
65
66 IFunctor* m_functor = nullptr;
67 TraceInfo m_trace_info;
68};
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73} // namespace Arcane
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78#endif
Functor associated with a method of a class T.
Interface of the functor class for recalculating a variable.
~VariableComputeFunction() override
Releases resources.
const TraceInfo & traceInfo() const override
Trace information of the calculation function definition.
void execute() override
Executes the calculation function.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --