Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 26.8% 49 / 0 / 183
Functions: 23.7% 18 / 0 / 76
Branches: 6.8% 10 / 0 / 148

OMCompiler/SimulationRuntime/cpp/Core/DataExchange/HistoryImpl.h
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 #pragma once
29 /** @defgroup core Core
30 * Core module of cpp runtime
31 *
32 * @{
33 */
34 template< class ResultsPolicy >
35 class HistoryImpl : public IHistory,
36 public ResultsPolicy
37 {
38 public:
39 40 HistoryImpl(IGlobalSettings& globalSettings,size_t dim)
40
6/18
HistoryImpl<BufferReaderWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
HistoryImpl<DefaultWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
HistoryImpl<MatFileWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
✓ Branch 7 taken 38 times.
HistoryImpl<TextFileWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
40 : ResultsPolicy((globalSettings.getEndTime()-globalSettings.getStartTime())/globalSettings.gethOutput(), globalSettings.getResultsFileName())
41 40 , _globalSettings(globalSettings)
42
2/4
HistoryImpl<BufferReaderWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✗ Branch 2 not taken.
✗ Branch 3 not taken.
HistoryImpl<MatFileWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✓ Branch 2 taken 38 times.
HistoryImpl<TextFileWriter>::HistoryImpl(IGlobalSettings&, unsigned long):
✓ Branch 2 taken 2 times.
80 , _dim(dim)
43 {
44 40 }
45
46 40 virtual ~HistoryImpl()
47 {
48
49 40 }
50
51 /*
52 void setOutputs(map<unsigned int,string> var_outputs)
53 {
54 _var_outputs=var_outputs;
55 }
56 */
57
58 40 virtual void init()
59 {
60
2/2
HistoryImpl<MatFileWriter>::init():
✓ Branch 2 taken 38 times.
HistoryImpl<TextFileWriter>::init():
✓ Branch 2 taken 2 times.
40 ResultsPolicy::init(_globalSettings.getResultsFileName(), _dim);
61 40 }
62
63 ✗ virtual void getOutputNames(vector<string>& output_names)
64 {
65 //boost::copy(_var_outputs | boost::adaptors::map_values, std::back_inserter(output_names));
66 ✗ output_names = ResultsPolicy::_var_outputs;
67 ✗ }
68
69 ✗ void getSimResults(const double time, ublas::vector<double>& v, ublas::vector<double>& dv)
70 {
71 ResultsPolicy::read(time,v,dv);
72 ✗ }
73
74 ✗ void getSimResults(ublas::matrix<double>& R, ublas::matrix<double>& dR)
75 {
76 ResultsPolicy::read(R,dR);
77 ✗ }
78
79 ✗ void getSimResults(ublas::matrix<double>& R, ublas::matrix<double>& dR, ublas::matrix<double>& Re)
80 {
81 ✗ ResultsPolicy::read(R, dR, Re);
82 ✗ }
83
84 ✗ virtual void getOutputResults(ublas::matrix<double>& Ro)
85 {
86 //vector<unsigned int> ids;
87 //boost::copy(_var_outputs | boost::adaptors::map_keys, std::back_inserter(ids));
88 ✗ ResultsPolicy::read(Ro);
89 ✗ }
90
91 ✗ unsigned long getSize()
92 {
93 ✗ return ResultsPolicy::size();
94 }
95
96 ✗ int getDimRe()
97 {
98 ✗ throw ModelicaSimulationError(DATASTORAGE,"getDimRe not implemented yet");
99 }
100
101 ✗ unsigned long getDimdR()
102 {
103 ✗ throw ModelicaSimulationError(DATASTORAGE,"getDimdR not implemented yet");
104 }
105
106 ✗ unsigned long getDimR()
107 {
108 ✗ throw ModelicaSimulationError(DATASTORAGE,"getDimR not implemented yet");
109 }
110
111 ✗ vector<double> getTimeEntries()
112 {
113 vector<double> time;
114 ✗ ResultsPolicy::getTime(time);
115 ✗ return time;
116 }
117
118 40 virtual void clear()
119 {
120 ✗ ResultsPolicy::eraseAll();
121 40 };
122 40 virtual void write(const all_vars_t& v_list, double start_time, double end_time)
123 {
124 38 ResultsPolicy::write(v_list,start_time,end_time);
125 40 };
126 40 virtual void write(const all_names_t& s_list,const all_description_t& s_desc_list, const all_names_t& s_parameter_list,const all_description_t&
127 s_desc_parameter_list)
128 {
129 40 ResultsPolicy::write(s_list,s_desc_list,s_parameter_list,s_desc_parameter_list);
130 40 };
131 340419 virtual void write(const all_vars_time_t& v_list,const neg_all_vars_t& neg_v_list)
132 {
133 340419 ResultsPolicy:: write(v_list,neg_v_list);
134 340419 };
135 340419 virtual write_data_t& getFreeContainer()
136 {
137 340419 return ResultsPolicy::getFreeContainer();
138 }
139
140 340419 virtual void addContainerToWriteQueue(const write_data_t& container)
141 {
142 ResultsPolicy::addContainerToWriteQueue(container);
143 340419 }
144
145
146
147 private:
148 //map of indices of all output variables
149 //map<unsigned int,string> _var_outputs;
150
151 IGlobalSettings& _globalSettings;
152 size_t _dim;
153 };
154 /** @} */ // end of core
155