Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ServiceInfo.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/* ServiceInfo.cc (C) 2000-2019 */
9/* */
10/* Informations d'un service. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/List.h"
17#include "arcane/utils/VersionInfo.h"
18#include "arcane/utils/String.h"
19#include "arcane/utils/StringBuilder.h"
20
21#include "arcane/ServiceInfo.h"
22#include "arcane/ServiceFactory.h"
23#include "arcane/StringDictionary.h"
24#include "arcane/IBase.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane::Internal
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
36{
37 public:
38 ServiceInfoPrivate(const String& local_name,const VersionInfo& version,
39 Integer valid_dimension);
41 public:
42 List<IServiceFactory2*> factories() { return m_factories; }
43 void addFactory(IServiceFactory2* factory)
44 {
45 m_factories.add(factory);
46 m_ref_factories.add(ReferenceCounter<IServiceFactory2>(factory));
47 }
48 public:
49 String m_namespace_uri;
50 String m_local_name;
51 VersionInfo m_version;
52 Integer m_valid_dimension;
53 StringList m_implemented_interfaces;
54 String m_case_options_file_name;
55 private:
56 List<IServiceFactory2*> m_factories;
58 public:
59 ISingletonServiceFactory* m_singleton_factory;
60 StringDictionary m_tag_names;
61 String m_default_tag_name;
62 Real m_axl_version;
63 IServiceFactoryInfo* m_factory_info;
64 FileContent m_axl_content;
65 int m_usage_type;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71ServiceInfoPrivate::
72ServiceInfoPrivate(const String& local_name,const VersionInfo& version,
73 Integer valid_dimension)
74: m_namespace_uri(arcaneNamespaceURI())
75, m_local_name(local_name)
76, m_version(version)
77, m_valid_dimension(valid_dimension)
78, m_singleton_factory(nullptr)
79, m_axl_version(0.0)
80, m_factory_info(nullptr)
81, m_usage_type(ST_None)
82{
83 m_default_tag_name = local_name.clone();
84 m_default_tag_name = m_default_tag_name.lower();
85}
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90ServiceInfoPrivate::
91~ServiceInfoPrivate()
92{
93 delete m_singleton_factory;
94}
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
103ServiceInfo(const String& local_name,const VersionInfo& version,
104 Integer valid_dimension)
106{
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
114{
115 delete m_p;
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
122namespaceURI() const
123{
124 return m_p->m_namespace_uri;
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
131localName() const
132{
133 return m_p->m_local_name;
134}
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
140version() const
141{
142 return m_p->m_version;
143}
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
149allowDimension(Integer n) const
150{
151 if (n==3 && (m_p->m_valid_dimension & Dim3))
152 return true;
153 if (n==2 && (m_p->m_valid_dimension & Dim2))
154 return true;
155 if (n==1 && (m_p->m_valid_dimension & Dim1))
156 return true;
157 return false;
158}
159
160/*---------------------------------------------------------------------------*/
161/*---------------------------------------------------------------------------*/
162
165{
166 if (m_p->m_implemented_interfaces.contains(name))
167 return;
168 m_p->m_implemented_interfaces.add(name);
169}
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
176{
177 return m_p->m_implemented_interfaces;
178}
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
185{
186 return m_p->m_case_options_file_name;
187}
188
189/*---------------------------------------------------------------------------*/
190/*---------------------------------------------------------------------------*/
191
192void ServiceInfo::
193setCaseOptionsFileName(const String& fn)
194{
195 m_p->m_case_options_file_name = fn;
196}
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201void ServiceInfo::
202addFactory(IServiceFactory2* factory)
203{
204 m_p->addFactory(factory);
205}
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
209
211factories() const
212{
213 return m_p->factories();
214}
215
216/*---------------------------------------------------------------------------*/
217/*---------------------------------------------------------------------------*/
218
220singletonFactory() const
221{
222 return m_p->m_singleton_factory;
223}
224
225/*---------------------------------------------------------------------------*/
226/*---------------------------------------------------------------------------*/
227
228void ServiceInfo::
229setSingletonFactory(ISingletonServiceFactory* f)
230{
231 delete m_p->m_singleton_factory;
232 m_p->m_singleton_factory = f;
233}
234
235/*---------------------------------------------------------------------------*/
236/*---------------------------------------------------------------------------*/
237
239tagName(const String& lang) const
240{
241 String v = m_p->m_tag_names.find(lang);
242 if (v.null())
243 v = m_p->m_default_tag_name;
244 return v;
245}
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250void ServiceInfo::
251setDefaultTagName(const String& value)
252{
253 m_p->m_default_tag_name = value;
254}
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
259void ServiceInfo::
260setTagName(const String& value,const String& lang)
261{
262 m_p->m_tag_names.add(lang,value);
263}
264
265/*---------------------------------------------------------------------------*/
266/*---------------------------------------------------------------------------*/
267
269axlVersion() const
270{
271 return m_p->m_axl_version;
272}
273
274/*---------------------------------------------------------------------------*/
275/*---------------------------------------------------------------------------*/
276
277void ServiceInfo::
278setAxlVersion(Real v) const
279{
280 m_p->m_axl_version = v;
281}
282
283/*---------------------------------------------------------------------------*/
284/*---------------------------------------------------------------------------*/
285
287factoryInfo() const
288{
289 return m_p->m_factory_info;
290}
291
292/*---------------------------------------------------------------------------*/
293/*---------------------------------------------------------------------------*/
294
295void ServiceInfo::
296setFactoryInfo(IServiceFactoryInfo* sfi)
297{
298 m_p->m_factory_info = sfi;
299}
300
301void ServiceInfo::
302setAxlContent(const FileContent& file_content)
303{
304 m_p->m_axl_content = file_content;
305}
306
308axlContent() const
309{
310 return m_p->m_axl_content;
311}
312
313/*---------------------------------------------------------------------------*/
314/*---------------------------------------------------------------------------*/
315
317usageType() const
318{
319 return m_p->m_usage_type;
320}
321
322/*---------------------------------------------------------------------------*/
323/*---------------------------------------------------------------------------*/
324
325ServiceInfo* ServiceInfo::
326create(const ServiceProperty& sp,const char* filename,int lineno)
327{
328 ARCANE_UNUSED(filename);
329 ARCANE_UNUSED(lineno);
330 //TODO: utiliser les infos 'filename' et 'lineno'.
331
332 // Attention à bien copier la chaîne issu de sp car il s'agit d'un const char*.
333 String name = std::string_view(sp.name());
334 ServiceInfo* si = new ServiceInfo(name,VersionInfo("0.0"),IServiceInfo::Dim2|IServiceInfo::Dim3);
336 si->setFactoryInfo(sfi);
337 sfi->initProperties(sp.properties());
338 si->m_p->m_usage_type = sp.type();
339 return si;
340}
341
342/*---------------------------------------------------------------------------*/
343/*---------------------------------------------------------------------------*/
344
345ServiceInfo* ServiceInfo::
346create(const String& name,int service_type)
347{
348 ServiceProperty sp(name.localstr(),service_type);
349 return create(sp,"none",0);
350}
351
352/*---------------------------------------------------------------------------*/
353/*---------------------------------------------------------------------------*/
354
355} // End namespace Arcane::Internal
356
357/*---------------------------------------------------------------------------*/
358/*---------------------------------------------------------------------------*/
359
Description et contenu d'un fichier.
Definition FileContent.h:32
Informations sur la fabrique d'un service.
Infos sur la fabrication d'un service ou d'un module.
Informations d'un service.
Definition ServiceInfo.h:46
ServiceInfo(const String &local_name, const VersionInfo &version, Integer valid_dimension)
Constructeur.
const FileContent & axlContent() const override
Contenu du fichier AXL associé à ce service ou module.
~ServiceInfo() override
Destructeur.
String localName() const override
Partie locale du nom du service.
String namespaceURI() const override
Namespace du nom du service.
bool allowDimension(Integer n) const override
Indique si le service est utilisable en dimension n.
VersionInfo version() const override
Version du service.
StringCollection implementedInterfaces() const override
Liste des noms des classes implémentées par ce service.
ServiceFactory2Collection factories() const override
Liste des fabriques du service.
void addImplementedInterface(const String &name) override
Ajoute l'interface de nom name aux interfaces implémentées par ce service.
ISingletonServiceFactory * singletonFactory() const override
Fabrique pour les service singleton (nullptr si non supporté)
int usageType() const override
Indique où peut être utilisé le service.
const String & caseOptionsFileName() const override
Nom du fichier contenant le jeu de données (nul si aucun)
IServiceFactoryInfo * factoryInfo() const override
Infos sur les fabriques disponibles pour ce service.
Real axlVersion() const override
Version du fichier axl décrivant ce service.
String tagName(const String &lang) const override
Nom de l'élément XML du service pour le langage lang. Si lang est nul, retourne le nom par défaut.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Propriétés de création d'un service.
Dictionnaire de chaînes unicode.
void add(const String &key, const String &value)
Ajoute le couple (key,value) au dictionnaire.
String find(const String &key, bool throw_exception=false) const
Retourne la valeur associée à key.
Informations sur une version.
Definition VersionInfo.h:46
Chaîne de caractères unicode.
bool null() const
Retourne true si la chaîne est nulle.
Definition String.cc:304
String lower() const
Transforme tous les caractères de la chaîne en minuscules.
Definition String.cc:478
Types interne à Arcane.
Definition ArcaneTypes.h:88