Antares Simulator
Power System Simulator
matrix-to-buffer.h
1 /*
2 ** Copyright 2007-2025, RTE (https://www.rte-france.com)
3 ** See AUTHORS.txt
4 ** SPDX-License-Identifier: MPL-2.0
5 ** This file is part of Antares-Simulator,
6 ** Adequacy and Performance assessment for interconnected energy networks.
7 **
8 ** Antares_Simulator is free software: you can redistribute it and/or modify
9 ** it under the terms of the Mozilla Public Licence 2.0 as published by
10 ** the Mozilla Foundation, either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** Antares_Simulator is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** Mozilla Public Licence 2.0 for more details.
17 **
18 ** You should have received a copy of the Mozilla Public Licence 2.0
19 ** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20 */
21 
22 #ifndef __ANTARES_LIBS_ARRAY_MATRIX_TO_BUFFER_SENDER_H__
23 #define __ANTARES_LIBS_ARRAY_MATRIX_TO_BUFFER_SENDER_H__
24 
25 #include <yuni/core/string.h>
26 
27 namespace Antares
28 {
29 template<class T, class ReadWriteT>
30 class Matrix;
31 }
32 
33 namespace Antares
34 {
35 // Forward declarations
36 const char* get_format(bool isDecimal, uint precision);
37 template<class T, class ReadWriteT, class PredicateT>
38 class I_mtx_to_buffer_dumper;
39 
41 {
42 public:
44  {
45  }
46 
48  {
49  }
50 
51  template<class T, class ReadWriteT, class PredicateT>
52  std::unique_ptr<I_mtx_to_buffer_dumper<T, ReadWriteT, PredicateT>>
53  get_dumper(const Matrix<T, ReadWriteT>* mtx, std::string& data, PredicateT& predicate);
54 };
55 
56 template<class T, class ReadWriteT, class PredicateT>
58 {
59 public:
61  std::string& data,
62  PredicateT& predicate):
63  mtx_(mtx),
64  buffer_(data),
65  predicate_(predicate)
66  {
67  }
68 
69  virtual ~I_mtx_to_buffer_dumper() = default;
70 
71  void set_print_format(bool isDecimal, uint precision);
72  virtual void run() = 0;
73 
74 protected:
75  const Matrix<T, ReadWriteT>* mtx_;
76  std::string& buffer_;
77  PredicateT& predicate_;
78  std::string format_;
79 };
80 
81 template<class T, class ReadWriteT, class PredicateT>
82 class one_column__dumper: public I_mtx_to_buffer_dumper<T, ReadWriteT, PredicateT>
83 {
84 public:
85  one_column__dumper(const Matrix<T, ReadWriteT>* mtx, std::string& data, PredicateT& predicate):
87  {
88  }
89 
90  void run() override;
91 };
92 
93 template<class T, class ReadWriteT, class PredicateT>
94 class multiple_columns__dumper: public I_mtx_to_buffer_dumper<T, ReadWriteT, PredicateT>
95 {
96 public:
98  std::string& data,
99  PredicateT& predicate):
101  {
102  }
103 
104  void run() override;
105 };
106 
107 } // namespace Antares
108 
109 #include "matrix-to-buffer.hxx"
110 
111 #endif // __ANTARES_LIBS_ARRAY_MATRIX_TO_BUFFER_SENDER_H__
Definition: matrix-to-buffer.h:58
Definition: matrix-to-buffer.h:41
Definition: matrix-to-buffer.h:95
Definition: matrix-to-buffer.h:83