diff --git a/src/lib/marble/geodata/data/GeoDataRegion_p.h b/src/lib/marble/geodata/data/GeoDataRegion_p.h index 68f7ccd7a..3ea6882be 100644 --- a/src/lib/marble/geodata/data/GeoDataRegion_p.h +++ b/src/lib/marble/geodata/data/GeoDataRegion_p.h @@ -1,76 +1,76 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Torsten Rahn // #ifndef MARBLE_GEODATAREGIONPRIVATE_H #define MARBLE_GEODATAREGIONPRIVATE_H #include "GeoDataRegion.h" #include "GeoDataLatLonAltBox.h" #include "GeoDataTypes.h" #include "GeoDataLod.h" namespace Marble { class GeoDataRegionPrivate { public: GeoDataRegionPrivate() : m_parent( nullptr ), m_latLonAltBox( nullptr ), m_lod( nullptr ) { } GeoDataRegionPrivate( const GeoDataRegionPrivate& other ) : m_parent( other.m_parent ) { if ( other.m_latLonAltBox ) { m_latLonAltBox = new GeoDataLatLonAltBox( *other.m_latLonAltBox ); } else { m_latLonAltBox = nullptr; } if ( other.m_lod ) { m_lod = new GeoDataLod( *other.m_lod ); } else { m_lod = nullptr; } } explicit GeoDataRegionPrivate( GeoDataFeature * feature ) : m_parent( feature ), m_latLonAltBox( nullptr ), m_lod( nullptr ) { } ~GeoDataRegionPrivate() { delete m_latLonAltBox; delete m_lod; } GeoDataFeature * m_parent; GeoDataLatLonAltBox * m_latLonAltBox; GeoDataLod * m_lod; private: // Preventing usage of operator= - GeoDataRegionPrivate &operator=( const GeoDataRegionPrivate& ); + GeoDataRegionPrivate &operator=( const GeoDataRegionPrivate& ) = delete; }; } // namespace Marble #endif diff --git a/src/lib/marble/geodata/handlers/kml/KmlObjectTagHandler.h b/src/lib/marble/geodata/handlers/kml/KmlObjectTagHandler.h index 149adc562..4d3981664 100644 --- a/src/lib/marble/geodata/handlers/kml/KmlObjectTagHandler.h +++ b/src/lib/marble/geodata/handlers/kml/KmlObjectTagHandler.h @@ -1,35 +1,35 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2014 Dennis Nienhüser // #ifndef MARBLE_KMLOBJECTTAGHANDLER_H #define MARBLE_KMLOBJECTTAGHANDLER_H #include #include namespace Marble { class KmlObjectTagHandler { public: /** * Parses the id and targetId attributes and assign their values to the given object */ static void parseIdentifiers( const GeoParser &parser, GeoDataObject* object ); private: - KmlObjectTagHandler(); // not implemented + KmlObjectTagHandler() = delete; // not implemented }; } #endif diff --git a/src/lib/marble/geodata/parser/GeoTagHandler.h b/src/lib/marble/geodata/parser/GeoTagHandler.h index bcd043a25..74d7655c3 100644 --- a/src/lib/marble/geodata/parser/GeoTagHandler.h +++ b/src/lib/marble/geodata/parser/GeoTagHandler.h @@ -1,98 +1,98 @@ /* Copyright (C) 2007, 2008 Nikolas Zimmermann This file is part of the KDE project This library is free software you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License aint with this library see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARBLE_GEOTAGHANDLER_H #define MARBLE_GEOTAGHANDLER_H #include #include "marble_export.h" #include "GeoParser.h" namespace Marble { class GeoNode; /** * @brief A base class for XML tag handlers * This is a base class that is used in the GeoParser architecture. To implement * a new GeoData format you will need to subclass GeoTagHandler and reimplement * the @see parse(GeoParser&) method. You also need to register the newly * implemented GeoTagHandler by declaring an instance of the helper structure * @see GeoTagHandlerRegistrar with a corresponding @see QualifiedName. */ class MARBLE_EXPORT GeoTagHandler { public: // API to be implemented by child handlers. virtual GeoNode* parse(GeoParser&) const = 0; protected: // This base class is not directly constructable nor is it copyable. GeoTagHandler(); virtual ~GeoTagHandler(); private: - GeoTagHandler(const GeoTagHandler&); - GeoTagHandler& operator=(const GeoTagHandler&); + GeoTagHandler(const GeoTagHandler&) = delete; + GeoTagHandler& operator=(const GeoTagHandler&) = delete; private: // Only our registrar is allowed to register tag handlers. friend struct GeoTagHandlerRegistrar; static void registerHandler(const GeoParser::QualifiedName&, const GeoTagHandler*); static void unregisterHandler(const GeoParser::QualifiedName&); private: // Only our parser is allowed to access tag handlers. friend class GeoParser; static const GeoTagHandler* recognizes(const GeoParser::QualifiedName&); private: typedef QHash TagHash; static TagHash* tagHandlerHash(); static TagHash* s_tagHandlerHash; }; // Helper structure struct GeoTagHandlerRegistrar { public: GeoTagHandlerRegistrar(const GeoParser::QualifiedName& name, const GeoTagHandler* handler) :m_name( name ) { GeoTagHandler::registerHandler(name, handler); } ~GeoTagHandlerRegistrar() { GeoTagHandler::unregisterHandler(m_name); } private: GeoParser::QualifiedName m_name; }; // Macros to ease registering new handlers #define GEODATA_DEFINE_TAG_HANDLER(Module, UpperCaseModule, Name, NameSpace) \ static GeoTagHandlerRegistrar s_handler##Name##NameSpace(GeoParser::QualifiedName(QLatin1String(Module##Tag_##Name), QLatin1String(NameSpace)), \ new UpperCaseModule##Name##TagHandler()); } #endif diff --git a/src/lib/marble/geodata/writers/kml/KmlObjectTagWriter.h b/src/lib/marble/geodata/writers/kml/KmlObjectTagWriter.h index 57e5a7c54..6310188b1 100644 --- a/src/lib/marble/geodata/writers/kml/KmlObjectTagWriter.h +++ b/src/lib/marble/geodata/writers/kml/KmlObjectTagWriter.h @@ -1,35 +1,35 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2014 Dennis Nienhüser // #ifndef MARBLE_KMLOBJECTTAGWRITER_H #define MARBLE_KMLOBJECTTAGWRITER_H #include namespace Marble { class GeoWriter; class KmlObjectTagWriter { public: /** * Parses the id and targetId attributes and assign their values to the given object */ static void writeIdentifiers( GeoWriter &writer, const GeoDataObject* object ); private: - KmlObjectTagWriter(); // not implemented + KmlObjectTagWriter() = delete; // not implemented }; } #endif diff --git a/src/lib/marble/routing/instructions/InstructionTransformation.h b/src/lib/marble/routing/instructions/InstructionTransformation.h index 6e536aa98..8c599ba61 100644 --- a/src/lib/marble/routing/instructions/InstructionTransformation.h +++ b/src/lib/marble/routing/instructions/InstructionTransformation.h @@ -1,38 +1,38 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Dennis Nienhüser // #ifndef MARBLE_INSTRUCTIONTRANSFORMATION_H #define MARBLE_INSTRUCTIONTRANSFORMATION_H #include "RoutingInstruction.h" #include "RoutingWaypoint.h" #include "marble_export.h" namespace Marble { /** * Transforms waypoints and metadata into driving directions */ class MARBLE_EXPORT InstructionTransformation { public: /** Transforms waypoints and metadata into driving directions */ static RoutingInstructions process( const RoutingWaypoints &waypoints ); private: // Pure static usage - InstructionTransformation(); + InstructionTransformation() = delete; Q_DISABLE_COPY( InstructionTransformation ) }; } // namespace Marble #endif // MARBLE_INSTRUCTIONTRANSFORMATION_H diff --git a/src/plugins/runner/monav/MonavPlugin.cpp b/src/plugins/runner/monav/MonavPlugin.cpp index f1b8d912b..3975c5045 100644 --- a/src/plugins/runner/monav/MonavPlugin.cpp +++ b/src/plugins/runner/monav/MonavPlugin.cpp @@ -1,406 +1,406 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Dennis Nienhüser // #include "MonavPlugin.h" #include "signals.h" #include "MonavRunner.h" #include "MonavConfigWidget.h" #include "MonavMap.h" #include "MonavMapsModel.h" #include "MarbleDirs.h" #include "MarbleDebug.h" #include "GeoDataLatLonBox.h" #include "GeoDataData.h" #include "GeoDataExtendedData.h" #include "routing/RouteRequest.h" #include #include #include #include #include namespace Marble { /** A helper class to have a portable sleep call */ class MonavWaiter : private QThread { public: static void msleep( unsigned long milliSeconds ) { QThread::msleep( milliSeconds ); } private: - MonavWaiter(); + MonavWaiter() = delete; Q_DISABLE_COPY( MonavWaiter ) }; class MonavPluginPrivate { public: QDir m_mapDir; QVector m_maps; bool m_ownsServer; QString m_monavDaemonProcess; MonavPlugin::MonavRoutingDaemonVersion m_monavVersion; MonavPluginPrivate(); ~MonavPluginPrivate(); bool startDaemon(); void stopDaemon(); static bool isDaemonRunning(); static bool isDaemonInstalled(); void loadMaps(); void initialize(); static bool areaLessThan( const MonavMap &first, const MonavMap &second ); private: void loadMap( const QString &path ); bool m_initialized; }; MonavPluginPrivate::MonavPluginPrivate() : m_ownsServer( false ), m_monavDaemonProcess("monav-daemon"), m_monavVersion( MonavPlugin::Monav_0_3 ), m_initialized( false ) { // nothing to do } MonavPluginPrivate::~MonavPluginPrivate() { stopDaemon(); } bool MonavPluginPrivate::isDaemonRunning() { QLocalSocket socket; socket.connectToServer( "MoNavD" ); return socket.waitForConnected(); } bool MonavPluginPrivate::isDaemonInstalled() { QString path = QProcessEnvironment::systemEnvironment().value(QStringLiteral("PATH"), QStringLiteral("/usr/local/bin:/usr/bin:/bin")); auto const applications = QStringList() << "monav-daemon" << "MoNavD"; for( const QString &application: applications ) { for( const QString &dir: path.split( QLatin1Char( ':' ) ) ) { QFileInfo executable( QDir( dir ), application ); if ( executable.exists() ) { return true; } } } return false; } bool MonavPluginPrivate::startDaemon() { if ( !isDaemonRunning() ) { if ( QProcess::startDetached( m_monavDaemonProcess, QStringList() ) ) { m_ownsServer = true; } else { if ( QProcess::startDetached( "MoNavD", QStringList() ) ) { m_ownsServer = true; m_monavDaemonProcess = "MoNavD"; m_monavVersion = MonavPlugin::Monav_0_2; } else { return false; } } // Give monav-daemon up to one second to set up its server // Without that, the first route request would fail for ( int i = 0; i < 10; ++i ) { if ( isDaemonRunning() ) { break; } MonavWaiter::msleep( 100 ); } return true; } return true; } void MonavPluginPrivate::stopDaemon() { if ( m_ownsServer ) { m_ownsServer = false; QProcess::startDetached( m_monavDaemonProcess, QStringList() << "-t" ); } } void MonavPluginPrivate::loadMaps() { if ( m_maps.isEmpty() ) { QStringList const baseDirs = QStringList() << MarbleDirs::systemPath() << MarbleDirs::localPath(); for ( const QString &baseDir: baseDirs ) { const QString base = baseDir + QLatin1String("/maps/earth/monav/"); loadMap( base ); QDir::Filters filters = QDir::AllDirs | QDir::Readable | QDir::NoDotAndDotDot; QDirIterator::IteratorFlags flags = QDirIterator::Subdirectories | QDirIterator::FollowSymlinks; QDirIterator iter( base, filters, flags ); while ( iter.hasNext() ) { iter.next(); loadMap( iter.filePath() ); } } // Prefer maps where bounding boxes are known std::sort( m_maps.begin(), m_maps.end(), MonavMap::areaLessThan ); } } void MonavPluginPrivate::loadMap( const QString &path ) { QDir mapDir( path ); QFileInfo pluginsFile( mapDir, "plugins.ini" ); QFileInfo moduleFile( mapDir, "Module.ini" ); if ( pluginsFile.exists() && !moduleFile.exists() ) { qDebug() << "Migrating" << mapDir.dirName() << "from monav-0.2"; QFile file( moduleFile.absoluteFilePath() ); file.open( QIODevice::WriteOnly ); QTextStream stream( &file ); stream << "[General]\nconfigVersion=2\n"; stream << "router=Contraction Hierarchies\ngpsLookup=GPS Grid\n"; stream << "routerFileFormatVersion=1\ngpsLookupFileFormatVersion=1\n"; stream.flush(); file.close(); moduleFile.refresh(); } if ( moduleFile.exists() ) { MonavMap map; map.setDirectory( mapDir ); m_maps.append( map ); } } void MonavPluginPrivate::initialize() { if ( !m_initialized ) { m_initialized = true; loadMaps(); } } MonavPlugin::MonavPlugin( QObject *parent ) : RoutingRunnerPlugin( parent ), d( new MonavPluginPrivate ) { setSupportedCelestialBodies(QStringList(QStringLiteral("earth"))); setCanWorkOffline( true ); if ( d->isDaemonInstalled() ) { d->initialize(); if ( d->m_maps.isEmpty() ) { setStatusMessage( tr ( "No offline maps installed yet." ) ); } } else { setStatusMessage( tr ( "The monav routing daemon does not seem to be installed on your system." ) ); } connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(stopDaemon()) ); } MonavPlugin::~MonavPlugin() { delete d; } QString MonavPlugin::name() const { return tr( "Monav Routing" ); } QString MonavPlugin::guiString() const { return tr( "Monav" ); } QString MonavPlugin::nameId() const { return QStringLiteral("monav"); } QString MonavPlugin::version() const { return QStringLiteral("1.0"); } QString MonavPlugin::description() const { return tr( "Offline routing using the monav daemon" ); } QString MonavPlugin::copyrightYears() const { return QStringLiteral("2010"); } QVector MonavPlugin::pluginAuthors() const { return QVector() << PluginAuthor(QStringLiteral("Dennis Nienhüser"), QStringLiteral("nienhueser@kde.org")); } RoutingRunner *MonavPlugin::newRunner() const { d->initialize(); if ( !d->startDaemon() ) { mDebug() << "Failed to start the monav routing daemon"; } return new MonavRunner( this ); } QString MonavPlugin::mapDirectoryForRequest( const RouteRequest* request ) const { d->initialize(); QHash settings = request->routingProfile().pluginSettings()[nameId()]; const QString transport = settings[QStringLiteral("transport")].toString(); for ( int j=0; jm_maps.size(); ++j ) { bool valid = true; if ( transport.isEmpty() || transport == d->m_maps[j].transport() ) { for ( int i = 0; i < request->size(); ++i ) { GeoDataCoordinates via = request->at( i ); if ( !d->m_maps[j].containsPoint( via ) ) { valid = false; break; } } } else { valid = false; } if ( valid ) { if ( j ) { // Subsequent route requests will likely be in the same country qSwap( d->m_maps[0], d->m_maps[j] ); } // mDebug() << "Using " << d->m_maps.first().m_directory.dirName() << " as monav map"; return d->m_maps.first().directory().absolutePath(); } } return QString(); } QStringList MonavPlugin::mapDirectoriesForRequest( const RouteRequest* request ) const { QStringList result; d->initialize(); QHash settings = request->routingProfile().pluginSettings()[nameId()]; const QString transport = settings[QStringLiteral("transport")].toString(); for ( int j=0; jm_maps.size(); ++j ) { bool valid = true; if ( transport.isEmpty() || transport == d->m_maps[j].transport() ) { for ( int i = 0; i < request->size(); ++i ) { GeoDataCoordinates via = request->at( i ); if ( !d->m_maps[j].containsPoint( via ) ) { valid = false; break; } } } else { valid = false; } if ( valid ) { result << d->m_maps[j].directory().absolutePath(); } } return result; } RoutingRunnerPlugin::ConfigWidget *MonavPlugin::configWidget() { return new MonavConfigWidget( this ); } MonavMapsModel* MonavPlugin::installedMapsModel() { d->initialize(); return new MonavMapsModel( d->m_maps ); } void MonavPlugin::reloadMaps() { d->m_maps.clear(); d->loadMaps(); } bool MonavPlugin::canWork() const { d->initialize(); return !d->m_maps.isEmpty(); } bool MonavPlugin::supportsTemplate( RoutingProfilesModel::ProfileTemplate profileTemplate ) const { // Since we support multiple maps, pretty much anything can be installed, but ecological is // not supported by monav return profileTemplate != RoutingProfilesModel::CarEcologicalTemplate; } QHash< QString, QVariant > MonavPlugin::templateSettings( RoutingProfilesModel::ProfileTemplate profileTemplate ) const { QHash result; switch ( profileTemplate ) { case RoutingProfilesModel::CarFastestTemplate: result["transport"] = "Motorcar"; break; case RoutingProfilesModel::CarShortestTemplate: result["transport"] = "Motorcar"; break; case RoutingProfilesModel::CarEcologicalTemplate: break; case RoutingProfilesModel::BicycleTemplate: result["transport"] = "Bicycle"; break; case RoutingProfilesModel::PedestrianTemplate: result["transport"] = "Pedestrian"; break; case RoutingProfilesModel::LastTemplate: Q_ASSERT( false ); break; } return result; } MonavPlugin::MonavRoutingDaemonVersion MonavPlugin::monavVersion() const { return d->m_monavVersion; } } #include "moc_MonavPlugin.cpp"