Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
NullPhysicalUnitSystemService.cc
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/* NullPhysicalUnitSystemService.h (C) 2000-2022 */
9/* */
10/* Default physical unit system management. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/PlatformUtils.h"
15#include "arcane/utils/NotSupportedException.h"
16#include "arcane/utils/TraceInfo.h"
17#include "arcane/utils/ArrayView.h"
18
19#include "arcane/core/IPhysicalUnitSystemService.h"
20#include "arcane/core/IPhysicalUnitSystem.h"
21#include "arcane/core/IPhysicalUnitConverter.h"
22#include "arcane/core/IPhysicalUnit.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
41: public IPhysicalUnit
42{
43 public:
44
45 friend class NullPhysicalUnitSystem;
46
47 public:
48
49 const String& name() const override
50 {
51 return m_name;
52 }
53
54 private:
55
56 String m_name;
57};
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62class NullPhysicalUnitConverter
64{
65 public:
66
67 NullPhysicalUnitConverter()
68 {
69 }
70
71 public:
72
73 Real convert(Real value) override
74 {
75 ARCANE_UNUSED(value);
76 throw NotSupportedException(A_FUNCINFO);
77 }
78
79 void convert(RealConstArrayView input_values,
80 RealArrayView output_values) override
81 {
82 ARCANE_UNUSED(input_values);
83 ARCANE_UNUSED(output_values);
84 throw NotSupportedException(A_FUNCINFO);
85 }
86
88 {
89 return m_from_unit;
90 }
91
93 {
94 return m_to_unit;
95 }
96
97 public:
98 private:
99
100 NullPhysicalUnit* m_from_unit = nullptr;
101 NullPhysicalUnit* m_to_unit = nullptr;
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107class NullPhysicalUnitSystem
108: public IPhysicalUnitSystem
109{
110 public:
111
112 NullPhysicalUnitSystem() = default;
113
115 {
116 ARCANE_UNUSED(from);
117 ARCANE_UNUSED(to);
119 return cvt;
120 }
121
122 IPhysicalUnitConverter* createConverter(const String& from, const String& to) override
123 {
124 ARCANE_UNUSED(from);
125 ARCANE_UNUSED(to);
127 return cvt;
128 }
129
130 public:
131 private:
132};
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137class NullPhysicalUnitSystemService
139{
140 public:
141
142 NullPhysicalUnitSystemService() = default;
143
144 public:
145
146 void build() override {}
147
148 public:
149
155
156 private:
157};
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162/*---------------------------------------------------------------------------*/
163/*---------------------------------------------------------------------------*/
164
165extern "C++" IPhysicalUnitSystemService*
166createNullPhysicalUnitSystemService()
167{
168 IPhysicalUnitSystemService* s = new NullPhysicalUnitSystemService();
169 s->build();
170 return s;
171}
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176} // End namespace Arcane
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
Interface of a unit converter.
Interface of a service managing a unit system.
Interface of a unit system.
Real convert(Real value) override
Returns the converted value of value.
IPhysicalUnit * fromUnit() override
Starting unit.
IPhysicalUnit * toUnit() override
Target unit.
void convert(RealConstArrayView input_values, RealArrayView output_values) override
Returns the converted values of input_values in output_values.
IPhysicalUnitSystem * createStandardUnitSystem() override
Creates a unit system for the International System SI.
IPhysicalUnitConverter * createConverter(IPhysicalUnit *from, IPhysicalUnit *to) override
Creates a converter between two units. The caller must destroy the returned converter....
IPhysicalUnitConverter * createConverter(const String &from, const String &to) override
Creates a converter between two units. The caller must destroy the returned converter.
const String & name() const override
Unit name.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.
ArrayView< Real > RealArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:459
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488