Debian Codegraph @

src/FDM/JSBSim/input_output/FGOutputFile.cpp

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGOutputFile.cpp
4 Author: Bertrand Coconnier
5 Date started: 09/10/11
6 Purpose: Manage output of sim parameters to a file
7 Called by: FGOutput
8
9 ------------- Copyright (C) 2011 Bertrand Coconnier -------------
10
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU Lesser General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
14 version.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
19 details.
20
21 You should have received a copy of the GNU Lesser General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
24
25 Further information about the GNU Lesser General Public License can also be found on
26 the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This is the place where you create output routines to dump data for perusal
31 later.
32
33 HISTORY
34 --------------------------------------------------------------------------------
35 09/10/11 BC Created
36
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include <sstream>
42
43 #include "FGOutputFile.h"
44 #include "input_output/FGXMLElement.h"
45
46 using namespace std;
47
48 namespace JSBSim {
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 CLASS IMPLEMENTATION
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 FGOutputFile::FGOutputFile(FGFDMExec* fdmex) :
55 FGOutputType(fdmex),
56 runID_postfix(-1)
57 {
58 }
59
60 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61
62 bool FGOutputFile::InitModel(void)
63 {
64 if (FGOutputType::InitModel()) {
65 if (Filename.isNull()) {
66 Filename = SGPath(Name);
67 runID_postfix = 0;
68 }
69 return OpenFile();
70 }
71
72 return false;
73 }
74
75 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
77 void FGOutputFile::SetStartNewOutput(void)
78 {
79 if (runID_postfix >= 0) {
80 ostringstream buf;
81 string::size_type dot = Name.find_last_of('.');
82 if (dot != string::npos) {
83 buf << Name.substr(0, dot) << '_' << runID_postfix++ << Name.substr(dot);
84 } else {
85 buf << Name << '_' << runID_postfix++;
86 }
87 Filename = SGPath(buf.str());
88 }
89
90 CloseFile();
91 }
92
93 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
95 bool FGOutputFile::Load(Element* el)
96 {
97 if (!FGOutputType::Load(el))
98 return false;
99
100 SetOutputName(el->GetAttributeValue("name"));
101
102 return true;
103 }
104
105 }