Debian Codegraph @

src/FDM/JSBSim/input_output/FGOutputFile.h

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGOutputFile.h
4 Author: Bertrand Coconnier
5 Date started: 09/10/11
6
7 ------------- Copyright (C) 2011 Bertrand Coconnier -------------
8
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 09/10/11 BC Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGOUTPUTFILE_H
35 #define FGOUTPUTFILE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGFDMExec.h"
42 #include "FGOutputType.h"
43
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 FORWARD DECLARATIONS
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47
48 namespace JSBSim {
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 CLASS DOCUMENTATION
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 /** Abstract class that provide functions that are generic to all the outputs
55 that are directed to a file. A new class derived from FGOutputFile should
56 be created for each file format that JSBSim is able to output.
57
58 This class provides all the machinery necessary to manage the file naming
59 including the sequence in which the file should be opened then closed. The
60 logic of SetStartNewOutput() is also managed in this class. Derived class
61 should normally not need to reimplement this method. In most cases, derived
62 classes only need to implement the methods OpenFile(), CloseFile() and
63 Print().
64 */
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 CLASS DECLARATION
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 class FGOutputFile : public FGOutputType
71 {
72 public:
73 /// Constructor
74 FGOutputFile(FGFDMExec* fdmex);
75
76 /// Destructor : closes the file.
77 ~FGOutputFile() override { CloseFile(); }
78
79 /** Init the output directives from an XML file.
80 @param element XML Element that is pointing to the output directives
81 */
82 bool Load(Element* el) override;
83
84 /** Initializes the instance. This method basically opens the file to which
85 outputs will be directed.
86 @result true if the execution succeeded.
87 */
88 bool InitModel(void) override;
89 /** Reset the output prior to a restart of the simulation. This method should
90 be called when the simulation is restarted with, for example, new initial
91 conditions. The current file is closed and reopened with a new name. The
92 new name is contructed from the base file name set by the class
93 constructor or SetOutputName() and is appended with an underscore _ and
94 an ID that is incremented at each call to this method.
95 */
96 void SetStartNewOutput(void) override;
97 /** Overwrites the name identifier under which the output will be logged.
98 For this method to take effect, it must be called prior to
99 FGFDMExec::RunIC(). If it is called after, it will not take effect before
100 the next call to SetStartNewOutput().
101 @param name new name */
102 void SetOutputName(const std::string& fname) override {
103 Name = (FDMExec->GetOutputPath()/fname).utf8Str();
104 runID_postfix = -1;
105 Filename = SGPath();
106 }
107 /** Generate the output. This is a pure method so it must be implemented by
108 the classes that inherits from FGOutputFile.
109 */
110 void Print(void) override = 0;
111
112 protected:
113 SGPath Filename;
114
115 /// Opens the file
116 virtual bool OpenFile(void) = 0;
117 /// Closes the file
118 virtual void CloseFile(void) {}
119
120 private:
121 int runID_postfix;
122 };
123 }
124 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 #endif