Removed template from basestreamstringifier as discussed in https://dev.vatsim-germany.org/boards/15/topics/497?r=503

This commit is contained in:
Klaus Basan
2013-05-10 22:56:36 +02:00
parent 7b3174fd96
commit abfd72552b
8 changed files with 31 additions and 16 deletions

View File

@@ -25,7 +25,7 @@ QString CAltitude::stringForConverter() const
/* /*
* Assigment * Assigment
*/ */
CAltitude& CAltitude::operator =(const CAltitude &otherAltitude) CAltitude &CAltitude::operator =(const CAltitude &otherAltitude)
{ {
// Check for self-assignment! // Check for self-assignment!
if (this == &otherAltitude) return *this; if (this == &otherAltitude) return *this;

View File

@@ -19,7 +19,7 @@ namespace Aviation
/*! /*!
* \brief Base class for avionics * \brief Base class for avionics
*/ */
class CAvionicsBase : public CBaseStreamStringifier<CAvionicsBase> class CAvionicsBase : public CBaseStreamStringifier
{ {
private: private:

View File

@@ -12,7 +12,7 @@ namespace BlackMisc
/*! /*!
* \brief Provides "to QString" and stream operators * \brief Provides "to QString" and stream operators
*/ */
template <class UsingClass> class CBaseStreamStringifier class CBaseStreamStringifier
{ {
/*! /*!
* \brief Stream << overload to be used in debugging messages * \brief Stream << overload to be used in debugging messages
@@ -20,13 +20,13 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend QDebug operator<<(QDebug debug, const UsingClass &uc) friend QDebug operator<<(QDebug debug, const CBaseStreamStringifier &uc)
{ {
const CBaseStreamStringifier &sf = uc; // allows to acces protected method const CBaseStreamStringifier &sf = uc; // allows to acces protected method
debug << sf.stringForStreaming(); debug << sf.stringForStreaming();
return debug; return debug;
} }
// msvc2010: friend QDebug &operator<<(QDebug &debug, const UsingClass &uc) // msvc2010: friend QDebug &operator<<(QDebug &debug, const CBaseStreamStringifier &uc)
// MinGW: No reference // MinGW: No reference
/*! /*!
@@ -35,7 +35,7 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend QTextStream &operator<<(QTextStream &textStream, const UsingClass &uc) friend QTextStream &operator<<(QTextStream &textStream, const CBaseStreamStringifier &uc)
{ {
const CBaseStreamStringifier &sf = uc; // allows to acces protected method const CBaseStreamStringifier &sf = uc; // allows to acces protected method
textStream << sf.stringForStreaming(); textStream << sf.stringForStreaming();
@@ -48,7 +48,7 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend QNoDebug operator<<(QNoDebug nodebug, const UsingClass &uc) friend QNoDebug operator<<(QNoDebug nodebug, const CBaseStreamStringifier & /* uc */)
{ {
return nodebug; return nodebug;
} }
@@ -59,7 +59,7 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend QDataStream &operator<<(QDataStream &stream, const UsingClass &uc) friend QDataStream &operator<<(QDataStream &stream, const CBaseStreamStringifier &uc)
{ {
const CBaseStreamStringifier &sf = uc; // allows to acces protected method const CBaseStreamStringifier &sf = uc; // allows to acces protected method
stream << sf.stringForStreaming(); stream << sf.stringForStreaming();
@@ -72,7 +72,7 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend CLogMessage operator<<(CLogMessage log, const UsingClass &uc) friend CLogMessage operator<<(CLogMessage log, const CBaseStreamStringifier &uc)
{ {
const CBaseStreamStringifier &sf = uc; // allows to acces protected method const CBaseStreamStringifier &sf = uc; // allows to acces protected method
log << sf.stringForStreaming(); log << sf.stringForStreaming();
@@ -85,7 +85,7 @@ template <class UsingClass> class CBaseStreamStringifier
* \param uc * \param uc
* \return * \return
*/ */
friend std::ostream &operator<<(std::ostream &ostr, const UsingClass &uc) friend std::ostream &operator<<(std::ostream &ostr, const CBaseStreamStringifier &uc)
{ {
const CBaseStreamStringifier &sf = uc; // allows to acces protected method const CBaseStreamStringifier &sf = uc; // allows to acces protected method
ostr << sf.stringForStreaming().toStdString(); ostr << sf.stringForStreaming().toStdString();

View File

@@ -37,7 +37,7 @@ class ICoordinateGeodetic
* \brief Geodetic coordinate * \brief Geodetic coordinate
*/ */
class CCoordinateGeodetic : class CCoordinateGeodetic :
public CBaseStreamStringifier<CCoordinateGeodetic>, public CBaseStreamStringifier,
public ICoordinateGeodetic public ICoordinateGeodetic
{ {

View File

@@ -18,7 +18,7 @@ namespace Math
/*! /*!
* \brief Base functionality of a matrix * \brief Base functionality of a matrix
*/ */
template<class ImplMatrix, int Rows, int Columns> class CMatrixBase : public BlackMisc::CBaseStreamStringifier<ImplMatrix> template<class ImplMatrix, int Rows, int Columns> class CMatrixBase : public BlackMisc::CBaseStreamStringifier
{ {
private: private:
/*! /*!

View File

@@ -21,7 +21,7 @@ class CMatrix3x1; // forward declaration
/*! /*!
* \brief 3D vector base (x, y, z) * \brief 3D vector base (x, y, z)
*/ */
template <class ImplVector> class CVector3DBase : public CBaseStreamStringifier<ImplVector> template <class ImplVector> class CVector3DBase : public CBaseStreamStringifier
{ {
private: private:

View File

@@ -23,7 +23,7 @@ namespace PhysicalQuantities
* Use the static values such CMeasurementMultiplier::k() as to specify values. * Use the static values such CMeasurementMultiplier::k() as to specify values.
* \author KWB * \author KWB
*/ */
class CMeasurementPrefix : public CBaseStreamStringifier<CMeasurementPrefix> class CMeasurementPrefix : public CBaseStreamStringifier
{ {
private: private:
QString m_name; //!< name, e.g. "kilo" QString m_name; //!< name, e.g. "kilo"
@@ -130,6 +130,14 @@ public:
return this->m_prefix; return this->m_prefix;
} }
/*!
* \brief Operator as double
*/
operator double() const
{
return this->m_factor;
}
// --- static units, always use these for initialization // --- static units, always use these for initialization
// --- Remark: Static initialization in C++ is random, this is why no static members // --- Remark: Static initialization in C++ is random, this is why no static members
// --- are used // --- are used
@@ -143,6 +151,7 @@ public:
static CMeasurementPrefix none("", "", 0.0); static CMeasurementPrefix none("", "", 0.0);
return none; return none;
} }
/*! /*!
* \brief Unit "One" * \brief Unit "One"
* \return * \return
@@ -152,6 +161,7 @@ public:
static CMeasurementPrefix one("one", "", 1.0); static CMeasurementPrefix one("one", "", 1.0);
return one; return one;
} }
/*! /*!
* \brief Unit "mega" * \brief Unit "mega"
* \return * \return
@@ -161,6 +171,7 @@ public:
static CMeasurementPrefix mega("mega", "M", 1E6); static CMeasurementPrefix mega("mega", "M", 1E6);
return mega; return mega;
} }
/*! /*!
* \brief Unit "kilo" * \brief Unit "kilo"
* \return * \return
@@ -170,6 +181,7 @@ public:
static CMeasurementPrefix kilo("kilo", "k", 1000.0); static CMeasurementPrefix kilo("kilo", "k", 1000.0);
return kilo; return kilo;
} }
/*! /*!
* \brief Unit "giga" * \brief Unit "giga"
* \return * \return
@@ -179,6 +191,7 @@ public:
static CMeasurementPrefix giga("giga", "G", 1E9); static CMeasurementPrefix giga("giga", "G", 1E9);
return giga; return giga;
} }
/*! /*!
* \brief Unit "hecto" * \brief Unit "hecto"
* \return * \return
@@ -188,6 +201,7 @@ public:
static CMeasurementPrefix hecto("hecto", "h", 100.0); static CMeasurementPrefix hecto("hecto", "h", 100.0);
return hecto; return hecto;
} }
/*! /*!
* \brief Unit "centi" * \brief Unit "centi"
* \return * \return
@@ -197,6 +211,7 @@ public:
static CMeasurementPrefix centi("centi", "c", 0.01); static CMeasurementPrefix centi("centi", "c", 0.01);
return centi; return centi;
} }
/*! /*!
* \brief Unit "milli" * \brief Unit "milli"
* \return * \return
@@ -216,7 +231,7 @@ public:
/*! /*!
* \brief Base class for all units, such as meter, hertz. * \brief Base class for all units, such as meter, hertz.
*/ */
class CMeasurementUnit: public CBaseStreamStringifier<CMeasurementUnit> class CMeasurementUnit: public CBaseStreamStringifier
{ {
protected: protected:
/*! /*!

View File

@@ -21,7 +21,7 @@ namespace PhysicalQuantities
/*! /*!
* \brief A physical quantity such as "5m", "20s", "1500ft/s" * \brief A physical quantity such as "5m", "20s", "1500ft/s"
*/ */
template <class MU, class PQ> class CPhysicalQuantity : public BlackMisc::CBaseStreamStringifier<PQ> template <class MU, class PQ> class CPhysicalQuantity : public BlackMisc::CBaseStreamStringifier
{ {
private: private:
double m_unitValueD; //!< value backed by double double m_unitValueD; //!< value backed by double