Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
FlexLMTools.h
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/* FlexLMTools.h (C) 2000-2012 */
9/* */
10/* Gestion des protections FlexLM. . */
11/*---------------------------------------------------------------------------*/
12
13#ifndef ARCANE_UTILS_FLEXLMTOOLS_H_
14#define ARCANE_UTILS_FLEXLMTOOLS_H_
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include "arcane/ArcaneVersion.h"
20#include "arcane/utils/String.h"
21#include "arcane/utils/Exception.h"
22#include <map>
23#include <iostream>
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28ARCANE_BEGIN_NAMESPACE
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33class IParallelSuperMng;
34class TraceInfo;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
40class ARCANE_IMPL_EXPORT LicenseErrorException
41: public Exception
42{
43 public:
44
45 LicenseErrorException(const String& where);
46 LicenseErrorException(const TraceInfo& where);
47 LicenseErrorException(const String& where, const String& message);
48 LicenseErrorException(const TraceInfo& where, const String& message);
49 ~LicenseErrorException() ARCANE_NOEXCEPT {}
50
51 public:
52
53 virtual void explain(std::ostream& m) const;
54 virtual void write(std::ostream& o) const;
55
56 private:
57};
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
63
71class ARCANE_IMPL_EXPORT FlexLMMng
72{
73 private:
74
76 FlexLMMng();
77
79 virtual ~FlexLMMng() {}
80
81 public:
82
84 static FlexLMMng* instance();
85
86 public:
87
90
92
97 void setCheckInterval(const Integer t = 120);
98
100
103 bool checkLicense(const String name, const Real version, bool do_fatal = true) const;
104
106
109 void getLicense(const String name, const Real version, Integer nb_licenses = 1);
110
112
114 void releaseLicense(const String name, Integer nb_licenses = 0);
115
117
118 void releaseAllLicenses();
119
121 String featureInfo(const String name, const Real version) const;
122
123 private:
124
125 typedef std::map<String, Integer> FeatureMapType;
126 FeatureMapType m_features;
127 static FlexLMMng* m_instance;
128 IParallelSuperMng* m_parallel_super_mng;
130};
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
136template <typename FeatureModel>
138{
139 public:
140
143
145 virtual ~FlexLMTools() {}
146
147 public:
148
150
151 bool checkLicense(typename FeatureModel::eFeature feature, const bool do_fatal) const
152 {
153 const String name = FeatureModel::getName(feature);
154 const Real version = FeatureModel::getVersion(feature);
155 return FlexLMMng::instance()->checkLicense(name, version, do_fatal);
156 }
157
159
161 bool checkLicense(typename FeatureModel::eFeature feature, const Real version, const bool do_fatal) const
162 {
163 const String name = FeatureModel::getName(feature);
164 return FlexLMMng::instance()->checkLicense(name, version, do_fatal);
165 }
166
168
169 void getLicense(typename FeatureModel::eFeature feature, Integer nb_licenses = 1)
170 {
171 const String name = FeatureModel::getName(feature);
172 const Real version = FeatureModel::getVersion(feature);
173 return FlexLMMng::instance()->getLicense(name, version, nb_licenses);
174 }
175
177
178 void releaseLicense(typename FeatureModel::eFeature feature, Integer nb_licenses = 0)
179 {
180 const String name = FeatureModel::getName(feature);
181 return FlexLMMng::instance()->releaseLicense(name, nb_licenses);
182 }
183
185 String featureInfo(typename FeatureModel::eFeature feature) const
186 {
187 const String name = FeatureModel::getName(feature);
188 const Real version = FeatureModel::getVersion(feature);
189 return FlexLMMng::instance()->featureInfo(name, version);
190 }
191};
192
193/*---------------------------------------------------------------------------*/
194/*---------------------------------------------------------------------------*/
195
197{
198 public:
199
200 typedef enum
201 {
202 ArcaneCore = 0, //<! Fonctionnalité noyau (liée à l'exécution)
203 } eFeature;
204
205 static String getName(eFeature feature)
206 {
207 return m_arcane_feature_name[feature];
208 }
209
210 static Real getVersion(eFeature feature)
211 {
212 ARCANE_UNUSED(feature);
213 // Ecrit une version comparable numériquement; ex: 1.0610 (au lieu de 1.6.1)
214 return (Real)ARCANE_VERSION_MAJOR + (Real)ARCANE_VERSION_MINOR / 100 + (Real)ARCANE_VERSION_RELEASE / 1000 + (Real)ARCANE_VERSION_BETA / 10000;
215 }
216
217 private:
218
219 static const String m_arcane_feature_name[];
220};
221
222/*---------------------------------------------------------------------------*/
223/*---------------------------------------------------------------------------*/
224
225/*---------------------------------------------------------------------------*/
226/*---------------------------------------------------------------------------*/
227
228ARCANE_END_NAMESPACE
229
230/*---------------------------------------------------------------------------*/
231/*---------------------------------------------------------------------------*/
232
233#endif /*FLEXLMTOOLS_H_*/
FlexLM manager.
Definition FlexLMTools.h:72
virtual ~FlexLMMng()
Destructeur.
Definition FlexLMTools.h:79
bool m_is_master
Cet host est il le maître des contrôles ?
Wrapper pour accéder aux FlexLMMng pour un jeu de fonctionnalités donné
bool checkLicense(typename FeatureModel::eFeature feature, const bool do_fatal) const
Teste la disponibilité d'une fonctionnalité
void releaseLicense(typename FeatureModel::eFeature feature, Integer nb_licenses=0)
Relache.
bool checkLicense(typename FeatureModel::eFeature feature, const Real version, const bool do_fatal) const
Teste la disponibilité d'une fonctionnalité sur une version maximale.
String featureInfo(typename FeatureModel::eFeature feature) const
Return info on feature.
virtual ~FlexLMTools()
Destructeur.
FlexLMTools()
Constructeur.
void getLicense(typename FeatureModel::eFeature feature, Integer nb_licenses=1)
Demande l'allocation de.
Classe abstraite du superviseur de parallélisme.
Exception de licence.
Definition FlexLMTools.h:42
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe de base d'une exception.
virtual void explain(std::ostream &o) const
Explique la cause de l'exception dans le flot o.
Chaîne de caractères unicode.