Debian Codegraph @

src/FDM/JSBSim/input_output/FGInputType.h

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGInputType.h
4 Author: Paul Chavent
5 Date started: 01/20/15
6
7 ------------- Copyright (C) 2015 Paul Chavent -------------
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 01/20/15 PC Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGINPUTTYPE_H
35 #define FGINPUTTYPE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "models/FGModel.h"
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 FORWARD DECLARATIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 namespace JSBSim {
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 CLASS DOCUMENTATION
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 /** Abstract class to provide functions generic to all the input directives.
54 This class is used by the input manager FGInput to manage a list of
55 different input classes without needing to know the details of each one of
56 them. It also provides the functions that are common to all the input
57 classes.
58
59 The class inherits from FGModelFunctions so it is possible to define
60 functions that execute before or after the input is generated. Such
61 functions need to be tagged with a "pre" or "post" type attribute to denote
62 the sequence in which they should be executed.
63
64 The class mimics some functionalities of FGModel (methods InitModel(),
65 Run() and SetRate()). However it does not inherit from FGModel since it is
66 conceptually different from the model paradigm.
67 */
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 CLASS DECLARATION
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 class FGInputType : public FGModel
74 {
75 public:
76 /** Constructor (implement the FGModel interface).
77 @param fdmex a pointer to the parent executive object
78 */
79 FGInputType(FGFDMExec* fdmex);
80
81 /// Destructor
82 ~FGInputType() override;
83
84 /** Set the idx for this input instance
85 @param idx ID of the input instance that is constructed
86 */
87 void SetIdx(unsigned int idx);
88
89 /** Init the input directives from an XML file (implement the FGModel interface).
90 @param element XML Element that is pointing to the input directives
91 */
92 bool Load(Element* el) override;
93
94 /// Init the input model according to its configitation.
95 bool InitModel(void) override;
96
97 /** Executes the input directives (implement the FGModel interface).
98 This method checks that the current time step matches the input
99 rate and calls the registered "pre" functions, the input
100 generation and finally the "post" functions.
101 @result false if no error.
102 */
103 bool Run(bool Holding) override;
104
105 /** Generate the input. This is a pure method so it must be implemented by
106 the classes that inherits from FGInputType. The Read name may not be
107 relevant to all inputs but it has been kept for backward compatibility.
108 */
109 virtual void Read(bool Holding) = 0;
110
111 /// Enables the input generation.
112 void Enable(void) { enabled = true; }
113 /// Disables the input generation.
114 void Disable(void) { enabled = false; }
115 /** Toggles the input generation.
116 @result the input generation status i.e. true if the input has been
117 enabled, false if the input has been disabled. */
118 bool Toggle(void) {enabled = !enabled; return enabled;}
119
120 /** Overwrites the name identifier under which the input will be read.
121 This method is taken into account if it is called before
122 FGFDMExec::RunIC() otherwise it is ignored until the next call to
123 SetStartNewInput().
124 @param name new name */
125 virtual void SetInputName(const std::string& name) { Name = name; }
126
127 /** Get the name identifier to which the input will be directed.
128 @result the name identifier.*/
129 virtual const std::string& GetInputName(void) const { return Name; }
130
131 protected:
132 unsigned int InputIdx;
133 bool enabled;
134
135 void Debug(int from) override;
136 };
137 }
138 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 #endif