]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/math/FGPropertyValue.cpp
std namespace fix
[flightgear.git] / src / FDM / JSBSim / math / FGPropertyValue.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGPropertyValue.cpp
4 Author: Jon Berndt
5 Date started: 12/10/2004
6 Purpose: Stores property values
7
8  ------------- Copyright (C) 2001  Jon S. Berndt (jon@jsbsim.org) -------------
9  ------ Copyright (C) 2010 - 2011  Anders Gidenstam (anders(at)gidenstam.org) -
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU Lesser General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
19  details.
20
21  You should have received a copy of the GNU Lesser General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU Lesser General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 INCLUDES
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
31
32 #include "FGPropertyValue.h"
33
34 namespace JSBSim {
35
36 static const char *IdSrc = "$Id: FGPropertyValue.cpp,v 1.7 2011/04/05 20:20:21 andgi Exp $";
37 static const char *IdHdr = ID_PROPERTYVALUE;
38
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 CLASS IMPLEMENTATION
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 FGPropertyValue::FGPropertyValue(FGPropertyManager* propNode)
44   : PropertyManager(0L), PropertyNode(propNode)
45 {
46 }
47
48 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
50 FGPropertyValue::FGPropertyValue(std::string propName, FGPropertyManager* propertyManager)
51   : PropertyManager(propertyManager), PropertyNode(0L), PropertyName(propName)
52 {
53 }
54
55 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
57 double FGPropertyValue::GetValue(void) const
58 {
59   FGPropertyManager* node = PropertyNode;
60
61   if (!PropertyNode) {
62     // The node cannot be cached since this is a const method.
63     node = PropertyManager->GetNode(PropertyName);
64     
65     if (!node) {
66       throw(std::string("FGPropertyValue::GetValue() The property " +
67                         PropertyName + " does not exist."));
68     }
69   }
70
71   return node->getDoubleValue();
72 }
73
74 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76 std::string FGPropertyValue::GetName(void) const
77 {
78   if (PropertyNode) {
79     return PropertyNode->GetName();
80   } else {
81     return PropertyName;
82   }
83 }
84
85 }