| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGFunctionValue.h |
| 4 | Author: Bertrand Coconnier |
| 5 | Date started: March 10 2018 |
| 6 | |
| 7 | --------- Copyright (C) 2018 B. Coconnier ([email protected]) ----------- |
| 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 FGFUNCTIONVALUE_H |
| 31 | #define FGFUNCTIONVALUE_H |
| 32 | |
| 33 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 34 | INCLUDES |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 36 | |
| 37 | #include "math/FGPropertyValue.h" |
| 38 | |
| 39 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 40 | FORWARD DECLARATIONS |
| 41 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 42 | |
| 43 | namespace JSBSim { |
| 44 | |
| 45 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 46 | CLASS DOCUMENTATION |
| 47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 48 | |
| 49 | /** Represents a property value on which a function is applied |
| 50 | @author Bertrand Coconnier |
| 51 | */ |
| 52 | |
| 53 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 54 | DECLARATION: FGFunctionValue |
| 55 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 56 | |
| 57 | class FGFunctionValue : public FGPropertyValue |
| 58 | { |
| 59 | public: |
| 60 | |
| 61 | FGFunctionValue(FGPropertyNode* propNode, FGTemplateFunc* f) |
| 62 | :FGPropertyValue(propNode), function(f) {} |
| 63 | FGFunctionValue(std::string propName, FGPropertyManager* propertyManager, |
| 64 | FGTemplateFunc* f) |
| 65 | :FGPropertyValue(propName, propertyManager), function(f) {} |
| 66 | |
| 67 | double GetValue(void) const override { return function->GetValue(GetNode()); } |
| 68 | |
| 69 | std::string GetName(void) const override { |
| 70 | return function->GetName() + "(" + FGPropertyValue::GetName() + ")"; |
| 71 | } |
| 72 | std::string GetNameWithSign(void) const override { |
| 73 | return function->GetName() + "(" + FGPropertyValue::GetNameWithSign() + ")"; |
| 74 | } |
| 75 | std::string GetPrintableName(void) const override { |
| 76 | return function->GetName() + "(" + FGPropertyValue::GetPrintableName() + ")"; |
| 77 | } |
| 78 | std::string GetFullyQualifiedName(void) const override { |
| 79 | return function->GetName() + "(" + FGPropertyValue::GetFullyQualifiedName() + ")"; |
| 80 | } |
| 81 | |
| 82 | private: |
| 83 | FGTemplateFunc_ptr function; |
| 84 | }; |
| 85 | |
| 86 | } // namespace JSBSim |
| 87 | |
| 88 | #endif |