Moved PQs from blackcore to blackmisc, added header for namespace, mainpage.dox for Doxygen

This commit is contained in:
Klaus Basan
2013-03-22 16:07:53 +01:00
parent 969f0c879f
commit 525910c7a3
34 changed files with 237 additions and 112 deletions

View File

@@ -6,11 +6,11 @@ WITH_BLACKCORE = ON
WITH_BLACKD = ON
WITH_BLACKBOX = ON
WITH_SAMPLES = ON
WITH_UNITTESTS = ON
#WITH_DRIVER_FSX = ON
#WITH_DRIVER_FS9 = ON
#WITH_DRIVER_XPLANE = ON
#WITH_UNITTESTS = ON
equals(WITH_BLACKMISC, ON) {
SUBDIRS += src/blackmisc
@@ -51,5 +51,5 @@ equals(WITH_SAMPLES, ON) {
}
equals(WITH_UNITTESTS, ON) {
SUBDIRS += tests/blackcore/test_blackcore.pro
SUBDIRS += tests/blackmisc/test_blackmisc.pro
}

View File

@@ -22,9 +22,8 @@ win32-msvc* {
PRE_TARGETDEPS += ../../lib/libblackmisc.a \
LIBS += ../../lib/libblackmisc.a \
}
DESTDIR = ../../bin

View File

@@ -1,18 +1,20 @@
#include <QCoreApplication>
#include <QDebug>
#include "blackcore/pqdistance.h"
#include "blackcore/pqfrequency.h"
#include "blackcore/pqspeed.h"
#include "blackcore/pqangle.h"
#include "blackcore/pqmass.h"
#include "blackcore/pqpressure.h"
#include "blackmisc/pqconstants.h"
#include "blackmisc/debug.h"
using namespace BlackCore;
using namespace BlackMisc;
/*!
* Sample tests
* \brief main
* \param argc
* \param argv
* \return
*/
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const CDistance d1(5.0, CDistanceUnit::ft()); // 5 ft
CDistance d2(1, CDistanceUnit::NM()); // 1NM
CDistance d3(1, CDistanceUnit::km());
@@ -50,6 +52,14 @@ int main(int argc, char *argv[])
CPressure p1(1013.25, CPressureUnit::hPa());
qDebug() << p1 << p1.valueRoundedWithUnit(CPressureUnit::psi()) << p1.valueRoundedWithUnit(CPressureUnit::inHg());
CTemperature t1;
CTemperature t2(20, CTemperatureUnit::C());
qDebug() << t1 << t2;
// some logging wit CLogMessage
bDebug << p1;
bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
// bye
return a.exec();
}

View File

@@ -7,18 +7,18 @@ TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
DEPENDPATH += . ../../src/blackcore
DEPENDPATH += . ../../src
INCLUDEPATH += . ../../src
SOURCES += main.cpp
win32-msvc* {
PRE_TARGETDEPS += ../../lib/blackcore.lib
LIBS += ../../lib/blackcore.lib
PRE_TARGETDEPS += ../../lib/blackmisc.lib
LIBS += ../../lib/blackmisc.lib
}
!win32-msvc* {
PRE_TARGETDEPS += ../../lib/libblackcore.a
LIBS += ../../lib/libblackcore.a
PRE_TARGETDEPS += ../../lib/libblackmisc.a
LIBS += ../../lib/libblackmisc.a
}
DESTDIR = ../../bin

View File

@@ -29,15 +29,6 @@ HEADERS += \
multiplayer.h \
ned.h \
plane.h \
pqdistance.h \
pqphysicalquantity.h \
pqfrequency.h \
pqbase.h \
pqspeed.h \
pqangle.h \
pqmass.h \
pqpressure.h \
pqtemperature.h \
simulator.h \
vector_3d.h \
vector_geo.h
@@ -52,15 +43,6 @@ SOURCES += \
multiplayer.cpp \
ned.cpp \
plane.cpp \
pqdistance.cpp \
pqphysicalquantity.cpp \
pqfrequency.cpp \
pqbase.cpp \
pqspeed.cpp \
pqangle.cpp \
pqmass.cpp \
pqpressure.cpp \
pqtemperature.cpp \
simulator.cpp \
vector_3d.cpp \
vector_geo.cpp \

14
src/blackmisc/blackmisc.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef BLACKMISC_H
#define BLACKMISC_H
// just a dummy header, namespace documentation will go here
/**
* @namespace BlackMisc
* BlackMisc is the namespace for generic utility classes. As of its nature
* (containing central classes such as CLogMessage, or CPhysicalQuantity),
* BlackMisc is available in any other compilation unit.
*/
#endif

View File

@@ -5,7 +5,6 @@ TEMPLATE = lib
CONFIG += staticlib
INCLUDEPATH += ..
DEPENDPATH += . ..
#PRECOMPILED_HEADER = stdpch.h
@@ -17,6 +16,7 @@ precompile_header:!isEmpty(PRECOMPILED_HEADER) {
DEFINES += LOG_IN_FILE
HEADERS += \
blackmisc.h \
logmessage.h \
log.h \
display.h \
@@ -26,22 +26,33 @@ HEADERS += \
config_manager.h \
serialize.h \
com_client.h \
com_handler.h \
com_server.h \
com_client_buffer.h \
message.h \
com_handler.h \
message_factory.h \
message_handler.h \
type_info.h \
message_dispatcher.h \
message_system.h \
gui_messages.h
gui_messages.h \
pqdistance.h \
pqphysicalquantity.h \
pqfrequency.h \
pqbase.h \
pqspeed.h \
pqangle.h \
pqmass.h \
pqpressure.h \
pqtemperature.h \
pqconstants.h
SOURCES += \
logmessage.cpp \
log.cpp \
display.cpp \
debug.cpp \
com_handler.cpp \
context.cpp \
config.cpp \
config_manager.cpp \
@@ -50,15 +61,20 @@ SOURCES += \
com_server.cpp \
com_client_buffer.cpp \
message.cpp \
com_handler.cpp \
message_factory.cpp \
message_handler.cpp \
type_info.cpp \
message_dispatcher.cpp \
message_system.cpp
message_system.cpp \
pqdistance.cpp \
pqphysicalquantity.cpp \
pqfrequency.cpp \
pqbase.cpp \
pqspeed.cpp \
pqangle.cpp \
pqmass.cpp \
pqpressure.cpp \
pqtemperature.cpp \
pqconstants.cpp
DESTDIR = ../../lib

View File

@@ -1,6 +1,6 @@
#include "pqangle.h"
#include "blackmisc/pqangle.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default constructor

View File

@@ -3,7 +3,7 @@
#include "pqphysicalquantity.h"
#include "math.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for angles (degrees, radian).

View File

@@ -1,6 +1,6 @@
#include "pqbase.h"
#include "blackmisc/pqbase.h"
namespace BlackCore {
namespace BlackMisc {
// -----------------------------------------------------------------------
// --- Mulitplier --------------------------------------------------------
@@ -78,6 +78,15 @@ QDebug operator<<(QDebug d, const CMeasurementPrefix &multiplier)
return d;
}
/**
* Log to debug
*/
CLogMessage operator<<(CLogMessage log, const CMeasurementPrefix &multiplier)
{
log << multiplier._name;
return log;
}
// -----------------------------------------------------------------------
// --- Measurement unit --------------------------------------------------
// -----------------------------------------------------------------------
@@ -132,14 +141,6 @@ bool CMeasurementUnit::operator ==(const CMeasurementUnit &otherUnit) const
&& this->_isSIUnit==otherUnit._isSIUnit;
}
/**
* Unequal operator
*/
bool CMeasurementUnit::operator !=(const CMeasurementUnit &otherUnit) const
{
return !(otherUnit == *this);
}
/**
* Stream to debug
*/
@@ -149,6 +150,23 @@ QDebug operator <<(QDebug d, const CMeasurementUnit &unit)
return d;
}
/**
* Stream to log
*/
CLogMessage operator<<(CLogMessage log, const CMeasurementUnit &unit)
{
log << unit._name;
return log;
}
/**
* Unequal operator
*/
bool CMeasurementUnit::operator !=(const CMeasurementUnit &otherUnit) const
{
return !(otherUnit == *this);
}
/**
* Conversion factor from unit x to y
*/

View File

@@ -8,8 +8,9 @@
#include <QString>
#include <QtGlobal>
#include <QDebug>
#include "blackmisc/debug.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Typical prefixes (multipliers) such as kilo, mega, hecto.
@@ -25,6 +26,14 @@ class CMeasurementPrefix {
* \return
*/
friend QDebug operator<<(QDebug d, const CMeasurementPrefix &multiplier);
/*!
* Stream operator for log messages
* \brief operator <<
* \param log
* \param multiplier
* \return
*/
friend CLogMessage operator<<(CLogMessage log, const CMeasurementPrefix &multiplier);
private:
QString _name; //!< name, e.g. "kilo"
@@ -155,6 +164,15 @@ class CMeasurementUnit {
*/
friend QDebug operator<<(QDebug d, const CMeasurementUnit &unit);
/*!
* Stream operator for log messages
* \brief operator <<
* \param log
* \param unit
* \return
*/
friend CLogMessage operator<<(CLogMessage log, const CMeasurementUnit &unit);
private:
QString _name; //!< name, e.g. "meter"
QString _unitName; //!< unit name, e.g. "m"
@@ -275,6 +293,6 @@ public:
static CMeasurementUnit& None() { static CMeasurementUnit none("none", "", "", false, false, 0.0, CMeasurementPrefix::None(), 0, 0); return none;}
};
} // namespace BlackCore
} // namespace BlackMisc
#endif // PQBASE_H

View File

@@ -0,0 +1,7 @@
#include "blackmisc/pqconstants.h"
namespace BlackMisc {
// no code here, all in header
} // namespace

View File

@@ -0,0 +1,40 @@
#ifndef PQCONSTANTS_H
#define PQCONSTANTS_H
#include "blackmisc/blackmisc.h"
#include "blackmisc/pqdistance.h"
#include "blackmisc/pqfrequency.h"
#include "blackmisc/pqspeed.h"
#include "blackmisc/pqangle.h"
#include "blackmisc/pqmass.h"
#include "blackmisc/pqpressure.h"
#include "blackmisc/pqtemperature.h"
namespace BlackMisc{
class CPhysicalQuantitiesConstants
{
public:
/*!
* \brief Temperature absolute Zero in °C
* \return
*/
static CTemperature& TemperatureAbsoluteZero() { static CTemperature t(-273.15, CTemperatureUnit::C()); return t;}
/*!
* \brief Tripe point of purified water, 0.01°C
* \return
*/
static CTemperature& TemperatureTriplePointOfVSMOW() { static CTemperature t(-273.16, CTemperatureUnit::K()); return t;}
/*!
* \brief Temperature absolute Zero in °C
* \return
*/
static CTemperature& TemperatureAbsoluteZeroC() { static CTemperature t(-273.15, CTemperatureUnit::C()); return t;}
/*!
* \brief Standard pressure 1013,25mbar / 29.92inHg
* \return
*/
static CPressure& InternationalStandardSeaLevelPressure() { static CPressure p(1013.25, CPressureUnit::hPa()); return p;}
};
} // namespace
#endif // PQCONSTANTS_H

View File

@@ -1,6 +1,6 @@
#include "pqdistance.h"
#include "blackmisc/pqdistance.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default Constructor

View File

@@ -2,7 +2,7 @@
#define PQDISTANCE_H
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for distance units (meter, foot, nautical miles).

View File

@@ -1,6 +1,6 @@
#include "pqfrequency.h"
#include "blackmisc/pqfrequency.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default constructor

View File

@@ -2,7 +2,7 @@
#define PQFREQUENCY_H
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for frequency (hertz, mega hertz, kilo hertz).

View File

@@ -1,6 +1,6 @@
#include "pqmass.h"
#include "blackmisc/pqmass.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default Constructor

View File

@@ -2,7 +2,7 @@
#define PQMASS_H
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for mass units (kg, lbs).

View File

@@ -1,6 +1,6 @@
#include "pqPhysicalQuantity.h"
#include "blackmisc/pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Constructor by integer
@@ -40,6 +40,16 @@ QDebug operator <<(QDebug d, const CPhysicalQuantity &quantity)
return d;
}
/**
* Stream operator
*/
CLogMessage operator <<(CLogMessage d, const CPhysicalQuantity &quantity)
{
QString v = quantity.unitValueRoundedWithUnit(-1);
d << v;
return d;
}
/**
* Equal operator ==
*/
@@ -234,7 +244,7 @@ bool CPhysicalQuantity::operator <=(const CPhysicalQuantity &otherQuantity) cons
/**
* Switch to another unit
*/
bool CPhysicalQuantity::switchUnit(const BlackCore::CMeasurementUnit &unit)
bool CPhysicalQuantity::switchUnit(const CMeasurementUnit &unit)
{
if (this->_unit == unit) return true;
if (this->_unit.getType() != unit.getType()) return false; // not possible

View File

@@ -4,9 +4,10 @@
#include <QtGlobal>
#include <QString>
#include <QLocale>
#include "pqbase.h"
#include "blackmisc/pqbase.h"
#include "blackmisc/debug.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* \brief A physical quantity such as "5m", "20s", "1500ft/s"
@@ -22,6 +23,14 @@ class CPhysicalQuantity
* \return
*/
friend QDebug operator<<(QDebug debug, const CPhysicalQuantity &quantity);
/*!
* Stream operator for log messages
* \brief operator <<
* \param log
* \param quantity
* \return
*/
friend CLogMessage operator<<(CLogMessage log, const CPhysicalQuantity &quantity);
private:
qint32 _unitValueI; //!< value backed by integer, allows sole integer arithmetic

View File

@@ -1,6 +1,6 @@
#include "pqpressure.h"
#include "blackmisc/pqpressure.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default constructor

View File

@@ -3,7 +3,7 @@
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for pressure (psi, hPa, bar).

View File

@@ -1,6 +1,6 @@
#include "pqspeed.h"
#include "blackmisc/pqspeed.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default constructor

View File

@@ -2,7 +2,7 @@
#define CSPEED_H
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for speed units (m/s, ft/s, NM/h).

View File

@@ -1,6 +1,6 @@
#include "pqtemperature.h"
#include "blackmisc/pqtemperature.h"
namespace BlackCore {
namespace BlackMisc {
/**
* Default Constructor

View File

@@ -2,7 +2,7 @@
#define CTEMPERATURE_H
#include "pqphysicalquantity.h"
namespace BlackCore {
namespace BlackMisc {
/*!
* Specialized class for temperatur units (kelvin, centidegree).
@@ -23,7 +23,7 @@ public:
* \param epsilon
*/
CTemperatureUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
CMeasurementUnit(name, unitName, "distance", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
CMeasurementUnit(name, unitName, "temperature", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
/*!
* Downcast copy constructor, allows to implement methods in base class
* \param otherUnit
@@ -42,7 +42,7 @@ public:
};
/*!
* \brief Physical unit distance
* \brief Physical unit temperature
* \author KWB
*/
class CTemperature : public CPhysicalQuantity
@@ -55,7 +55,7 @@ public:
/**
*\brief downcast copy constructor
*/
CTemperature(const CPhysicalQuantity &distance);
CTemperature(const CPhysicalQuantity &temperature);
/*!
* \brief Init by int value
* \param value
@@ -69,7 +69,7 @@ public:
*/
CTemperature(double value, const CTemperatureUnit &unit = CTemperatureUnit::K());
/*!
* \brief Unit of the distance
* \brief Unit of the temperature
* \return
*/
CTemperatureUnit getUnit() const { return this->_unit; }
@@ -79,6 +79,6 @@ public:
*/
CTemperatureUnit getConversionSiUnit() const { return this->_conversionSiUnit; }
};
} // namespace blackCore
} // namespace
#endif // CTEMPERATURE_H

6
src/mainpage.dox Normal file
View File

@@ -0,0 +1,6 @@
/**
\mainpage VATSIM client project, aka black mystery
This is the Doxygen main page for the file,please write something useful here!
*/

View File

@@ -2,8 +2,15 @@
#include <QDebug>
#include "testmain.h"
using namespace BlackCoreTest;
using namespace BlackMiscTest;
/*!
* Starter for testcases
* \brief main
* \param argc
* \param argv
* \return
*/
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

View File

@@ -1,25 +1,25 @@
QT += core testlib
QT -= gui
TARGET = test_blackcore
TARGET = test_blackmisc
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
DEPENDPATH += . ../../src/blackcore
INCLUDEPATH += . ../../src/blackcore
DEPENDPATH += . ../../src
INCLUDEPATH += . ../../src
SOURCES += main.cpp testmain.cpp testphysicalquantitiesbase.cpp
HEADERS += testmain.h testphysicalquantitiesbase.h
win32-msvc* {
PRE_TARGETDEPS += ../../lib/blackcore.lib
LIBS += ../../lib/blackcore.lib
PRE_TARGETDEPS += ../../lib/blackmisc.lib
LIBS += ../../lib/blackmisc.lib
}
!win32-msvc* {
PRE_TARGETDEPS += ../../lib/libblackcore.a
LIBS += ../../lib/libblackcore.a
PRE_TARGETDEPS += ../../lib/libblackmisc.a
LIBS += ../../lib/libblackmisc.a
}
DESTDIR = ../../bin

View File

@@ -1,6 +1,6 @@
#include "testmain.h"
namespace BlackCoreTest {
namespace BlackMiscTest {
//! Starting main, equivalent to QTEST_APPLESS_MAIN for multiple test classes.
/*! \param argc

View File

@@ -4,11 +4,7 @@
#include <QtTest/QtTest>
#include "testphysicalquantitiesbase.h"
using namespace BlackCore;
using namespace BlackCoreTest;
namespace BlackCoreTest{
namespace BlackMiscTest{
/*!
* Class firing of all unit tests in this namespace.

View File

@@ -1,6 +1,6 @@
#include "testphysicalquantitiesbase.h"
namespace BlackCoreTest {
namespace BlackMiscTest {
/*!
* \brief Constructor

View File

@@ -2,15 +2,10 @@
#define TESTPHYSICALQUANTITIESBASE_H
#include <QtTest/QtTest>
#include "../../src/blackcore/pqdistance.h"
#include "../../src/blackcore/pqfrequency.h"
#include "../../src/blackcore/pqspeed.h"
#include "../../src/blackcore/pqangle.h"
#include "../../src/blackcore/pqmass.h"
#include "../../src/blackcore/pqpressure.h"
using namespace BlackCore;
#include "blackmisc/pqconstants.h"
using namespace BlackMisc;
namespace BlackCoreTest {
namespace BlackMiscTest {
/*!
* \brief Physical quantities,basic tests
@@ -53,12 +48,10 @@ private slots:
* \brief Testing pressure
*/
void pressureTests();
/*!
* \brief testing construction / destruction in memory
*/
void memoryTests();
};
}