1
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4
Author: Bertrand Coconnier
7
------------- Copyright (C) 2011 Bertrand Coconnier -------------
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
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
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.
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.
27
--------------------------------------------------------------------------------
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
#ifndef FGOUTPUTFILE_H
35
#define FGOUTPUTFILE_H
37
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
#include "FGFDMExec.h"
42
#include "FGOutputType.h"
44
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
#define ID_OUTPUTFILE "$Id: FGOutputFile.h,v 1.3 2012/12/15 16:13:57 bcoconni Exp $"
50
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
/** Abstract class that provide functions that are generic to all the outputs
61
that are directed to a file. A new class derived from FGOutputFile should
62
be created for each file format that JSBSim is able to output.
64
This class provides all the machinery necessary to manage the file naming
65
including the sequence in which the file should be opened then closed. The
66
logic of SetStartNewOutput() is also managed in this class. Derived class
67
should normally not need to reimplement this method. In most cases, derived
68
classes only need to implement the methods OpenFile(), CloseFile() and
72
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76
class FGOutputFile : public FGOutputType
80
FGOutputFile(FGFDMExec* fdmex);
82
/// Destructor : closes the file.
83
virtual ~FGOutputFile() { CloseFile(); }
85
/** Init the output directives from an XML file.
86
@param element XML Element that is pointing to the output directives
88
bool Load(Element* el);
90
/** Initializes the instance. This method basically opens the file to which
91
outputs will be directed.
92
@result true if the execution succeeded.
95
/** Reset the output prior to a restart of the simulation. This method should
96
be called when the simulation is restarted with, for example, new initial
97
conditions. The current file is closed and reopened with a new name. The
98
new name is contructed from the base file name set by the class
99
constructor or SetOutputName() and is appended with an underscore _ and
100
an ID that is incremented at each call to this method.
102
void SetStartNewOutput(void);
103
/** Overwrites the name identifier under which the output will be logged.
104
For this method to take effect, it must be called prior to
105
FGFDMExec::RunIC(). If it is called after, it will not take effect before
106
the next call to SetStartNewOutput().
107
@param name new name */
108
void SetOutputName(const std::string& fname) {
109
Name = Filename = FDMExec->GetRootDir() + fname;
112
/** Generate the output. This is a pure method so it must be implemented by
113
the classes that inherits from FGOutputFile.
115
void Print(void) = 0;
118
std::string Filename;
121
virtual bool OpenFile(void) = 0;
123
virtual void CloseFile(void) {}
129
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%