1
0
Fork 0

Maintenance: namespace

Clean up namespaces.
Don't use broad 'using namespace' context in header files.
Header Guards.
SPDX tags.
This commit is contained in:
scttgs0 2023-05-20 17:22:15 -05:00
parent 3df69b8381
commit bd3b209466
7 changed files with 488 additions and 595 deletions

View file

@ -1,25 +1,9 @@
// JSBsim.cxx -- interface to the JSBsim flight model
//
// Written by Curtis Olson, started February 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id: FlightGear.cxx,v 1.15 2014/01/28 09:42:20 ehofman Exp $
/*
* SPDX-FileName: JSBsim.cxx
* SPDX-FileComment: interface to the JSBsim flight model
* SPDX-FileCopyrightText: Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
@ -376,7 +360,7 @@ FGJSBsim::FGJSBsim( double dt )
fgtrim->DoTrim();
delete fgtrim;
string directive_file = fgGetString("/sim/jsbsim/output-directive-file");
std::string directive_file = fgGetString("/sim/jsbsim/output-directive-file");
if (!directive_file.empty())
fdmex->SetOutputDirectives(directive_file);
}

View file

@ -1,35 +1,15 @@
/*
* SPDX-FileName: FGPropertyManager.h
* SPDX-FileComment: Based on work originally by David Megginson
* SPDX-FileCopyrightText: Copyright (C) 2002 Tony Peden
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPropertyManager.h
Author: Tony Peden
Based on work originally by David Megginson
Date: 2/2002
------------- Copyright (C) 2002 -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPROPERTYMANAGER_H
#define FGPROPERTYMANAGER_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -42,6 +22,7 @@ INCLUDES
#endif
#include <string>
#include "simgear/props/propertyObject.hxx"
#if !PROPS_STANDALONE
#include "simgear/math/SGMath.hxx"
@ -384,9 +365,13 @@ class FGPropertyManager
FGPropertyNode* GetNode(void) const { return root; }
FGPropertyNode* GetNode(const std::string& path, bool create = false)
{ return root->GetNode(path, create); }
{
return root->GetNode(path, create);
}
FGPropertyNode* GetNode(const std::string& relpath, int index, bool create = false)
{ return root->GetNode(relpath, index, create); }
{
return root->GetNode(relpath, index, create);
}
bool HasNode(const std::string& path) const
{
std::string newPath = path;
@ -445,20 +430,21 @@ class FGPropertyManager
* @param name The property name to tie (full path).
* @param pointer A pointer to the variable.
*/
template <typename T> void
template <typename T>
void
Tie(const std::string& name, T* pointer)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
if (!property) {
cerr << "Could not get or create property " << name << endl;
std::cerr << "Could not get or create property " << name << std::endl;
return;
}
if (!property->tie(SGRawValuePointer<T>(pointer), false))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
std::cerr << "Failed to tie property " << name << " to a pointer" << std::endl;
else {
tied_properties.push_back(property);
if (FGJSBBase::debug_lvl & 0x20) cout << name << endl;
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
}
}
@ -476,7 +462,8 @@ class FGPropertyManager
* @param setter The setter function, or 0 if the value is unmodifiable.
*/
template <typename T> void
template <typename T>
void
Tie(const std::string& name, T (*getter)(), void (*setter)(T) = nullptr)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
@ -511,7 +498,8 @@ class FGPropertyManager
* @param getter The getter function, or 0 if the value is unreadable.
* @param setter The setter function, or 0 if the value is unmodifiable.
*/
template <typename T> void
template <typename T>
void
Tie(const std::string& name, int index, T (*getter)(int),
void (*setter)(int, T) = nullptr)
{
@ -549,7 +537,8 @@ class FGPropertyManager
* @param setter The object's setter method, or 0 if the value is
* unmodifiable.
*/
template <class T, class V> void
template <class T, class V>
void
Tie(const std::string& name, T* obj, V (T::*getter)() const,
void (T::*setter)(V) = nullptr)
{
@ -586,7 +575,8 @@ class FGPropertyManager
* @param getter The getter method, or 0 if the value is unreadable.
* @param setter The setter method, or 0 if the value is unmodifiable.
*/
template <class T, class V> void
template <class T, class V>
void
Tie(const std::string& name, T* obj, int index, V (T::*getter)(int) const,
void (T::*setter)(int, V) = nullptr)
{
@ -608,13 +598,15 @@ class FGPropertyManager
}
}
template <class T> simgear::PropertyObject<T>
template <class T>
simgear::PropertyObject<T>
CreatePropertyObject(const std::string& path)
{ return simgear::PropertyObject<T>(root->GetNode(path, true)); }
{
return simgear::PropertyObject<T>(root->GetNode(path, true));
}
private:
std::vector<SGPropertyNode_ptr> tied_properties;
FGPropertyNode_ptr root;
};
}
#endif // FGPROPERTYMANAGER_H
} // namespace JSBSim

View file

@ -1,34 +1,15 @@
/*
* SPDX-FileName: FGParameterValue.h
* SPDX-FileComment: Author: Bertrand Coconnier, Date started: December 09 2018
* SPDX-FileCopyrightText: Copyright (C) 2018 B. Coconnier (bcoconni@users.sf.net)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGParameterValue.h
Author: Bertrand Coconnier
Date started: December 09 2018
--------- Copyright (C) 2018 B. Coconnier (bcoconni@users.sf.net) -----------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPARAMETERVALUE_H
#define FGPARAMETERVALUE_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -36,9 +17,9 @@
#include <stdexcept>
#include "math/FGRealValue.h"
#include "math/FGPropertyValue.h"
#include "input_output/FGXMLElement.h"
#include "math/FGPropertyValue.h"
#include "math/FGRealValue.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -63,43 +44,49 @@ class FGPropertyManager;
class FGParameterValue : public FGParameter
{
public:
FGParameterValue(Element* el, FGPropertyManager* pm) {
string value = el->GetDataLine();
FGParameterValue(Element* el, FGPropertyManager* pm)
{
std::string value = el->GetDataLine();
if (el->GetNumDataLines() != 1 || value.empty()) {
cerr << el->ReadFrom()
std::cerr << el->ReadFrom()
<< "The element <" << el->GetName()
<< "> must either contain a value number or a property name."
<< endl;
throw invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName());
<< std::endl;
throw std::invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName());
}
Construct(value, pm);
}
FGParameterValue(const std::string& value, FGPropertyManager* pm) {
FGParameterValue(const std::string& value, FGPropertyManager* pm)
{
Construct(value, pm);
}
double GetValue(void) const override { return param->GetValue(); }
bool IsConstant(void) const override { return param->IsConstant(); }
std::string GetName(void) const override {
std::string GetName(void) const override
{
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
if (v)
return v->GetNameWithSign();
else
return to_string(param->GetValue());
return std::to_string(param->GetValue());
}
bool IsLateBound(void) const {
bool IsLateBound(void) const
{
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
return v != nullptr && v->IsLateBound();
}
private:
FGParameter_ptr param;
void Construct(const std::string& value, FGPropertyManager* pm) {
void Construct(const std::string& value, FGPropertyManager* pm)
{
if (is_number(value)) {
param = new FGRealValue(atof(value.c_str()));
} else {
@ -112,5 +99,3 @@ private:
typedef SGSharedPtr<FGParameterValue> FGParameterValue_ptr;
} // namespace JSBSim
#endif

View file

@ -1,31 +1,12 @@
/*
* SPDX-FileName: FGPropertyValue.cpp
* SPDX-FileComment: Stores property values
* SPDX-FileCopyrightText: Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org)
* SPDX-FileContributor: Copyright (C) 2010 - 2011 Anders Gidenstam (anders(at)gidenstam.org)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGPropertyValue.cpp
Author: Jon Berndt
Date started: 12/10/2004
Purpose: Stores property values
------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) -------------
------ Copyright (C) 2010 - 2011 Anders Gidenstam (anders(at)gidenstam.org) -
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -101,7 +82,7 @@ std::string FGPropertyValue::GetName(void) const
std::string FGPropertyValue::GetNameWithSign(void) const
{
string name;
std::string name;
if (Sign < 0.0) name ="-";

View file

@ -1,28 +1,10 @@
/*
* SPDX-FileName: FGAerodynamics.h
* SPDX-FileCopyrightText: Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGAerodynamics.h
Author: Jon S. Berndt
Date started: 09/13/00
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
09/13/00 JSB Created
@ -31,20 +13,19 @@ HISTORY
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGAERODYNAMICS_H
#define FGAERODYNAMICS_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <map>
#include <string>
#include <vector>
#include <map>
#include "FGModel.h"
#include "math/FGFunction.h"
#include "math/FGColumnVector3.h"
#include "math/FGFunction.h"
#include "math/FGMatrix33.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -112,7 +93,6 @@ CLASS DECLARATION
class FGAerodynamics : public FGModel
{
public:
/** Constructor
@param Executive a pointer to the parent executive object */
@ -250,7 +230,12 @@ public:
} in;
private:
enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType;
enum eAxisType { atNone,
atWind,
atBodyAxialNormal,
atBodyXYZ,
atStability } forceAxisType,
momentAxisType;
typedef std::map<std::string, int> AxisIndex;
AxisIndex AxisIdx;
FGFunction* AeroRPShift;
@ -278,8 +263,8 @@ private:
typedef double (FGAerodynamics::*PMF)(int) const;
void DetermineAxisSystem(Element* document);
void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
const string& name, const string& frame,
Element* el, const string& validNames);
const std::string& name, const std::string& frame,
Element* el, const std::string& validNames);
void bind(void);
void BuildStabilityTransformMatrices(void);
@ -289,4 +274,3 @@ private:
} // namespace JSBSim
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -1,28 +1,10 @@
/*
* SPDX-FileName: FGTurbine.h
* SPDX-FileCopyrightText: Copyright (C) 2003 David Culp (daveculp@cox.net)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGTurbine.h
Author: David Culp
Date started: 03/11/2003
------------- Copyright (C) 2003 David Culp (daveculp@cox.net)----------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
03/11/2003 DPC Created, based on FGTurbine
@ -33,8 +15,7 @@ HISTORY
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGTURBINE_H
#define FGTURBINE_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -181,7 +162,13 @@ public:
/// Destructor
~FGTurbine();
enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
enum phaseType { tpOff,
tpRun,
tpSpinUp,
tpStart,
tpStall,
tpSeize,
tpTrim };
void Calculate(void);
double CalcFuelNeed(void);
@ -243,7 +230,6 @@ public:
std::string GetEngineValues(const std::string& delimiter);
private:
phaseType phase; ///< Operating mode, or "phase"
double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
@ -329,16 +315,17 @@ class FGSpoolUp : public FGParameter
public:
FGSpoolUp(FGTurbine* _turb, double BPR, double factor)
: turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {}
string GetName(void) const { return string(); };
double GetValue(void) const {
std::string GetName(void) const { return std::string(); };
double GetValue(void) const
{
// adjust acceleration for N2 and atmospheric density
double n = std::min(1.0, turb->N2norm + 0.1);
return delay / (1 + 3 * (1 - n) * (1 - n) * (1 - n) + (1 - turb->in.DensityRatio));
}
private:
FGTurbine* turb;
double delay; ///< Inverse spool-up time from idle to 100% (seconds)
};
}
} // namespace JSBSim
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -1,14 +1,12 @@
/*
* SPDX-FileName: uiuc_recorder.cpp
* SPDX-FileComment: outputs variables specified in input file to recorder file
* SPDX-FileCopyrightText: (C) 2000 by Michael Selig
* SPDX-License-Identifier: GPL-1.0
*/
/**********************************************************************
FILENAME: uiuc_recorder.cpp
----------------------------------------------------------------------
DESCRIPTION: outputs variables specified in input file to recorder
file
----------------------------------------------------------------------
STATUS: alpha version
----------------------------------------------------------------------
@ -68,24 +66,6 @@
----------------------------------------------------------------------
CALLS TO: none
----------------------------------------------------------------------
COPYRIGHT: (C) 2000 by Michael Selig
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#ifdef HAVE_CONFIG_H
@ -103,10 +83,10 @@ using std::endl; // -dw
void uiuc_recorder( double dt )
{
::stack command_list;
string linetoken;
std::string linetoken;
// static int init = 0;
static int recordStep = 0;
string record_variables = "# ";
std::string record_variables = "# ";
// int modulus = recordStep % recordRate;