Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ITimeHistoryCurveWriter2.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/* ITimeHistoryCurveWriter2.h (C) 2000-2025 */
9/* */
10/* Interface for a history curve writer (Version 2). */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITIMEHISTORYCURVEWRITER2_H
13#define ARCANE_CORE_ITIMEHISTORYCURVEWRITER2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/utils/ArrayView.h"
19#include "arcane/utils/String.h"
20
21/*
22 * \brief Indicates whether private member access is allowed.
23 * By default (March 2016), access is kept for compatibility reasons,
24 * but it will need to be removed.
25 */
26#define ARCANE_ALLOW_CURVE_WRITER_PRIVATE_ACCESS 1
27#ifdef SWIG
28#undef ARCANE_ALLOW_CURVE_WRITER_PRIVATE_ACCESS
29#endif
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34namespace Arcane
35{
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40/*!
41 * \brief Information for writing a curve.
42 */
43class TimeHistoryCurveInfo
44{
45 public:
46
47 TimeHistoryCurveInfo(const String& aname, Int32ConstArrayView aiterations,
48 RealConstArrayView avalues, Integer sub_size)
49 : m_name(aname)
50 , m_support()
51 , m_has_support(false)
52 , m_iterations(aiterations)
53 , m_values(avalues)
54 , m_sub_size(sub_size)
55 , m_sub_domain(-1)
56 {}
57
58 TimeHistoryCurveInfo(const String& aname, Int32ConstArrayView aiterations,
59 RealConstArrayView avalues, Integer sub_size, Integer sub_domain)
60 : m_name(aname)
61 , m_support()
62 , m_has_support(false)
63 , m_iterations(aiterations)
64 , m_values(avalues)
65 , m_sub_size(sub_size)
66 , m_sub_domain(sub_domain)
67 {}
68
69 TimeHistoryCurveInfo(const String& aname, const String& asupport, Int32ConstArrayView aiterations,
70 RealConstArrayView avalues, Integer sub_size)
71 : m_name(aname)
72 , m_support(asupport)
73 , m_has_support(true)
74 , m_iterations(aiterations)
75 , m_values(avalues)
76 , m_sub_size(sub_size)
77 , m_sub_domain(-1)
78 {}
79
80 TimeHistoryCurveInfo(const String& aname, const String& asupport, Int32ConstArrayView aiterations,
81 RealConstArrayView avalues, Integer sub_size, Integer sub_domain)
82 : m_name(aname)
83 , m_support(asupport)
84 , m_has_support(true)
85 , m_iterations(aiterations)
86 , m_values(avalues)
87 , m_sub_size(sub_size)
88 , m_sub_domain(sub_domain)
89 {}
90
91 public:
92
93 //! Curve name
94 const String& name() const { return m_name; }
95 const String& support() const { return m_support; }
96 bool hasSupport() const { return m_has_support; }
97 //! List of iterations
98 Int32ConstArrayView iterations() const { return m_iterations; }
99 //! List of curve values
100 RealConstArrayView values() const { return m_values; }
101 //! Number of values per time step
102 Integer subSize() const { return m_sub_size; }
103 // TODO not a great name
104 Integer subDomain() const { return m_sub_domain; }
105
106#if ARCANE_ALLOW_CURVE_WRITER_PRIVATE_ACCESS
107 public:
108
109#else
110 private:
111#endif
112 String m_name;
113 String m_support;
114 bool m_has_support = false;
115 Int32ConstArrayView m_iterations;
116 RealConstArrayView m_values;
117 Integer m_sub_size = 0;
118 Integer m_sub_domain = 0;
119};
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124/*!
125 * \brief Information about writing curves.
126 */
127class TimeHistoryCurveWriterInfo
128{
129 public:
130
131 TimeHistoryCurveWriterInfo(const String& apath, RealConstArrayView atimes)
132 : m_path(apath)
133 , m_times(atimes)
134 {}
135
136 public:
137
138 /*!
139 * \brief Path to write the data (unless specifically overridden
140 * by the service via ITimeHistoryCurveWriter2::setOutputPath())
141 */
142 String path() const { return m_path; }
143 //! List of times
144 RealConstArrayView times() const { return m_times; }
145
146#if ARCANE_ALLOW_CURVE_WRITER_PRIVATE_ACCESS
147 public:
148
149#else
150 private:
151#endif
152 String m_path;
153 RealConstArrayView m_times;
154};
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159/*!
160 * \ingroup StandardService
161 * \brief Interface for a curve writer.
162 *
163 * When writing curves, the instance will be called as follows:
164 * \code
165 * ITimeHistoryCurveWriter2* instance = ...;
166 * instance->beginWrite();
167 * for( const TimeHistoryCurveInfo& curveinfo : all_curves )
168 * instance->writeCurve(curveinfo);
169 * instance->endWrite()
170 * \endcode
171 */
172class ARCANE_CORE_EXPORT ITimeHistoryCurveWriter2
173{
174 public:
175
176 //! Release resources
177 virtual ~ITimeHistoryCurveWriter2() = default;
178
179 public:
180
181 virtual void build() = 0;
182
183 /*!
184 * \brief Notify the start of writing.
185 */
186 virtual void beginWrite(const TimeHistoryCurveWriterInfo& infos) = 0;
187
188 /*!
189 * \brief Notify the end of writing.
190 */
191 virtual void endWrite() = 0;
192
193 /*!
194 * \brief Write a curve.
195 *
196 * Curve info is provided by \a infos
197 * Values are in the array \a values. \a times and \a iterations
198 * contain respectively the time and the iteration number for
199 * each value.
200 * \a path contains the directory where the curves will be written
201 */
202 virtual void writeCurve(const TimeHistoryCurveInfo& infos) = 0;
203
204 //! Writer name
205 virtual String name() const = 0;
206
207 /*!
208 * \brief Base directory where curves will be written.
209 *
210 * If null, the directory specified during beginWrite()
211 * will be used.
212 */
213 virtual void setOutputPath(const String& path) = 0;
214
215 //! Base directory where curves will be written.
216 virtual String outputPath() const = 0;
217};
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222} // namespace Arcane
223
224/*---------------------------------------------------------------------------*/
225/*---------------------------------------------------------------------------*/
226
227#endif
Declarations of types used in Arcane.
virtual ~ITimeHistoryCurveWriter2()=default
Release resources.
virtual void setOutputPath(const String &path)=0
Base directory where curves will be written.
virtual String name() const =0
Writer name.
virtual void endWrite()=0
Notify the end of writing.
virtual void beginWrite(const TimeHistoryCurveWriterInfo &infos)=0
Notify the start of writing.
virtual String outputPath() const =0
Base directory where curves will be written.
virtual void writeCurve(const TimeHistoryCurveInfo &infos)=0
Write a curve.
Information for writing a curve.
Int32ConstArrayView iterations() const
List of iterations.
const String & name() const
Curve name.
RealConstArrayView values() const
List of curve values.
Integer subSize() const
Number of values per time step.
Information about writing curves.
String path() const
Path to write the data (unless specifically overridden by the service via ITimeHistoryCurveWriter2::s...
RealConstArrayView times() const
List of times.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488