Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ServiceRegisterer.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* ServiceRegisterer.cc (C) 2000-2018 */
9/* */
10/* Registre contenant la liste des manufactures de services. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/Iostream.h"
17
18#include "arcane/ServiceRegisterer.h"
19
20#include <stdlib.h>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25ARCANE_BEGIN_NAMESPACE
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30static ServiceRegisterer* global_arcane_first_service = nullptr;
31static Integer global_arcane_nb_service = 0;
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36ServiceRegisterer::
37ServiceRegisterer(ServiceInfoWithPropertyCreateFunc func,
38 const ServiceProperty& properties) ARCANE_NOEXCEPT
39: m_module_factory_with_property_functor(nullptr)
40, m_info_function_with_property(func)
41, m_name(properties.name())
42, m_service_property(properties)
43, m_module_property(properties.name())
44, m_previous(nullptr)
45, m_next(nullptr)
46{
47 _init();
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
53ServiceRegisterer::
54ServiceRegisterer(ModuleFactoryWithPropertyFunc func,
55 const ModuleProperty& properties) ARCANE_NOEXCEPT
56: m_module_factory_with_property_functor(func)
57, m_info_function_with_property(nullptr)
58, m_name(properties.name())
59, m_service_property(ServiceProperty(properties.name(),0))
60, m_module_property(properties)
61, m_previous(nullptr)
62, m_next(nullptr)
63{
64 _init();
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
70void ServiceRegisterer::
71_init()
72{
73 if (global_arcane_first_service==nullptr){
74 global_arcane_first_service = this;
75 setPreviousService(nullptr);
76 setNextService(nullptr);
77 }
78 else{
79 ServiceRegisterer* next = global_arcane_first_service->nextService();
80 setNextService(global_arcane_first_service);
81 global_arcane_first_service = this;
82 if (next)
83 next->setPreviousService(this);
84 }
85 ++global_arcane_nb_service;
86
87 { // Check integrity
88 ServiceRegisterer * p = global_arcane_first_service;
89 Integer count = global_arcane_nb_service;
90 while (p && count > 0) {
91 p = p->nextService();
92 --count;
93 }
94 if (p) {
95 cout << "Arcane Fatal Error: Service '" << m_name << "' conflict in service registration" << std::endl;
96 exit(1);
97 } else if (count > 0) {
98 cout << "Arcane Fatal Error: Service '" << m_name << "' breaks service registration (inconsistent shortcut)" << std::endl;
99 exit(1);
100 }
101 }
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107ServiceRegisterer* ServiceRegisterer::
108firstService()
109{
110 return global_arcane_first_service;
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116Integer ServiceRegisterer::
117nbService()
118{
119 return global_arcane_nb_service;
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125ARCANE_END_NAMESPACE
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
Propriétés de création d'un module.
Propriétés de création d'un service.
Enregistreur de service et modules.
ServiceRegisterer * nextService() const
Service suivant (0 si le dernier)
Int32 Integer
Type représentant un entier.