OOFEM 3.0
Loading...
Searching...
No Matches
dynamicdatareader.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include "dynamicdatareader.h"
36#include "inputrecord.h"
37#include "error.h"
38
39#include <memory>
40#include <fstream>
41
42namespace oofem {
43DynamicDataReader :: DynamicDataReader(std :: string name) : DataReader(), name(std :: move(name))
44{
45 this->it = recordList.end();
46}
47
48DynamicDataReader :: ~DynamicDataReader()
49{
50}
51
52void
53DynamicDataReader :: insertInputRecord(InputRecordType type, std::unique_ptr<InputRecord> record)
54{
55 // Should care about the record type, but its a hassle.
56 this->recordList.push_back(std::move(record));
57 this->it = recordList.end();
58}
59
61DynamicDataReader :: giveInputRecord(InputRecordType typeId, int recordId)
62{
63 // Ignores recordId in favor of having a dynamic list (just incremental access). typeId could be supported, but its a hassle.
64 // The txt data reader makes the same assumptions.
65 if ( this->it == this->recordList.end() ) {
66 this->it = this->recordList.begin();
67 } else {
68 ++this->it;
69 }
70 return **(this->it);
71}
72
73bool
74DynamicDataReader :: peekNext(const std :: string &keyword)
75{
76 std :: string nextKey;
77 auto temp = this->it;
78 temp++;
79 (*temp)->giveRecordKeywordField(nextKey);
80 return keyword.compare( nextKey ) == 0;
81}
82
83void
84DynamicDataReader :: finish()
85{
86 this->recordList.clear();
87}
88
89void
90DynamicDataReader :: writeToFile(const char *fileName)
91{
92 std :: ofstream fout(fileName);
93
94 fout << this->outputFileName << '\n';
95 fout << this->description << '\n';
96 for ( auto &rec: this->recordList ) {
97 fout << rec->giveRecordInTXTFormat() << "\n";
98 }
99 fout.close();
100}
101} // end namespace oofem
std::string outputFileName
Output file name (first line in OOFEM input files).
Definition datareader.h:58
InputRecordType
Determines the type of input record.
Definition datareader.h:64
std::string description
Description line (second line in OOFEM input files).
Definition datareader.h:60
std ::vector< std ::unique_ptr< InputRecord > > recordList
All record types will be appended to this list, no split in terms of InputRecordType is implemented y...
std::vector< std::unique_ptr< InputRecord > >::iterator it
Keeps track of the current position in the list.

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011