JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGOutputFile.h
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 
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 CLASS DECLARATION
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 
70 class FGOutputFile : public FGOutputType
71 {
72 public:
74  FGOutputFile(FGFDMExec* fdmex);
75 
77  ~FGOutputFile() override { CloseFile(); }
78 
82  bool Load(Element* el) override;
83 
88  bool InitModel(void) override;
96  void SetStartNewOutput(void) override;
102  void SetOutputName(const std::string& fname) override {
103  Name = (FDMExec->GetOutputPath()/fname).utf8Str();
104  runID_postfix = -1;
105  Filename = SGPath();
106  }
110  void Print(void) override = 0;
111 
112 protected:
113  SGPath Filename;
114 
116  virtual bool OpenFile(void) = 0;
118  virtual void CloseFile(void) {}
119 
120 private:
121  int runID_postfix;
122 };
123 }
124 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 #endif
JSBSim::FGOutputFile::CloseFile
virtual void CloseFile(void)
Closes the file.
Definition: FGOutputFile.h:118
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGOutputType
Abstract class to provide functions generic to all the output directives.
Definition: FGOutputType.h:90
JSBSim::FGOutputFile::FGOutputFile
FGOutputFile(FGFDMExec *fdmex)
Constructor.
Definition: FGOutputFile.cpp:54
JSBSim::FGOutputFile::InitModel
bool InitModel(void) override
Initializes the instance.
Definition: FGOutputFile.cpp:62
JSBSim::FGOutputFile::OpenFile
virtual bool OpenFile(void)=0
Opens the file.
JSBSim::FGOutputFile::SetOutputName
void SetOutputName(const std::string &fname) override
Overwrites the name identifier under which the output will be logged.
Definition: FGOutputFile.h:102
JSBSim::FGOutputFile::~FGOutputFile
~FGOutputFile() override
Destructor : closes the file.
Definition: FGOutputFile.h:77
JSBSim::FGFDMExec::GetOutputPath
const SGPath & GetOutputPath(void)
Retrieves the path to the output files.
Definition: FGFDMExec.h:401
JSBSim::FGOutputFile::Print
void Print(void) override=0
Generate the output.
JSBSim::FGOutputFile
Abstract class that provide functions that are generic to all the outputs that are directed to a file...
Definition: FGOutputFile.h:70
JSBSim::FGOutputFile::Load
bool Load(Element *el) override
Init the output directives from an XML file.
Definition: FGOutputFile.cpp:95
JSBSim::FGOutputFile::SetStartNewOutput
void SetStartNewOutput(void) override
Reset the output prior to a restart of the simulation.
Definition: FGOutputFile.cpp:77
JSBSim::Element
Definition: FGXMLElement.h:143