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:28:50 -05:00
parent 584c40ef47
commit e754b850f1
9 changed files with 250 additions and 346 deletions

View file

@ -1,20 +1,8 @@
/*
* Copyright (C) 2021 James Turner
*
* This file is part of the program FlightGear.
*
* 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, 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* SPDX-FileName: ErrorReporter.cxx
* SPDX-FileComment: This file is part of the program FlightGear
* SPDX-FileCopyrightText: Copyright (C) 2021 James Turner
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
@ -133,7 +121,7 @@ public:
bool doProcessEntry(const simgear::LogEntry& e) override
{
ostringstream os;
std::ostringstream os;
if (e.file != nullptr) {
os << e.file << ":" << e.line << ":\t";
}
@ -330,7 +318,7 @@ public:
// remove any existing error children
_displayNode->removeChildren("error");
ostringstream detailsTextStream;
std::ostringstream detailsTextStream;
// add all the discrete errors as child nodes with all their information
for (const auto& e : report.errors) {
@ -521,46 +509,46 @@ void ErrorReporter::ErrorReporterPrivate::writeReportToStream(const AggregateRep
char buf[64];
time_t now = time(nullptr);
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
os << buf << endl;
os << buf << std::endl;
}
os << "Category:" << static_categoryIds.at(static_cast<int>(report.type)) << endl;
os << "Category:" << static_categoryIds.at(static_cast<int>(report.type)) << std::endl;
if (!report.parameter.empty()) {
os << "\tParameter:" << report.parameter << endl;
os << "\tParameter:" << report.parameter << std::endl;
}
os << endl; // insert a blank line after header data
os << std::endl; // insert a blank line after header data
int index = 1;
char whenBuf[64];
for (const auto& err : report.errors) {
os << "Error " << index++ << std::endl;
os << "\tcode:" << static_errorIds.at(static_cast<int>(err.code)) << endl;
os << "\ttype:" << static_errorTypeIds.at(static_cast<int>(err.type)) << endl;
os << "\tcode:" << static_errorIds.at(static_cast<int>(err.code)) << std::endl;
os << "\ttype:" << static_errorTypeIds.at(static_cast<int>(err.type)) << std::endl;
strftime(whenBuf, sizeof(whenBuf), "%H:%M:%S GMT", gmtime(&err.when));
os << "\twhen:" << whenBuf << endl;
os << "\twhen:" << whenBuf << std::endl;
os << "\t" << err.detailedInfo << std::endl;
os << "\tlocation:" << err.origin.asString() << endl;
os << "\tlocation:" << err.origin.asString() << std::endl;
writeContextToStream(err, os);
writeLogToStream(err, os);
os << std::endl; // trailing blank line
}
os << "Command line / launcher / fgfsrc options" << endl;
os << "Command line / launcher / fgfsrc options" << std::endl;
for (auto o : Options::sharedInstance()->extractOptions()) {
os << "\t" << o << "\n";
}
os << endl;
os << std::endl;
writeSignificantPropertiesToStream(os);
}
void ErrorReporter::ErrorReporterPrivate::writeSignificantPropertiesToStream(std::ostream& os) const
{
os << "Properties:" << endl;
os << "Properties:" << std::endl;
for (const auto& ps : _significantProperties) {
auto node = fgGetNode(ps);
if (!node) {
@ -569,7 +557,7 @@ void ErrorReporter::ErrorReporterPrivate::writeSignificantPropertiesToStream(std
os << "\t" << ps << ": " << node->getStringValue() << "\n";
}
}
os << endl;
os << std::endl;
}

View file

@ -1,25 +1,9 @@
// fg_init.cxx -- Flight Gear top level initialization routines
//
// Written by Curtis Olson, started August 1997.
//
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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; 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
// 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.
//
// $Id$
/*
* SPDX-FileName: fg_init.cxx
* SPDX-FileComment: FlightGear top level initialization routines
* SPDX-FileCopyrightText: Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
@ -362,7 +346,7 @@ private:
return false; // cache mismatch
}
vector<SGPropertyNode_ptr> cache = _cache->getChildren("aircraft");
std::vector<SGPropertyNode_ptr> cache = _cache->getChildren("aircraft");
for (unsigned int i = 0; i < cache.size(); i++) {
const std::string name = cache[i]->getStringValue("file", "");
if (!simgear::strutils::iequals(_searchAircraft, name)) {

View file

@ -1,36 +1,19 @@
// fg_io.hxx -- Higher level I/O management routines
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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; 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
// 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.
//
// $Id$
/*
* SPDX-FileName: fg_io.hxx
* SPDX-FileComment: Higher level I/O management routines
* SPDX-FileCopyrightText: Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#ifndef _FG_IO_HXX
#define _FG_IO_HXX
#include <string>
#include <vector>
#include <simgear/compiler.h>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <vector>
#include <string>
class FGProtocol;
@ -60,25 +43,23 @@ public:
private:
FGProtocol* add_channel(const std::string& config, bool& o_ok);
FGProtocol* parse_port_config( const std::string& cfgstr, bool& o_ok );
FGProtocol* parse_port_config( const string_list& tokens, bool& o_ok );
void addToPropertyTree(const string name, const string config);
void removeFromPropertyTree(const string name);
string generateName(const string protocol);
FGProtocol* parse_port_config(const std::string& cfgstr, bool& o_ok);
FGProtocol* parse_port_config(const string_list& tokens, bool& o_ok);
void addToPropertyTree(const std::string name, const std::string config);
void removeFromPropertyTree(const std::string name);
std::string generateName(const std::string protocol);
private:
// define the global I/O channel list
//io_container global_io_list;
typedef std::vector< FGProtocol* > ProtocolVec;
typedef std::vector<FGProtocol*> ProtocolVec;
ProtocolVec io_channels;
SGPropertyNode_ptr _realDeltaTime;
bool commandAddChannel(const SGPropertyNode * arg, SGPropertyNode * root);
bool commandRemoveChannel(const SGPropertyNode * arg, SGPropertyNode * root);
};
#endif // _FG_IO_HXX
bool commandAddChannel(const SGPropertyNode* arg, SGPropertyNode* root);
bool commandRemoveChannel(const SGPropertyNode* arg, SGPropertyNode* root);
};

View file

@ -1,4 +1,7 @@
// fg_scene_commands.cxx - internal FGFS commands.
/*
* SPDX-FileName: fg_scene_commands.cxx
* SPDX-FileComment: internal FGFS commands
*/
#include "config.h"
@ -122,7 +125,7 @@ do_reposition (const SGPropertyNode * arg, SGPropertyNode * root)
static bool
do_panel_load (const SGPropertyNode * arg, SGPropertyNode * root)
{
string panel_path = arg->getStringValue("path");
std::string panel_path = arg->getStringValue("path");
if (!panel_path.empty()) {
// write to the standard property, which will force a load
fgSetString("/sim/panel/path", panel_path.c_str());
@ -366,7 +369,7 @@ do_dialog_update (const SGPropertyNode * arg, SGPropertyNode * root)
static bool
do_open_browser (const SGPropertyNode * arg, SGPropertyNode * root)
{
string path;
std::string path;
if (arg->hasValue("path"))
path = arg->getStringValue("path");
else
@ -472,12 +475,12 @@ do_presets_commit (const SGPropertyNode * arg, SGPropertyNode * root)
static bool
do_press_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root)
{
const string prefix = arg->getStringValue("prefix");
const std::string prefix = arg->getStringValue("prefix");
if (arg->getBoolValue("guarded") && fgGetDouble((prefix + "-guard").c_str()) < 1)
return true;
string prop = prefix + "-button";
std::string prop = prefix + "-button";
double value;
if (arg->getBoolValue("latching"))
@ -494,10 +497,10 @@ do_press_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root)
static bool
do_release_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root)
{
const string prefix = arg->getStringValue("prefix");
const std::string prefix = arg->getStringValue("prefix");
if (arg->getBoolValue("guarded")) {
string prop = prefix + "-guard";
std::string prop = prefix + "-guard";
if (fgGetDouble(prop.c_str()) < 1) {
fgSetDouble(prop.c_str(), 1);
return true;

View file

@ -1,24 +1,9 @@
// main.cxx -- top level sim routines
//
// Written by Curtis Olson, started May 1997.
//
// Copyright (C) 1997 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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; 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
// 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.
//
// $Id$
/*
* SPDX-FileName: main.cxx
* SPDX-FileComment: top level sim routines
* SPDX-FileCopyrightText: Copyright (C) 1997 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
@ -395,7 +380,7 @@ static void fgIdleFunction ( void ) {
} catch (std::exception& e) {
// attempt to trace location of illegal argument / invalid string
// position errors on startup
flightgear::sentryReportException(string{"Creating subsystems: caught:"} + e.what());
flightgear::sentryReportException(std::string{"Creating subsystems: caught:"} + e.what());
throw;
}

View file

@ -1,7 +1,9 @@
// modelmgr.cxx - manage a collection of 3D models.
// Written by David Megginson, started 2002.
//
// This file is in the Public Domain, and comes with no warranty.
/*
* SPDX-FileName: modelmgr.cxx
* SPDX-FileComment: manage a collection of 3D models
* SPDX-FileCopyrightText: Written by David Megginson, started 2002.
* SPDX-License-Identifier: This file is in the Public Domain, and comes with no warranty.
*/
#ifdef _MSC_VER
# pragma warning( disable: 4355 )
@ -284,7 +286,7 @@ void FGModelMgr::update(double dt)
if (instance->heading_deg_node != 0)
heading = testNan(instance->heading_deg_node->getDoubleValue());
} catch (const sg_range_exception&) {
string path = instance->node->getStringValue("path", "unknown");
std::string path = instance->node->getStringValue("path", "unknown");
SG_LOG(SG_AIRCRAFT, SG_INFO, "Instance of model " << path
<< " has invalid values");
return;

View file

@ -1,22 +1,8 @@
/*
MPServerResolver.cxx - mpserver names lookup via DNS
Written and copyright by Torsten Dreyer - November 2016
This file is part of FlightGear.
FlightGear 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, either version 2 of the License, or
(at your option) any later version.
FlightGear 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 FlightGear. If not, see <http://www.gnu.org/licenses/>.
* SPDX-FileName: MPServerResolver.cxx
* SPDX-FileComment: mpserver names lookup via DNS. This file is part of FlightGear.
* SPDX-FileCopyrightText: Written and copyright by Torsten Dreyer - November 2016
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <algorithm>
@ -33,13 +19,13 @@ using namespace simgear;
/**
* Build a name=value map from base64 encoded JSON string
*/
class MPServerProperties : public std::map<string, string> {
class MPServerProperties : public std::map<std::string, std::string> {
public:
MPServerProperties (string b64)
MPServerProperties (std::string b64)
{
std::vector<unsigned char> b64dec;
simgear::strutils::decodeBase64 (b64, b64dec);
auto jsonString = string ((char*) b64dec.data (), b64dec.size ());
auto jsonString = std::string ((char*) b64dec.data (), b64dec.size ());
cJSON * json = ::cJSON_Parse (jsonString.c_str ());
if (json) {
for (int i = 0; i < ::cJSON_GetArraySize (json); i++) {

View file

@ -1,33 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// multiplaymgr.hxx
//
// Written by Duncan McCreanor, started February 2003.
// duncan.mccreanor@airservicesaustralia.com
//
// Copyright (C) 2003 Airservices Australia
// Copyright (C) 2005 Oliver Schroeder
//
// 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; 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
// 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.
//
// $Id$
//
//////////////////////////////////////////////////////////////////////
/*
* SPDX-FileName: multiplaymgr.hxx
* SPDX-FileCopyrightText: Written by Duncan McCreanor, started February 2003 - duncan.mccreanor@airservicesaustralia.com
* SPDX-FileContributor: Copyright (C) 2003 Airservices Australia, Copyright (C) 2005 Oliver Schroeder
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef MULTIPLAYMGR_H
#define MULTIPLAYMGR_H
#pragma once
#define MULTIPLAYTXMGR_HID "$Id$"
@ -35,22 +13,23 @@ const int MIN_MP_PROTOCOL_VERSION = 1;
const int MAX_MP_PROTOCOL_VERSION = 2;
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include <memory>
#include <simgear/compiler.h>
#include <simgear/props/props.hxx>
#include <simgear/io/raw_socket.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
class IRCConnection;
class CPDLCManager;
const std::string MPIRC_SERVER_HOST_DEFAULT {"mpirc.flightgear.org"};
const std::string MPIRC_SERVER_HOST_PROPERTY {"/network/mpirc/server-host"};
const std::string MPIRC_SERVER_PORT_PROPERTY {"/network/mpirc/server-port"};
const std::string MPIRC_NICK_PREFIX {"MP_IRC_"};
const std::string MPIRC_SERVER_HOST_DEFAULT{"mpirc.flightgear.org"};
const std::string MPIRC_SERVER_HOST_PROPERTY{"/network/mpirc/server-host"};
const std::string MPIRC_SERVER_PORT_PROPERTY{"/network/mpirc/server-port"};
const std::string MPIRC_NICK_PREFIX{"MP_IRC_"};
struct FGExternalMotionData;
class MPPropertyListener;
@ -75,18 +54,18 @@ public:
// transmitter
void SendTextMessage(const std::string &sMsgText);
void SendTextMessage(const std::string& sMsgText);
// receiver
FGAIMultiplayer* getMultiplayer(const std::string& callsign);
std::shared_ptr<vector<char>> popMessageHistory();
void pushMessageHistory(std::shared_ptr<vector<char>> message);
std::shared_ptr<std::vector<char>> popMessageHistory();
void pushMessageHistory(std::shared_ptr<std::vector<char>> message);
// Remove motion information for all multiplayer aircraft, e.g. when
// scrubbing during replay.
void ClearMotion();
CPDLCManager *getCPDLC() { return _cpdlc.get(); };
CPDLCManager* getCPDLC() { return _cpdlc.get(); };
private:
std::unique_ptr<IRCConnection> _mpirc;
@ -95,7 +74,7 @@ private:
void setPropertiesChanged()
{
mPropertiesChanged = true;
mPropertiesChanged = true;
}
int getProtocolToUse()
{
@ -116,7 +95,7 @@ private:
FGAIMultiplayer* addMultiplayer(const std::string& callsign,
const std::string& modelName,
const int fallback_model_index);
void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
void FillMsgHdr(T_MsgHdr* MsgHdr, int iMsgId, unsigned _len = 0u);
void ProcessPosMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress,
long stamp);
void ProcessChatMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress);
@ -125,7 +104,7 @@ private:
int GetMsg(MsgBuf& msgBuf, simgear::IPAddress& SenderAddress);
/// maps from the callsign string to the FGAIMultiplayer
typedef std::map<std::string, SGSharedPtr<FGAIMultiplayer> > MultiPlayerMap;
typedef std::map<std::string, SGSharedPtr<FGAIMultiplayer>> MultiPlayerMap;
MultiPlayerMap mMultiPlayerMap;
std::unique_ptr<simgear::Socket> mSocket;
@ -136,16 +115,16 @@ private:
// Map between the property id's from the multiplayers network packets
// and the property nodes
typedef std::map<unsigned int, SGSharedPtr<SGPropertyNode> > PropertyMap;
typedef std::map<unsigned int, SGSharedPtr<SGPropertyNode>> PropertyMap;
PropertyMap mPropertyMap;
SGPropertyNode *pProtocolVersion;
SGPropertyNode *pXmitLen;
SGPropertyNode *pMultiPlayDebugLevel;
SGPropertyNode *pMultiPlayRange;
SGPropertyNode *pMultiPlayTransmitPropertyBase;
SGPropertyNode *pReplayState;
SGPropertyNode *pLogRawSpeedMultiplayer;
SGPropertyNode* pProtocolVersion;
SGPropertyNode* pXmitLen;
SGPropertyNode* pMultiPlayDebugLevel;
SGPropertyNode* pMultiPlayRange;
SGPropertyNode* pMultiPlayTransmitPropertyBase;
SGPropertyNode* pReplayState;
SGPropertyNode* pLogRawSpeedMultiplayer;
typedef std::map<unsigned int, const struct IdPropertyList*> PropertyDefinitionMap;
PropertyDefinitionMap mPropertyDefinition;
@ -156,8 +135,6 @@ private:
double mDt; // reciprocal of /sim/multiplay/tx-rate-hz
double mNextTransmitTime = 0.0;
std::deque<std::shared_ptr<std::vector<char>>> mRecordMessageQueue;
std::deque<std::shared_ptr<std::vector<char>>> mReplayMessageQueue;
std::deque<std::shared_ptr<std::vector<char>>> mRecordMessageQueue;
std::deque<std::shared_ptr<std::vector<char>>> mReplayMessageQueue;
};
#endif

View file

@ -1,26 +1,25 @@
/*
* SPDX-FileCopyrightText: (C) 2012 James Turner <james@flightgear.org>
* SPDX_FileComment: Defins a unified binary cache for navigation data, parsed from text/XMl sources
* SPDX_FileComment: Defines a unified binary cache for navigation data, parsed from text/XMl sources
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef FG_NAVDATACACHE_HXX
#define FG_NAVDATACACHE_HXX
#pragma once
#include <memory>
#include <cstddef> // for std::size_t
#include <cstddef> // for std::size_t
#include <functional>
#include <memory>
#include <simgear/misc/strutils.hxx> // for string_list
#include <Navaids/positioned.hxx>
#include <Main/globals.hxx> // for PathList
#include <Navaids/positioned.hxx>
#include <simgear/misc/strutils.hxx> // for string_list
class SGPath;
class FGRunway;
namespace flightgear
{
namespace flightgear {
/// a pair of airport ID, runway ID
typedef std::pair<PositionedID, PositionedID> AirportRunwayPair;
@ -33,22 +32,22 @@ typedef std::pair<int, PositionedID> AirwayEdge;
typedef std::vector<AirwayEdge> AirwayEdgeVec;
namespace Octree {
class Node;
class Branch;
}
class Node;
class Branch;
} // namespace Octree
class Airway;
using AirwayRef = SGSharedPtr<Airway>;
class Airway;
using AirwayRef = SGSharedPtr<Airway>;
class NavDataCache
{
public:
~NavDataCache();
// singleton accessor
// singleton accessor
static NavDataCache* instance();
// static creator
// static creator
static NavDataCache* createInstance();
static void shutdown();
@ -56,21 +55,21 @@ public:
SGPath path() const;
enum DatFileType {
DATFILETYPE_APT = 0,
DATFILETYPE_METAR,
DATFILETYPE_AWY,
DATFILETYPE_NAV,
DATFILETYPE_FIX,
DATFILETYPE_POI,
DATFILETYPE_CARRIER,
DATFILETYPE_TACAN_FREQ,
DATFILETYPE_LAST
DATFILETYPE_APT = 0,
DATFILETYPE_METAR,
DATFILETYPE_AWY,
DATFILETYPE_NAV,
DATFILETYPE_FIX,
DATFILETYPE_POI,
DATFILETYPE_CARRIER,
DATFILETYPE_TACAN_FREQ,
DATFILETYPE_LAST
};
struct DatFilesGroupInfo {
DatFileType datFileType; // for instance, DATFILETYPE_APT
PathList paths; // SGPath instances
std::size_t totalSize; // total size of all these files, in bytes
DatFileType datFileType; // for instance, DATFILETYPE_APT
PathList paths; // SGPath instances
std::size_t totalSize; // total size of all these files, in bytes
};
// datTypeStr[DATFILETYPE_APT] = std::string("apt"), etc. This gives,
@ -88,7 +87,7 @@ public:
// Returns datFilesInfo for the given type.
const DatFilesGroupInfo& getDatFilesInfo(DatFileType datFileType) const;
/**
/**
* predicate - check if the cache needs to be rebuilt.
* This can happen is the cache file is missing or damaged, or one of the
** global input files is changed.
@ -97,8 +96,7 @@ public:
static bool isAnotherProcessRebuilding();
enum RebuildPhase
{
enum RebuildPhase {
REBUILD_UNKNOWN = 0,
REBUILD_READING_APT_DAT_FILES,
REBUILD_LOADING_AIRPORTS,
@ -108,194 +106,194 @@ public:
REBUILD_DONE
};
/**
/**
* run the cache rebuild - returns the current phase or 'done'
*/
RebuildPhase rebuild();
RebuildPhase rebuild();
unsigned int rebuildPhaseCompletionPercentage() const;
void setRebuildPhaseProgress(RebuildPhase ph, unsigned int percent = 0);
unsigned int rebuildPhaseCompletionPercentage() const;
void setRebuildPhaseProgress(RebuildPhase ph, unsigned int percent = 0);
bool isCachedFileModified(const SGPath& path) const;
void stampCacheFile(const SGPath& path, const std::string& sha = {});
bool isCachedFileModified(const SGPath& path) const;
void stampCacheFile(const SGPath& path, const std::string& sha = {});
int readIntProperty(const std::string& key);
double readDoubleProperty(const std::string& key);
std::string readStringProperty(const std::string& key);
int readIntProperty(const std::string& key);
double readDoubleProperty(const std::string& key);
std::string readStringProperty(const std::string& key);
void writeIntProperty(const std::string& key, int value);
void writeStringProperty(const std::string& key, const std::string& value);
void writeDoubleProperty(const std::string& key, const double& value);
void writeIntProperty(const std::string& key, int value);
void writeStringProperty(const std::string& key, const std::string& value);
void writeDoubleProperty(const std::string& key, const double& value);
// Warning: order is not necessarily preserved upon write-read cycles!
string_list readStringListProperty(const std::string& key);
void writeStringListProperty(const std::string& key, const string_list& values);
// Warning: order is not necessarily preserved upon write-read cycles!
string_list readStringListProperty(const std::string& key);
void writeStringListProperty(const std::string& key, const string_list& values);
// These ones guarantee the same order after each write-read cycle.
string_list readOrderedStringListProperty(const std::string& key,
const char* separator);
void writeOrderedStringListProperty(const std::string& key,
const string_list& values,
const char* separator);
// These ones guarantee the same order after each write-read cycle.
string_list readOrderedStringListProperty(const std::string& key,
const char* separator);
void writeOrderedStringListProperty(const std::string& key,
const string_list& values,
const char* separator);
/**
/**
* retrieve an FGPositioned from the cache.
* This may be trivial if the object is previously loaded, or require actual
* disk IO.
*/
FGPositionedRef loadById(PositionedID guid);
FGPositionedRef loadById(PositionedID guid);
PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident,
const std::string& name);
void insertTower(PositionedID airportId, const SGGeod& pos);
PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident,
const std::string& name);
void insertTower(PositionedID airportId, const SGGeod& pos);
PositionedID insertRunway(FGPositioned::Type ty, const string& ident,
const SGGeod& pos, PositionedID apt,
double heading, double length, double width, double displacedThreshold,
double stopway, int markings, int approach, int tdz, int reil,
int surfaceCode, int shoulder_code, float smoothness, int center_lights,
int edge_lights, int distance_remaining);
PositionedID insertRunway(FGPositioned::Type ty, const std::string& ident,
const SGGeod& pos, PositionedID apt,
double heading, double length, double width, double displacedThreshold,
double stopway, int markings, int approach, int tdz, int reil,
int surfaceCode, int shoulder_code, float smoothness, int center_lights,
int edge_lights, int distance_remaining);
PositionedID insertRunway(FGPositioned::Type ty, const string& ident,
const SGGeod& pos, PositionedID apt,
double heading, double length, double width, double displacedThreshold,
double stopway, int surfaceCode);
PositionedID insertRunway(FGPositioned::Type ty, const std::string& ident,
const SGGeod& pos, PositionedID apt,
double heading, double length, double width, double displacedThreshold,
double stopway, int surfaceCode);
void setRunwayReciprocal(PositionedID runway, PositionedID recip);
void setRunwayILS(PositionedID runway, PositionedID ils);
void setRunwayReciprocal(PositionedID runway, PositionedID recip);
void setRunwayILS(PositionedID runway, PositionedID ils);
PositionedID insertNavaid(FGPositioned::Type ty, const std::string& ident,
const std::string& name, const SGGeod& pos, int freq, int range, double multiuse,
PositionedID apt, PositionedID runway);
PositionedID insertNavaid(FGPositioned::Type ty, const std::string& ident,
const std::string& name, const SGGeod& pos, int freq, int range, double multiuse,
PositionedID apt, PositionedID runway);
// Assign colocated DME to a navaid
void setNavaidColocated(PositionedID navaid, PositionedID colocatedDME);
// Assign colocated DME to a navaid
void setNavaidColocated(PositionedID navaid, PositionedID colocatedDME);
PositionedID insertCommStation(FGPositioned::Type ty,
const std::string& name, const SGGeod& pos, int freq, int range,
PositionedID apt);
PositionedID insertFix(const std::string& ident, const SGGeod& aPos);
PositionedID insertCommStation(FGPositioned::Type ty,
const std::string& name, const SGGeod& pos, int freq, int range,
PositionedID apt);
PositionedID insertFix(const std::string& ident, const SGGeod& aPos);
PositionedID createPOI(FGPositioned::Type ty, const std::string& ident, const SGGeod& aPos);
PositionedID createPOI(FGPositioned::Type ty, const std::string& ident, const SGGeod& aPos);
bool removePOI(FGPositioned::Type ty, const std::string& aIdent);
bool removePOI(FGPositioned::Type ty, const std::string& aIdent);
/// update the metar flag associated with an airport
void setAirportMetar(const std::string& icao, bool hasMetar);
/// update the metar flag associated with an airport
void setAirportMetar(const std::string& icao, bool hasMetar);
/**
/**
* Modify the position of an existing item.
*/
void updatePosition(PositionedID item, const SGGeod &pos);
void updatePosition(PositionedID item, const SGGeod& pos);
FGPositionedList findAllWithIdent( const std::string& ident,
FGPositionedList findAllWithIdent(const std::string& ident,
FGPositioned::Filter* filter,
bool exact);
FGPositionedList findAllWithName(const std::string& ident,
FGPositioned::Filter* filter,
bool exact );
FGPositionedList findAllWithName( const std::string& ident,
FGPositioned::Filter* filter,
bool exact );
bool exact);
FGPositionedRef findClosestWithIdent( const std::string& aIdent,
const SGGeod& aPos,
FGPositioned::Filter* aFilter );
FGPositionedRef findClosestWithIdent(const std::string& aIdent,
const SGGeod& aPos,
FGPositioned::Filter* aFilter);
/**
/**
* Helper to implement the AirportSearch widget. Optimised text search of
* airport names and idents, returning a list suitable for passing directly
* to PLIB.
*/
char** searchAirportNamesAndIdents(const std::string& aFilter);
char** searchAirportNamesAndIdents(const std::string& aFilter);
/**
/**
* Find the closest matching comm-station on a frequency, to a position.
* The filter with be used for both type ranging and to validate the result
* candidates.
*/
FGPositionedRef findCommByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt);
FGPositionedRef findCommByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt);
/**
/**
* find all items of a specified type (or range of types) at an airport
*/
PositionedIDVec airportItemsOfType(PositionedID apt, FGPositioned::Type ty,
FGPositioned::Type maxTy = FGPositioned::INVALID);
PositionedIDVec airportItemsOfType(PositionedID apt, FGPositioned::Type ty,
FGPositioned::Type maxTy = FGPositioned::INVALID);
/**
/**
* find the first match item of the specified type and ident, at an airport
*/
PositionedID airportItemWithIdent(PositionedID apt, FGPositioned::Type ty, const std::string& ident);
PositionedID airportItemWithIdent(PositionedID apt, FGPositioned::Type ty, const std::string& ident);
/**
/**
* Find all navaids matching a particular frequency, sorted by range from the
* supplied position. Type-range will be determined from the filter
*/
PositionedIDVec findNavaidsByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt);
PositionedIDVec findNavaidsByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt);
/// overload version of the above that does not consider positioned when
/// returning results. Only used by TACAN carrier search
PositionedIDVec findNavaidsByFreq(int freqKhz, FGPositioned::Filter* filt);
/// overload version of the above that does not consider positioned when
/// returning results. Only used by TACAN carrier search
PositionedIDVec findNavaidsByFreq(int freqKhz, FGPositioned::Filter* filt);
/**
/**
* Given a runway and type, find the corresponding navaid (ILS / GS / OM)
*/
PositionedID findNavaidForRunway(PositionedID runway, FGPositioned::Type ty);
PositionedID findNavaidForRunway(PositionedID runway, FGPositioned::Type ty);
/**
/**
* given a navaid name (or similar) from apt.dat / nav.dat, find the
* corresponding airport and runway IDs.
* Such names look like: 'LHBP 31L DME-ILS' or 'UEEE 23L MM'
*/
AirportRunwayPair findAirportRunway(const std::string& name);
AirportRunwayPair findAirportRunway(const std::string& name);
/**
* Given an aiport, and runway and ILS identifier, find the corresponding cache
/**
* Given an airport, and runway and ILS identifier, find the corresponding cache
* entry. This matches the data we get in the ils.xml files for airports.
*/
PositionedID findILS(PositionedID airport, const std::string& runway, const std::string& navIdent);
PositionedID findILS(PositionedID airport, const std::string& runway, const std::string& navIdent);
/**
/**
* Given an Octree node ID, return a bit-mask defining which of the child
* nodes exist. In practice this means an 8-bit value be sufficent, but
* nodes exist. In practice this means an 8-bit value be sufficient, but
* an int works fine too.
*/
int getOctreeBranchChildren(int64_t octreeNodeId);
int getOctreeBranchChildren(int64_t octreeNodeId);
void defineOctreeNode(Octree::Branch* pr, Octree::Node* nd);
void defineOctreeNode(Octree::Branch* pr, Octree::Node* nd);
/**
/**
* given an octree leaf, return all its child positioned items and their types
*/
TypedPositionedVec getOctreeLeafChildren(int64_t octreeNodeId);
TypedPositionedVec getOctreeLeafChildren(int64_t octreeNodeId);
// airways
int findAirway(int network, const std::string& aName, bool create);
// airways
int findAirway(int network, const std::string& aName, bool create);
int findAirway(const std::string& aName);
int findAirway(const std::string& aName);
/**
/**
* insert an edge between two positioned nodes, into the network.
* The airway identifier will be set accordingly. No reverse edge is created
* by this method - edges are directional so a reverses must be explicitly
* created.
*/
void insertEdge(int network, int airwayID, PositionedID from, PositionedID to);
void insertEdge(int network, int airwayID, PositionedID from, PositionedID to);
/// is the specified positioned a node on the network?
bool isInAirwayNetwork(int network, PositionedID pos);
/// is the specified positioned a node on the network?
bool isInAirwayNetwork(int network, PositionedID pos);
/**
/**
* retrive all the destination points reachable from a positioned
* in an airway
*/
AirwayEdgeVec airwayEdgesFrom(int network, PositionedID pos);
AirwayEdgeVec airwayEdgesFrom(int network, PositionedID pos);
AirwayRef loadAirway(int airwayID);
/**
* Waypoints on the airway
*/
PositionedIDVec airwayWaypts(int id);
PositionedIDVec airwayWaypts(int id);
class Transaction
{
@ -304,6 +302,7 @@ public:
~Transaction();
void commit();
private:
NavDataCache* _instance;
bool _committed;
@ -320,6 +319,7 @@ public:
PositionedIDVec results() const;
bool isComplete() const;
private:
class ThreadedGUISearchPrivate;
std::unique_ptr<ThreadedGUISearchPrivate> d;
@ -328,29 +328,27 @@ public:
void clearDynamicPositioneds();
private:
NavDataCache();
NavDataCache();
friend class RebuildThread;
friend class RebuildThread;
// A generic function for loading all navigation data files of the
// specified type (apt/fix/nav etc.) using the passed type-specific loader.
void loadDatFiles(DatFileType type,
std::function<void(const SGPath&, std::size_t, std::size_t)> loader);
// A generic function for loading all navigation data files of the
// specified type (apt/fix/nav etc.) using the passed type-specific loader.
void loadDatFiles(DatFileType type,
std::function<void(const SGPath&, std::size_t, std::size_t)> loader);
void doRebuild();
void doRebuild();
friend class Transaction;
friend class Transaction;
void beginTransaction();
void commitTransaction();
void abortTransaction();
class NavDataCachePrivate;
std::unique_ptr<NavDataCachePrivate> d;
class NavDataCachePrivate;
std::unique_ptr<NavDataCachePrivate> d;
bool rebuildInProgress = false;
bool rebuildInProgress = false;
};
} // of namespace flightgear
#endif // of FG_NAVDATACACHE_HXX
} // namespace flightgear