diff --git a/samples/Logging/main.cpp b/samples/Logging/main.cpp deleted file mode 100644 index 1ad1a607a..000000000 --- a/samples/Logging/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - BlackMisc::CApplicationContext myApplicationContext; - - BlackMisc::IContext::getInstance().setSingleton(new BlackMisc::CDebug()); - - bAppInfo << "This is a Info log message"; - bAppWarning << "This is a bWarning log message"; - bAppError << "This is a bError log message"; - bAppDebug << "This is a bDebug log message"; - - return a.exec(); -} diff --git a/samples/Logging/sample_logging.pro b/samples/Logging/sample_logging.pro deleted file mode 100644 index d22de1cdf..000000000 --- a/samples/Logging/sample_logging.pro +++ /dev/null @@ -1,25 +0,0 @@ -QT += core -QT -= gui - -TARGET = sample_logging -TEMPLATE = app - -CONFIG += console -CONFIG -= app_bundle - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -SOURCES += *.cpp - -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} - -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} - -DESTDIR = ../../bin diff --git a/samples/blackmiscquantities/sample_quantities_avionics.pro b/samples/blackmiscquantities/sample_quantities_avionics.pro index 59cf6ab98..2e9e95d87 100644 --- a/samples/blackmiscquantities/sample_quantities_avionics.pro +++ b/samples/blackmiscquantities/sample_quantities_avionics.pro @@ -7,18 +7,13 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle -DEPENDPATH += . ../../src/blackmisc +DEPENDPATH += . ../../src INCLUDEPATH += . ../../src -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin diff --git a/samples/blackmiscvectorgeo/sample_vector_geo.pro b/samples/blackmiscvectorgeo/sample_vector_geo.pro index 94e455f70..a44bebc4a 100644 --- a/samples/blackmiscvectorgeo/sample_vector_geo.pro +++ b/samples/blackmiscvectorgeo/sample_vector_geo.pro @@ -9,24 +9,12 @@ TEMPLATE = app DEPENDPATH += . ../../src INCLUDEPATH += . ../../src -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin -SOURCES += main.cpp \ - samplesvectormatrix.cpp \ - samplesgeo.cpp \ - samplesgeodetictoecef.cpp - -HEADERS += \ - samplesvectormatrix.h \ - samplesgeo.h \ - samplesgeodetictoecef.h +SOURCES += *.cpp +HEADERS += *.h diff --git a/samples/com_client/sample_com_client.pro b/samples/com_client/sample_com_client.pro index 4b9007501..61b68e378 100644 --- a/samples/com_client/sample_com_client.pro +++ b/samples/com_client/sample_com_client.pro @@ -14,14 +14,12 @@ INCLUDEPATH += . ../../src SOURCES += *.cpp HEADERS += *.h -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin + + + diff --git a/samples/com_server/sample_com_server.pro b/samples/com_server/sample_com_server.pro index 21da67c03..e6d61c03d 100644 --- a/samples/com_server/sample_com_server.pro +++ b/samples/com_server/sample_com_server.pro @@ -13,15 +13,10 @@ INCLUDEPATH += . ../../src SOURCES += *.cpp HEADERS += *.h -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin diff --git a/samples/config/sample_config.pro b/samples/config/sample_config.pro index 18906e263..801d9f071 100644 --- a/samples/config/sample_config.pro +++ b/samples/config/sample_config.pro @@ -9,14 +9,12 @@ INCLUDEPATH += . ../../src SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin + + + diff --git a/samples/interpolator/sample_interpolator.pro b/samples/interpolator/sample_interpolator.pro index 13a77d8cc..aa2fea407 100644 --- a/samples/interpolator/sample_interpolator.pro +++ b/samples/interpolator/sample_interpolator.pro @@ -6,22 +6,19 @@ CONFIG -= app_bundle TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle + DEPENDPATH += . ../../src INCLUDEPATH += . ../../src + SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - PRE_TARGETDEPS += ../../lib/blackcore.lib - LIBS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackcore.lib -} +LIBS += -L../../lib -lblackcore -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - PRE_TARGETDEPS += ../../lib/libblackcore.a - LIBS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackcore.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ + ../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ + ../../lib/libblackcore.a DESTDIR = ../../bin diff --git a/samples/logging/sample_logging.pro b/samples/logging/sample_logging.pro deleted file mode 100644 index d22de1cdf..000000000 --- a/samples/logging/sample_logging.pro +++ /dev/null @@ -1,25 +0,0 @@ -QT += core -QT -= gui - -TARGET = sample_logging -TEMPLATE = app - -CONFIG += console -CONFIG -= app_bundle - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -SOURCES += *.cpp - -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} - -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} - -DESTDIR = ../../bin diff --git a/samples/plugin/sample_plugin.pro b/samples/plugin/sample_plugin.pro index 354f9b794..c01de703c 100644 --- a/samples/plugin/sample_plugin.pro +++ b/samples/plugin/sample_plugin.pro @@ -10,14 +10,12 @@ INCLUDEPATH += . ../../src SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin + + + diff --git a/samples/pluginmgr/sample_pluginmgr.pro b/samples/pluginmgr/sample_pluginmgr.pro index 2a8c326fe..11700db9a 100644 --- a/samples/pluginmgr/sample_pluginmgr.pro +++ b/samples/pluginmgr/sample_pluginmgr.pro @@ -12,18 +12,14 @@ INCLUDEPATH += . ../../src SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - PRE_TARGETDEPS += ../../lib/blackcore.lib - LIBS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackcore.lib -} +LIBS += -L../../lib -lblackcore -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - PRE_TARGETDEPS += ../../lib/libblackcore.a - LIBS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackcore.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ + ../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ + ../../lib/libblackcore.a DESTDIR = ../../bin + + + diff --git a/src/blackbox/blackbox.pro b/src/blackbox/blackbox.pro index 58b6c3b3e..79dad5973 100644 --- a/src/blackbox/blackbox.pro +++ b/src/blackbox/blackbox.pro @@ -12,14 +12,9 @@ HEADERS += *.h FORMS += blackbox.ui dialog_connect.ui dialog_chat.ui -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin diff --git a/src/blackd/blackd.pro b/src/blackd/blackd.pro index 640c71ede..7ac44a843 100644 --- a/src/blackd/blackd.pro +++ b/src/blackd/blackd.pro @@ -2,11 +2,11 @@ QT += core gui xml svg network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + TARGET = blackd TEMPLATE = app -DEPENDPATH += ../blackmisc ../blackcore - +DEPENDPATH += . .. INCLUDEPATH += .. SOURCES += *.cpp @@ -15,19 +15,12 @@ HEADERS += *.h FORMS += blackd.ui RESOURCES += blackd.qrc -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - PRE_TARGETDEPS += ../../lib/blackcore.lib - LIBS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackcore.lib -} +LIBS += -L../../lib -lblackcore -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - PRE_TARGETDEPS += ../../lib/libblackcore.a - LIBS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackcore.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ + ../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ + ../../lib/libblackcore.a DESTDIR = ../../bin diff --git a/src/blackmisc/basestreamstringifier.h b/src/blackmisc/basestreamstringifier.h index d75e88acd..c11b2e08e 100644 --- a/src/blackmisc/basestreamstringifier.h +++ b/src/blackmisc/basestreamstringifier.h @@ -48,7 +48,7 @@ template class CBaseStreamStringifier * \param uc * \return */ - friend QNoDebug &operator<<(QNoDebug &nodebug, const UsingClass &uc) + friend QNoDebug operator<<(QNoDebug nodebug, const UsingClass &uc) { return nodebug; } @@ -72,7 +72,7 @@ template class CBaseStreamStringifier * \param uc * \return */ - friend CLogMessage &operator<<(CLogMessage &log, const UsingClass &uc) + friend CLogMessage operator<<(CLogMessage log, const UsingClass &uc) { const CBaseStreamStringifier &sf = uc; // allows to acces protected method log << sf.stringForStreaming(); diff --git a/src/blackmisc/mathmatrixbase.cpp b/src/blackmisc/mathmatrixbase.cpp index 9d28779ca..99a1dadd3 100644 --- a/src/blackmisc/mathmatrixbase.cpp +++ b/src/blackmisc/mathmatrixbase.cpp @@ -97,7 +97,7 @@ template ImplMatrix &CMatrixBasem_matrix(r, c) = CMath::roundEpsilon(this->m_matrix(r, c), 1E-10); } } - return static_cast(*this); + return *derived(); } /* diff --git a/src/blackmisc/mathmatrixbase.h b/src/blackmisc/mathmatrixbase.h index 2841a3385..8b3b6152b 100644 --- a/src/blackmisc/mathmatrixbase.h +++ b/src/blackmisc/mathmatrixbase.h @@ -32,12 +32,21 @@ protected: QString stringForConverter() const; /*! - * \brief Clone as conrete implementation + * \brief Easy access to derived class (CRTP template parameter) * \return */ - ImplMatrix clone() const + ImplMatrix const* derived() const { - return static_cast(*this); + return static_cast(this); + } + + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + ImplMatrix* derived() + { + return static_cast(this); } public: @@ -118,7 +127,7 @@ public: */ ImplMatrix operator *(double factor) const { - ImplMatrix m = this->clone(); + ImplMatrix m = *derived(); m *= factor; return m; } @@ -159,7 +168,7 @@ public: */ ImplMatrix operator /(double factor) const { - ImplMatrix m = this->clone(); + ImplMatrix m = *derived(); m /= factor; return m; } @@ -182,7 +191,7 @@ public: */ ImplMatrix operator +(const ImplMatrix &otherMatrix) const { - ImplMatrix m = this->clone(); + ImplMatrix m = *derived(); m += otherMatrix; return m; } @@ -205,7 +214,7 @@ public: */ ImplMatrix operator -(const ImplMatrix &otherMatrix) const { - ImplMatrix m = this->clone(); + ImplMatrix m = *derived(); m -= otherMatrix; return m; } @@ -225,8 +234,8 @@ public: */ bool isIdentityEpsilon() const { - ImplMatrix m = this->clone().round(); - return m.isIdentity(); + ImplMatrix m = *derived(); + return m.round().isIdentity(); } /*! @@ -260,8 +269,8 @@ public: */ bool isZeroEpsilon() const { - ImplMatrix m = this->clone().round(); - return m.isZero(); + ImplMatrix m = *derived(); + return m.round().isZero(); } /*! diff --git a/src/blackmisc/mathvector3dbase.h b/src/blackmisc/mathvector3dbase.h index 8183c325e..1fe7d6133 100644 --- a/src/blackmisc/mathvector3dbase.h +++ b/src/blackmisc/mathvector3dbase.h @@ -62,14 +62,22 @@ protected: virtual QString stringForConverter() const; /*! - * \brief Clone as concrete implementation + * \brief Easy access to derived class (CRTP template parameter) * \return */ - ImplVector clone() const + ImplVector const* derived() const { - return static_cast(*this); + return static_cast(this); } + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + ImplVector* derived() + { + return static_cast(this); + } public: @@ -198,7 +206,7 @@ public: */ ImplVector operator +(const ImplVector &otherVector) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v += otherVector; return v; } @@ -223,7 +231,7 @@ public: */ ImplVector operator -(const ImplVector &otherVector) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v -= otherVector; return v; } @@ -248,7 +256,7 @@ public: */ ImplVector operator *(const ImplVector &otherVector) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v *= otherVector; return v; } @@ -273,7 +281,7 @@ public: */ ImplVector operator *(double factor) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v *= factor; return v; } @@ -309,7 +317,7 @@ public: */ ImplVector operator /(double divisor) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v /= divisor; return v; } @@ -334,7 +342,7 @@ public: */ ImplVector operator /(const ImplVector &otherVector) const { - ImplVector v = this->clone(); + ImplVector v = *derived(); v /= otherVector; return v; } @@ -413,7 +421,7 @@ public: this->m_i = BlackMisc::Math::CMath::roundEpsilon(this->m_i, epsilon); this->m_j = BlackMisc::Math::CMath::roundEpsilon(this->m_j, epsilon); this->m_k = BlackMisc::Math::CMath::roundEpsilon(this->m_k, epsilon); - return static_cast(*this); + return *derived(); } }; diff --git a/src/blackmisc/pqphysicalquantity.cpp b/src/blackmisc/pqphysicalquantity.cpp index 78be3743c..611a928ba 100644 --- a/src/blackmisc/pqphysicalquantity.cpp +++ b/src/blackmisc/pqphysicalquantity.cpp @@ -193,7 +193,7 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator -(const PQ &otherQuantity) const { - PQ minus = this->clone(); + PQ minus = *derived(); minus -= otherQuantity; return minus; } @@ -212,7 +212,7 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator *(double multiply) const { - PQ times = this->clone(); + PQ times = *derived(); times *= multiply; return times; } @@ -231,7 +231,7 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator /(double divide) const { - PQ div = this->clone(); + PQ div = *derived(); div /= divide; return div; } @@ -286,7 +286,7 @@ template PQ &CPhysicalQuantity::switchUnit(const MU this->m_unit = newUnit; this->setUnitValue(cf); } - return static_cast(*this); + return *derived(); } /* diff --git a/src/blackmisc/pqphysicalquantity.h b/src/blackmisc/pqphysicalquantity.h index 2314e0e48..053fcf829 100644 --- a/src/blackmisc/pqphysicalquantity.h +++ b/src/blackmisc/pqphysicalquantity.h @@ -60,12 +60,21 @@ protected: } /*! - * \brief Polymorphic clone as concrete class + * \brief Easy access to derived class (CRTP template parameter) * \return */ - PQ clone() const + PQ const* derived() const { - return static_cast(*this); + return static_cast(this); + } + + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + PQ* derived() + { + return static_cast(this); } /*! diff --git a/src/blackmisc/pqunits.h b/src/blackmisc/pqunits.h index a08328008..736ef86b8 100644 --- a/src/blackmisc/pqunits.h +++ b/src/blackmisc/pqunits.h @@ -5,8 +5,9 @@ #ifndef BLACKMISC_PQUNITS_H #define BLACKMISC_PQUNITS_H + #include "blackmisc/pqbase.h" -#include +#include // // Used with the template for quantities. This is the reason for diff --git a/tests/blackcore/test_blackcore.pro b/tests/blackcore/test_blackcore.pro index aaf0bfcff..d4076c16a 100644 --- a/tests/blackcore/test_blackcore.pro +++ b/tests/blackcore/test_blackcore.pro @@ -6,24 +6,17 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle -DEPENDPATH += . ../../src/blackmisc +DEPENDPATH += . ../../src INCLUDEPATH += . ../../src HEADERS += *.h SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - PRE_TARGETDEPS += ../../lib/blackcore.lib - LIBS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackcore.lib -} +LIBS += -L../../lib -lblackcore -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - PRE_TARGETDEPS += ../../lib/libblackcore.a - LIBS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackcore.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ + ../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ + ../../lib/libblackcore.a DESTDIR = ../../bin diff --git a/tests/blackmisc/test_blackmisc.pro b/tests/blackmisc/test_blackmisc.pro index 68427a185..dbbab21ba 100644 --- a/tests/blackmisc/test_blackmisc.pro +++ b/tests/blackmisc/test_blackmisc.pro @@ -6,20 +6,15 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle -DEPENDPATH += . ../../src/blackmisc +DEPENDPATH += . ../../src INCLUDEPATH += . ../../src HEADERS += *.h SOURCES += *.cpp -win32-msvc* { - PRE_TARGETDEPS += ../../lib/blackmisc.lib - LIBS += ../../lib/blackmisc.lib -} +LIBS += -L../../lib -lblackmisc -!win32-msvc* { - PRE_TARGETDEPS += ../../lib/libblackmisc.a - LIBS += ../../lib/libblackmisc.a -} +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin