Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableFactoryRegisterer.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/* VariableFactoryRegisterer.h (C) 2000-2025 */
9/* */
10/* Singleton allowing registration of a variable factory. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLEFACTORYREGISTERER_H
13#define ARCANE_CORE_VARIABLEFACTORYREGISTERER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/VariableTypeInfo.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \internal
30 * \brief Variable factory registrar.
31 *
32Each instance of this type must be a global variable that references
33a variable creation function of a given type. Since each instance
34is global, its creation happens before entering main(). Therefore, no
35operations using external objects or even dynamic allocations should be performed
36because the already created objects are unknown.
37
38The class is designed so that all its instances are linked by a
39linked list. The first link is retrievable via firstVariableFactory();
40*/
41class ARCANE_CORE_EXPORT VariableFactoryRegisterer
42{
43 public:
44
45 using VariableFactoryFunc = VariableFactoryVariableRefCreateFunc;
46
47 public:
48
49 //! Creates a registrar for a VariableFactory for the type \a var_type_info
50 //! and for the creation function \a func
51 VariableFactoryRegisterer(VariableFactoryFunc func, const VariableTypeInfo& var_type_info);
52
53 public:
54
55 /*!
56 * \brief Creates a factory for this variable type.
57 *
58 * The factory must be destroyed by the delete operator when it is
59 * no longer used.
60 */
62
63 //! Previous VariableFactory (0 if the first)
64 VariableFactoryRegisterer* previousVariableFactory() const { return m_previous; }
65
66 //! Next VariableFactory (0 if the last)
68
69 //! Kind of data variables of the variable created by this factory
70 eItemKind itemKind() const { return m_variable_type_info.itemKind(); }
71
72 //! Data type of the variable created by this factory
73 eDataType dataType() const { return m_variable_type_info.dataType(); }
74
75 //! Dimension of the variable created by this factory
76 Integer dimension() const { return m_variable_type_info.dimension(); }
77
78 //! Tag indicating the multiple type (0 if not multiple, 1 if multiple, 2 if multiple deprecated)
79 Integer multiTag() const { return m_variable_type_info.multiTag(); }
80
81 //! Indicates if the factory is for a partial variable.
82 bool isPartial() const { return m_variable_type_info.isPartial(); }
83
84 //! Information about the variable type
85 const VariableTypeInfo& variableTypeInfo() const { return m_variable_type_info; }
86
87 /*!
88 * \brief Positions the previous VariableFactory.
89 *
90 * This method is automatically called by IVariableFactoryRegistry.
91 */
93
94 /*!
95 * \brief Positions the next VariableFactory
96 *
97 * This method is automatically called by IVariableFactoryRegistry.
98 */
100
101 public:
102
103 static VariableFactoryRegisterer* firstVariableFactory();
104
105 private:
106
107 //! Creation function for IVariableFactoryFactory
108 VariableFactoryFunc m_function;
109
110 //! Information about the variable type
111 VariableTypeInfo m_variable_type_info;
112
113 //! Previous VariableFactory
114 VariableFactoryRegisterer* m_previous;
115
116 //! Next VariableFactory
118};
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123} // End namespace Arcane
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128#endif
Integer dimension() const
Dimension of the variable created by this factory.
IVariableFactory * createFactory()
Creates a factory for this variable type.
VariableFactoryRegisterer * previousVariableFactory() const
Previous VariableFactory (0 if the first).
void setNextVariableFactory(VariableFactoryRegisterer *s)
Positions the next VariableFactory.
Integer multiTag() const
Tag indicating the multiple type (0 if not multiple, 1 if multiple, 2 if multiple deprecated).
eDataType dataType() const
Data type of the variable created by this factory.
VariableFactoryRegisterer(VariableFactoryFunc func, const VariableTypeInfo &var_type_info)
bool isPartial() const
Indicates if the factory is for a partial variable.
eItemKind itemKind() const
Kind of data variables of the variable created by this factory.
const VariableTypeInfo & variableTypeInfo() const
Information about the variable type.
void setPreviousVariableFactory(VariableFactoryRegisterer *s)
Positions the previous VariableFactory.
VariableFactoryRegisterer * nextVariableFactory() const
Next VariableFactory (0 if the last).
Information characterizing the type of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
eItemKind
Mesh entity type.
eDataType
Data type.
Definition DataTypes.h:41