OMCompiler/SimulationRuntime/cpp/Core/DataExchange/DefaultContainerManager.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 | /** @addtogroup dataexchange | ||
| 30 | |||
| 31 | * | ||
| 32 | * @{ | ||
| 33 | */ | ||
| 34 | #include <Core/Modelica.h> | ||
| 35 | #include <Core/ModelicaDefine.h> | ||
| 36 | |||
| 37 | /** | ||
| 38 | * A container manager that is designed for single threaded write output. It has just one container that can | ||
| 39 | * be filled with values and written directly. | ||
| 40 | */ | ||
| 41 | class DefaultContainerManager : public Writer | ||
| 42 | { | ||
| 43 | private: | ||
| 44 | write_data_t _container; | ||
| 45 | |||
| 46 | protected: | ||
| 47 | /** | ||
| 48 | * Write the given container to the result file. | ||
| 49 | * @param container The container that should be written. | ||
| 50 | */ | ||
| 51 | void writeContainer(const write_data_t& container) | ||
| 52 | { | ||
| 53 | 340419 | write(get<0>(container),get<1>(container)); | |
| 54 | } | ||
| 55 | |||
| 56 | public: | ||
| 57 | 40 | DefaultContainerManager() : | |
| 58 | 40 | _container() | |
| 59 | { | ||
| 60 | } | ||
| 61 | |||
| 62 | virtual ~DefaultContainerManager() | ||
| 63 | 40 | { | |
| 64 | ✗ | } | |
| 65 | /** | ||
| 66 | * Get the internal container. It is always the same. | ||
| 67 | * @return A reference to the internal container that can be filled with values. | ||
| 68 | */ | ||
| 69 | ✗ | virtual write_data_t& getFreeContainer() | |
| 70 | { | ||
| 71 | 340419 | return _container; | |
| 72 | }; | ||
| 73 | /** | ||
| 74 | * Write the given container to the result file. | ||
| 75 | * @param container The container that should be written. | ||
| 76 | */ | ||
| 77 | ✗ | virtual void addContainerToWriteQueue(const write_data_t& container) | |
| 78 | { | ||
| 79 | writeContainer(container); | ||
| 80 | ✗ | }; | |
| 81 | }; | ||
| 82 | /** @} */ // end of dataexchange | ||
| 83 |