Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
EntryPoint.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/* EntryPoint.h (C) 2000-2025 */
9/* */
10/* Module entry point. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ENTRYPOINT_H
13#define ARCANE_CORE_ENTRYPOINT_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/utils/FunctorWithAddress.h"
19#include "arcane/core/IEntryPoint.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26class Timer;
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
37class ARCANE_CORE_EXPORT EntryPointBuildInfo
38{
39 public:
40
57 EntryPointBuildInfo(IModule* module, const String& name,
58 IFunctor* caller, const String& where, int property,
59 bool is_destroy_caller)
60 : m_module(module)
61 , m_name(name)
62 , m_caller(caller)
63 , m_where(where)
64 , m_property(property)
65 , m_is_destroy_caller(is_destroy_caller)
66 {
67 }
68
69 public:
70
71 IModule* module() const { return m_module; }
72 const String& name() const { return m_name; }
73 IFunctor* caller() const { return m_caller; }
74 const String& where() const { return m_where; }
75 int property() const { return m_property; }
76 bool isDestroyCaller() const { return m_is_destroy_caller; }
77
78 private:
79
80 IModule* m_module;
81 String m_name;
82 IFunctor* m_caller;
83 String m_where;
84 int m_property;
85 bool m_is_destroy_caller;
86};
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
95class ARCANE_CORE_EXPORT EntryPoint
96: public IEntryPoint
97{
98 public:
99
101 ~EntryPoint() override;
102
103 public:
104
112 static EntryPoint* create(const EntryPointBuildInfo& bi);
113
114 public:
115
116 String name() const override { return m_name; }
117 String fullName() const override { return m_full_name; }
118 ISubDomain* subDomain() const override { return m_sub_domain; }
119 IModule* module() const override { return m_module; }
120 void executeEntryPoint() override;
121 Real totalCPUTime() const override;
122 Real lastCPUTime() const override;
123 Real totalElapsedTime() const override;
124 Real lastElapsedTime() const override;
125 Real totalTime(Timer::eTimerType type) const override;
126 Real lastTime(Timer::eTimerType type) const override;
127 Integer nbCall() const override { return m_nb_call; }
128 String where() const override { return m_where; }
129 int property() const override { return m_property; }
130
131 private:
132
134 IFunctor* m_caller = nullptr;
138 IModule* m_module = nullptr;
140 int m_property = 0;
142 bool m_is_destroy_caller = false;
143
144 private:
145
146 explicit EntryPoint(const EntryPointBuildInfo& build_info);
147
148 public:
149
150 EntryPoint(const EntryPoint&) = delete;
151 void operator=(const EntryPoint&) = delete;
152
153 private:
154
155 void _getAddressForHyoda(void* = nullptr);
156};
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
173template <typename ModuleType> inline void
174addEntryPoint(ModuleType* module, const char* name, void (ModuleType::*func)(),
175 const String& where = IEntryPoint::WComputeLoop,
176 int property = IEntryPoint::PNone)
177{
178 IFunctorWithAddress* caller = new FunctorWithAddressT<ModuleType>(module, func);
179 EntryPoint::create(EntryPointBuildInfo(module, name, caller, where, property, true));
180}
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
197template <typename ModuleType> inline void
198addEntryPoint(ModuleType* module, const String& name, void (ModuleType::*func)(),
199 const String& where = IEntryPoint::WComputeLoop,
200 int property = IEntryPoint::PNone)
201{
202 IFunctorWithAddress* caller = new FunctorWithAddressT<ModuleType>(module, func);
203 EntryPoint::create(EntryPointBuildInfo(module, name, caller, where, property, true));
204}
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209} // End namespace Arcane
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214#endif
Information to build an entry point.
Definition EntryPoint.h:38
EntryPointBuildInfo(IModule *module, const String &name, IFunctor *caller, const String &where, int property, bool is_destroy_caller)
Entry point build information.
Definition EntryPoint.h:57
IFunctor * m_caller
Call point.
Definition EntryPoint.h:134
int m_property
Entry point properties.
Definition EntryPoint.h:140
Timer * m_elapsed_timer
Entry point clock timer.
Definition EntryPoint.h:135
ISubDomain * m_sub_domain
Sub-domain manager.
Definition EntryPoint.h:133
Integer m_nb_call
Number of times the entry point has been executed.
Definition EntryPoint.h:141
String where() const override
Returns where the entry point is called.
Definition EntryPoint.h:128
IModule * module() const override
Returns the module associated with the entry point.
Definition EntryPoint.h:119
static EntryPoint * create(const EntryPointBuildInfo &bi)
Constructs and returns an entry point.
Definition EntryPoint.cc:78
String name() const override
Returns the name of the entry point.
Definition EntryPoint.h:116
String fullName() const override
Full name (with the module) of the entry point. This name is unique.
Definition EntryPoint.h:117
bool m_is_destroy_caller
Indicates whether the calling functor should be destroyed.
Definition EntryPoint.h:142
Integer nbCall() const override
Returns the number of times the entry point has been executed.
Definition EntryPoint.h:127
IModule * m_module
Associated module.
Definition EntryPoint.h:138
String m_where
Call location.
Definition EntryPoint.h:139
int property() const override
Returns the properties of the entry point.
Definition EntryPoint.h:129
String m_full_name
Entry point name.
Definition EntryPoint.h:137
ISubDomain * subDomain() const override
Returns the main manager.
Definition EntryPoint.h:118
String m_name
Entry point name.
Definition EntryPoint.h:136
FunctorWithAddress associated with a method of a class T.
Interface of a module entry point.
Definition IEntryPoint.h:35
static const char *const WComputeLoop
called during the calculation loop
Definition IEntryPoint.h:43
@ PNone
No properties.
Definition IEntryPoint.h:67
Interface of a functor.
Interface of a module.
Definition IModule.h:40
Interface of the subdomain manager.
Definition ISubDomain.h:75
Management of a timer.
Definition Timer.h:63
eTimerType
Timer type.
Definition Timer.h:68
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
void addEntryPoint(ModuleType *module, const char *name, void(ModuleType::*func)(), const String &where=IEntryPoint::WComputeLoop, int property=IEntryPoint::PNone)
Template routine allowing an entry point to be referenced in a module.
Definition EntryPoint.h:174