JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGParameterValue.h
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGParameterValue.h
4 Author: Bertrand Coconnier
5 Date started: December 09 2018
6
7 --------- Copyright (C) 2018 B. Coconnier (bcoconni@users.sf.net) -----------
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
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later 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
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on the world wide web at http://www.gnu.org.
25
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 SENTRY
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
29
30#ifndef FGPARAMETERVALUE_H
31#define FGPARAMETERVALUE_H
32
33/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 INCLUDES
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36
37#include "math/FGRealValue.h"
38#include "math/FGPropertyValue.h"
39#include "input_output/FGXMLElement.h"
40#include "input_output/string_utilities.h"
41
42/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 FORWARD DECLARATIONS
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46namespace JSBSim {
47
48class FGPropertyManager;
49
50/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 CLASS DOCUMENTATION
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
58/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 DECLARATION: FGParameterValue
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62class JSBSIM_API FGParameterValue : public FGParameter
63{
64public:
65 FGParameterValue(Element* el, std::shared_ptr<FGPropertyManager> pm)
66 : FGParameterValue(el->GetDataLine(), pm, el)
67 {
68 std::string value = el->GetDataLine();
69
70 if (el->GetNumDataLines() != 1 || value.empty()) {
71 XMLLogException err(el);
72 err << "The element <" << el->GetName()
73 << "> must either contain a value number or a property name.\n";
74 throw err;
75 }
76 }
77
78 FGParameterValue(const std::string& value, std::shared_ptr<FGPropertyManager> pm,
79 Element* el) {
80 try {
81 param = new FGRealValue(atof_locale_c(value.c_str()));
82 } catch (InvalidNumber&) {
83 // "value" must be a property if execution passes to here.
84 param = new FGPropertyValue(value, pm, el);
85 }
86 }
87
88 double GetValue(void) const override { return param->GetValue(); }
89 bool IsConstant(void) const override { return param->IsConstant(); }
90
91 std::string GetName(void) const override {
92 FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
93 if (v)
94 return v->GetNameWithSign();
95 else
96 return param->GetName();
97 }
98
99 bool IsLateBound(void) const {
100 FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
101 return v != nullptr && v->IsLateBound();
102 }
103private:
104 FGParameter_ptr param;
105};
106
107typedef SGSharedPtr<FGParameterValue> FGParameterValue_ptr;
108
109} // namespace JSBSim
110
111#endif
const std::string & GetName(void) const
Retrieves the element name.
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
unsigned int GetNumDataLines(void)
Returns the number of lines of data stored.
Represents a either a real value or a property value.
Represents various types of parameters.
Definition FGParameter.h:61
Represents a property value which can use late binding.
Represents a real value.
Definition FGRealValue.h:58
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71