From 585c4db5784776ef99100e15affefe8ee06e5cd2 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sat, 30 Mar 2013 17:41:04 +0100 Subject: [PATCH] #12 Fixing linux build --- .../CMakeLists.txt | 0 .../{Geodetic2Ecef => geodetic2ecef}/main.cpp | 2 -- .../sample_geodetic2ecef.pro | 0 samples/interpolator/main.cpp | 2 -- samples/{Logging => logging}/CMakeLists.txt | 0 samples/{Logging => logging}/main.cpp | 0 .../{Logging => logging}/sample_logging.pro | 0 src/blackcore/blackcore.pro | 4 +++ src/blackcore/constants.h | 2 ++ src/blackcore/fsd_messages.h | 4 +-- src/blackcore/mathematics.cpp | 2 +- src/blackcore/mathematics.h | 2 ++ src/blackcore/simulator.h | 27 +++++++++++++++++++ src/blackd/blackd.pro | 4 --- src/blackmisc/com_handler.cpp | 6 ++--- src/blackmisc/config_manager.cpp | 4 +-- src/blackmisc/config_manager.h | 4 +-- src/blackmisc/context.h | 10 +++---- src/blackmisc/debug.cpp | 8 +++--- src/blackmisc/debug.h | 2 +- src/blackmisc/display.cpp | 6 ++++- src/blackmisc/display.h | 2 +- src/blackmisc/log.cpp | 2 +- src/blackmisc/message.cpp | 2 +- src/blackmisc/message.h | 4 +-- src/blackmisc/type_info.cpp | 2 +- src/blackmisc/type_info.h | 4 +-- 27 files changed, 68 insertions(+), 37 deletions(-) rename samples/{Geodetic2Ecef => geodetic2ecef}/CMakeLists.txt (100%) rename samples/{Geodetic2Ecef => geodetic2ecef}/main.cpp (96%) rename samples/{Geodetic2Ecef => geodetic2ecef}/sample_geodetic2ecef.pro (100%) rename samples/{Logging => logging}/CMakeLists.txt (100%) rename samples/{Logging => logging}/main.cpp (100%) rename samples/{Logging => logging}/sample_logging.pro (100%) diff --git a/samples/Geodetic2Ecef/CMakeLists.txt b/samples/geodetic2ecef/CMakeLists.txt similarity index 100% rename from samples/Geodetic2Ecef/CMakeLists.txt rename to samples/geodetic2ecef/CMakeLists.txt diff --git a/samples/Geodetic2Ecef/main.cpp b/samples/geodetic2ecef/main.cpp similarity index 96% rename from samples/Geodetic2Ecef/main.cpp rename to samples/geodetic2ecef/main.cpp index 21fec1a5e..a9e3e7ef3 100644 --- a/samples/Geodetic2Ecef/main.cpp +++ b/samples/geodetic2ecef/main.cpp @@ -2,8 +2,6 @@ #include #include "blackmisc/debug.h" #include -#include -#include #include "blackcore/ecef.h" #include "blackcore/vector_geo.h" diff --git a/samples/Geodetic2Ecef/sample_geodetic2ecef.pro b/samples/geodetic2ecef/sample_geodetic2ecef.pro similarity index 100% rename from samples/Geodetic2Ecef/sample_geodetic2ecef.pro rename to samples/geodetic2ecef/sample_geodetic2ecef.pro diff --git a/samples/interpolator/main.cpp b/samples/interpolator/main.cpp index c6cc7724a..5631edae9 100644 --- a/samples/interpolator/main.cpp +++ b/samples/interpolator/main.cpp @@ -1,8 +1,6 @@ #include #include -#include - #include #include "blackcore/matrix_3d.h" diff --git a/samples/Logging/CMakeLists.txt b/samples/logging/CMakeLists.txt similarity index 100% rename from samples/Logging/CMakeLists.txt rename to samples/logging/CMakeLists.txt diff --git a/samples/Logging/main.cpp b/samples/logging/main.cpp similarity index 100% rename from samples/Logging/main.cpp rename to samples/logging/main.cpp diff --git a/samples/Logging/sample_logging.pro b/samples/logging/sample_logging.pro similarity index 100% rename from samples/Logging/sample_logging.pro rename to samples/logging/sample_logging.pro diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index 22f89c23a..3986d725c 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -8,6 +8,10 @@ INCLUDEPATH += .. DEPENDPATH += . .. +linux-g++* { + QMAKE_CXXFLAGS += -std=c++0x +} + #PRECOMPILED_HEADER = stdpch.h precompile_header:!isEmpty(PRECOMPILED_HEADER) { diff --git a/src/blackcore/constants.h b/src/blackcore/constants.h index b307e57f1..fc1ef6636 100644 --- a/src/blackcore/constants.h +++ b/src/blackcore/constants.h @@ -8,6 +8,8 @@ #include "mathematics.h" +#include + namespace BlackCore { namespace Constants diff --git a/src/blackcore/fsd_messages.h b/src/blackcore/fsd_messages.h index 8711b98fd..d60ad3f6a 100644 --- a/src/blackcore/fsd_messages.h +++ b/src/blackcore/fsd_messages.h @@ -21,7 +21,7 @@ namespace FSD class FSD_MSG : public BlackMisc::IMessage { public: - FSD_MSG(QString& id) : IMessage(id) + FSD_MSG(QString id) : IMessage(id) { } @@ -40,7 +40,7 @@ namespace FSD class FSD_MSG_AddPilot : public FSD_MSG { public: - FSD_MSG_AddPilot() : FSD_MSG(QString("#AP")), m_revision(VATSIM_PROTOCOL_REV), + FSD_MSG_AddPilot() : FSD_MSG("#AP"), m_revision(VATSIM_PROTOCOL_REV), m_rating(1) { } diff --git a/src/blackcore/mathematics.cpp b/src/blackcore/mathematics.cpp index 7005e3a85..49f790400 100644 --- a/src/blackcore/mathematics.cpp +++ b/src/blackcore/mathematics.cpp @@ -25,7 +25,7 @@ double CMath::hypot(double x, double y) double CMath::cubicRootReal(const double x) { double result; - result = std::pow(std::abs(x), (double)1/3); + result = pow(abs(x), (double)1/3); return x < 0 ? -result : result; } diff --git a/src/blackcore/mathematics.h b/src/blackcore/mathematics.h index e24db691d..db0ec5a3d 100644 --- a/src/blackcore/mathematics.h +++ b/src/blackcore/mathematics.h @@ -6,6 +6,8 @@ #ifndef MATH_H #define MATH_H +#include + namespace BlackCore { diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index b1db49fff..8215e0f92 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -92,6 +92,8 @@ namespace BlackCore { bool beaconLights; //!< true if beacon lights on }; +#ifdef Q_OS_WIN + //! A callback that is called when the simulator is started. typedef std::tr1::function cbSimStarted; @@ -104,6 +106,20 @@ namespace BlackCore { //! A callback that is called when the user's plane changes its model. typedef std::tr1::function cbChangedModel; +#else + //! A callback that is called when the simulator is started. + typedef std::function cbSimStarted; + + //! A callback that is called when the user's plane changes its avionics state. + typedef std::function cbChangedAvionicsState; + + //! A callback that is called when the user's plane changes its animation state. + typedef std::function cbChangedAnimationState; + + //! A callback that is called when the user's plane changes its model. + typedef std::function cbChangedModel; +#endif + /*! * The interface that is implemented by each simulator driver. * @@ -200,14 +216,25 @@ namespace BlackCore { virtual bool setAnimationState(const qint32 planeID, const CAnimationState &state) = 0; //! Calls the supplied visitor function once for every model available in the simulator. + +#ifdef Q_OS_WIN virtual void visitAllModels(const std::tr1::function &visitor) = 0; +#else + virtual void visitAllModels(const std::function &visitor) = 0; +#endif /*! * Fills container with all models. * Class T must be a container of CPlaneModel objects and must support push_back. */ +#ifdef Q_OS_WIN template void getAllModels(T &container) { visitAllModels(std::tr1::bind(T::push_back, container)); } +#else + template + void getAllModels(T &container) { visitAllModels(std::bind(T::push_back, container)); } +#endif + protected: BlackMisc::IContext *m_libraryContext; //!< The global context. diff --git a/src/blackd/blackd.pro b/src/blackd/blackd.pro index be3079e58..f49b78453 100644 --- a/src/blackd/blackd.pro +++ b/src/blackd/blackd.pro @@ -2,10 +2,6 @@ QT += core gui xml svg network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -PRE_TARGETDEPS += ../../lib/blackmisc.lib \ - ../../lib/blackcore.lib - TARGET = blackd TEMPLATE = app diff --git a/src/blackmisc/com_handler.cpp b/src/blackmisc/com_handler.cpp index f6d31e6b1..2f582ae13 100644 --- a/src/blackmisc/com_handler.cpp +++ b/src/blackmisc/com_handler.cpp @@ -58,7 +58,7 @@ namespace BlackMisc do { qint32 sync = 0; - stream >> (qint32)sync; + stream >> sync; if (sync == Sync_Marker) found_sync = true; } @@ -78,7 +78,7 @@ namespace BlackMisc ///////////////////////////////////////////////// qint32 message_length = 0; - stream >> (qint32)message_length; + stream >> message_length; total_length += (int)sizeof(qint32); // Length total_length += message_length; // Data @@ -108,7 +108,7 @@ namespace BlackMisc quint16 crc_calc = qChecksum (data.constData(), data.size()); quint16 crc_recv = 0; - stream >> (quint16)crc_recv; + stream >> crc_recv; total_length += (int)sizeof(quint16); diff --git a/src/blackmisc/config_manager.cpp b/src/blackmisc/config_manager.cpp index 52eff6f37..57cc5da53 100644 --- a/src/blackmisc/config_manager.cpp +++ b/src/blackmisc/config_manager.cpp @@ -14,7 +14,7 @@ namespace BlackMisc { } - void CConfigManager::setConfigPath(QString &path) + void CConfigManager::setConfigPath(QString path) { m_config_path = QDir(path).absolutePath(); @@ -91,4 +91,4 @@ namespace BlackMisc } } -} // namespace BlackMisc \ No newline at end of file +} // namespace BlackMisc diff --git a/src/blackmisc/config_manager.h b/src/blackmisc/config_manager.h index 737cca67a..6bac64ae2 100644 --- a/src/blackmisc/config_manager.h +++ b/src/blackmisc/config_manager.h @@ -36,7 +36,7 @@ namespace BlackMisc /*! \param path absolute pathname */ - void setConfigPath(QString &path); + void setConfigPath(QString path); int readConfig(bool forceReload = false); @@ -56,4 +56,4 @@ namespace BlackMisc }; } // namespace BlackLib -#endif // CONFIGMANAGER_H \ No newline at end of file +#endif // CONFIGMANAGER_H diff --git a/src/blackmisc/context.h b/src/blackmisc/context.h index 8a3ffe2f9..a8ddc73ff 100644 --- a/src/blackmisc/context.h +++ b/src/blackmisc/context.h @@ -49,33 +49,33 @@ namespace BlackMisc \param singletonName a reference to the singletones name. \return Returns a pointer to the singleton object. */ - virtual void *singletonPointer(const QString &singletonName) = NULL; + virtual void *singletonPointer(const QString &singletonName) = 0; //! Pure virtual method sets the singletone pointer, given by its name. /*! \param singletonName a reference to the singletones name. \param object a pointer to the singletone object. */ - virtual void setSingletonPointer(const QString &singletonName, void *object) = NULL; + virtual void setSingletonPointer(const QString &singletonName, void *object) = 0; //! Deallocates the object and removes the singletone pointer from the context map. /*! \param singletonName a reference to the singletones name. \param object a pointer to the singletone object. */ - virtual void releaseSingletonPointer(const QString &singletonName, void *object) = NULL; + virtual void releaseSingletonPointer(const QString &singletonName, void *object) = 0; //! Pure virtual method returns the pointer to debug object /*! \return Pointer to CDebug object */ - virtual CDebug *getDebug() = NULL; + virtual CDebug *getDebug() = 0; //! Pure virtual function to set the global error log object /*! \param Pointer to CDebug object */ - virtual void setDebug(CDebug *debug) = NULL; + virtual void setDebug(CDebug *debug) = 0; protected: //! Method to register the context. diff --git a/src/blackmisc/debug.cpp b/src/blackmisc/debug.cpp index c07b4f66a..a58108b02 100644 --- a/src/blackmisc/debug.cpp +++ b/src/blackmisc/debug.cpp @@ -14,7 +14,7 @@ namespace BlackMisc } - void CDebug::create (QString &logPath, bool logInFile, bool eraseLastLog) + void CDebug::create (const char *logPath, bool logInFile, bool eraseLastLog) { if (!m_isInitialized) { @@ -28,7 +28,7 @@ namespace BlackMisc if (logInFile) { - QDir fileinfo(m_logPath); + QDir fileinfo(m_logPath); QString fn; if ( !m_logPath.isEmpty() ) { @@ -76,8 +76,8 @@ namespace BlackMisc m_assertLog->setLogInformation (line, file, function); BlackMisc::CLogMessage::getAssertMsgObj() << "ASSERT FAILED! STOP!"; - #ifdef BB_GUI - QMessageBox::critical(0, "ASSERT FAILED", + #ifdef BB_GUI + QMessageBox::critical(0, "ASSERT FAILED", QString("%1 %2 %3 () - failed assert: %4"). arg(QString(file)).arg(line).arg(QString(function)).arg(QString(exp))); #endif diff --git a/src/blackmisc/debug.h b/src/blackmisc/debug.h index 78e7041c7..8bb2cc6d1 100644 --- a/src/blackmisc/debug.h +++ b/src/blackmisc/debug.h @@ -29,7 +29,7 @@ namespace BlackMisc // internal use only - void create (QString &logPath = QString(""), bool logInFile = true, bool eraseLastLog = false); + void create (const char *logPath = "", bool logInFile = true, bool eraseLastLog = false); // init Debug void init(bool logInFile); diff --git a/src/blackmisc/display.cpp b/src/blackmisc/display.cpp index 1156578f3..ab1612b52 100644 --- a/src/blackmisc/display.cpp +++ b/src/blackmisc/display.cpp @@ -9,6 +9,10 @@ #include "blackmisc/context.h" #include "blackmisc/display.h" +#ifdef Q_OS_LINUX + #include +#endif + namespace BlackMisc { @@ -243,7 +247,7 @@ namespace BlackMisc if (m_file->handle() == -1) { if ( !m_file->open(QIODevice::WriteOnly) ) - printf ("Can't open log file '%s': %s\n", m_fileName.toLatin1(), strerror (errno)); + printf ("Can't open log file '%s': %s\n", m_fileName.toLatin1().constData(), strerror (errno)); } if (m_file->handle() != -1) diff --git a/src/blackmisc/display.h b/src/blackmisc/display.h index 1a98eb617..1fb3c2bbf 100644 --- a/src/blackmisc/display.h +++ b/src/blackmisc/display.h @@ -30,7 +30,7 @@ namespace BlackMisc protected: /// Method to implement in the derived class - virtual void doPrint(const CLog::SLogInformation &logInformation, const QString &message) = NULL; + virtual void doPrint(const CLog::SLogInformation &logInformation, const QString &message) = 0; // Return the header string with date (for the first line of the log) static QString headLine (); diff --git a/src/blackmisc/log.cpp b/src/blackmisc/log.cpp index 4d94cce2f..771a2ea08 100644 --- a/src/blackmisc/log.cpp +++ b/src/blackmisc/log.cpp @@ -60,7 +60,7 @@ namespace BlackMisc #else //! Todo: Check if there a corresponding API in Linux and Mac //! For the time being, set it to unknown. - if ((*m_applicationName).empty()) + if ((*m_applicationName).isEmpty()) { *m_applicationName = ""; } diff --git a/src/blackmisc/message.cpp b/src/blackmisc/message.cpp index a81a8769b..c5d85de9c 100644 --- a/src/blackmisc/message.cpp +++ b/src/blackmisc/message.cpp @@ -2,7 +2,7 @@ namespace BlackMisc { - IMessage::IMessage(QString& id) + IMessage::IMessage(QString id) { m_message_id = id; } diff --git a/src/blackmisc/message.h b/src/blackmisc/message.h index 58c9a2061..94b533acd 100644 --- a/src/blackmisc/message.h +++ b/src/blackmisc/message.h @@ -17,7 +17,7 @@ namespace BlackMisc class IMessage : public ISerialize { public: - IMessage(QString& id); + IMessage(QString id); QString getID() const; @@ -36,7 +36,7 @@ namespace BlackMisc class TestMessage : public IMessage { public: - TestMessage() : IMessage(QString("MSG_ID_TestMessage")) + TestMessage() : IMessage("MSG_ID_TestMessage") { testString = "This is a test message!"; } diff --git a/src/blackmisc/type_info.cpp b/src/blackmisc/type_info.cpp index d9fb8dcc8..d689816a3 100644 --- a/src/blackmisc/type_info.cpp +++ b/src/blackmisc/type_info.cpp @@ -8,7 +8,7 @@ namespace BlackMisc { - CTypeInfo::CTypeInfo(const type_info& info) + CTypeInfo::CTypeInfo(const std::type_info& info) : m_typeinfo(info) { } diff --git a/src/blackmisc/type_info.h b/src/blackmisc/type_info.h index 7061bd9c7..6ed97623f 100644 --- a/src/blackmisc/type_info.h +++ b/src/blackmisc/type_info.h @@ -14,12 +14,12 @@ namespace BlackMisc class CTypeInfo { public: - explicit CTypeInfo(const type_info& info); + explicit CTypeInfo(const std::type_info& info); bool operator < (const CTypeInfo& rhs) const; private: - const type_info& m_typeinfo; + const std::type_info& m_typeinfo; }; } // namespace BlackMisc