mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #403 extern templates
This commit is contained in:
@@ -22,6 +22,31 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
namespace Aviation
|
||||
{
|
||||
class CAircraftSituation;
|
||||
class CAircraftSituationList;
|
||||
class CAircraftParts;
|
||||
class CAircraftPartsList;
|
||||
class CAircraft;
|
||||
class CAircraftList;
|
||||
class CAtcStation;
|
||||
class CAtcStationList;
|
||||
}
|
||||
|
||||
namespace Simulation
|
||||
{
|
||||
class CSimulatedAircraft;
|
||||
class CSimulatedAircraftList;
|
||||
}
|
||||
|
||||
namespace Network
|
||||
{
|
||||
class CClient;
|
||||
class CClientList;
|
||||
}
|
||||
|
||||
namespace Aviation
|
||||
{
|
||||
//! List of objects with callsign.
|
||||
@@ -83,6 +108,13 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -85,6 +85,18 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO const *CModulator<AVIO>::derived() const
|
||||
{
|
||||
return static_cast<AVIO const *>(this);
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO *CModulator<AVIO>::derived()
|
||||
{
|
||||
return static_cast<AVIO *>(this);
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CModulator<CComSystem>;
|
||||
|
||||
@@ -22,6 +22,10 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
class CComSystem;
|
||||
class CNavSystem;
|
||||
class CAdfSystem;
|
||||
|
||||
//! Base class for COM, NAV, Squawk units.
|
||||
template <class AVIO> class CModulator : public CValueObject<CModulator<AVIO>, CAvionicsBase>
|
||||
{
|
||||
@@ -209,12 +213,16 @@ namespace BlackMisc
|
||||
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO const *derived() const { return static_cast<AVIO const *>(this); }
|
||||
AVIO const *derived() const;
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO *derived() { return static_cast<AVIO *>(this); }
|
||||
AVIO *derived();
|
||||
};
|
||||
|
||||
extern template class CModulator<CComSystem>;
|
||||
extern template class CModulator<CNavSystem>;
|
||||
extern template class CModulator<CAdfSystem>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,26 +244,6 @@ QVariant BlackMisc::complexQtTypeFromDbusArgument(const QDBusArgument &argument,
|
||||
return QVariant(); // suppress compiler warning
|
||||
}
|
||||
|
||||
template<class K, class V> QString BlackMisc::qmapToString(const QMap<K, V> &map)
|
||||
{
|
||||
QString s;
|
||||
const QString kv("%1: %2 ");
|
||||
QMapIterator<K, V> i(map);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
s.append(
|
||||
kv.arg(i.key()).arg(i.value())
|
||||
);
|
||||
}
|
||||
return s.trimmed();
|
||||
}
|
||||
|
||||
// forward declare: http://www.parashift.com/c++-faq-lite/separate-template-fn-defn-from-decl.html
|
||||
template QString BlackMisc::qmapToString<QString, int>(const QMap<QString, int> &);
|
||||
template QString BlackMisc::qmapToString<QString, QString>(const QMap<QString, QString> &);
|
||||
template QString BlackMisc::qmapToString<QString, double>(const QMap<QString, double> &);
|
||||
|
||||
#ifdef Q_CC_MSVC
|
||||
#include <crtdbg.h>
|
||||
|
||||
|
||||
@@ -169,7 +169,20 @@ namespace BlackMisc
|
||||
size_t heapSizeOf(const QMetaObject &objectType);
|
||||
|
||||
//! A map converted to string
|
||||
template<class K, class V> QString qmapToString(const QMap<K, V> &map);
|
||||
template<class K, class V> QString qmapToString(const QMap<K, V> &map)
|
||||
{
|
||||
QString s;
|
||||
const QString kv("%1: %2 ");
|
||||
QMapIterator<K, V> i(map);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
s.append(
|
||||
kv.arg(i.key()).arg(i.value())
|
||||
);
|
||||
}
|
||||
return s.trimmed();
|
||||
}
|
||||
|
||||
//! Bool to on/off
|
||||
QString boolToOnOff(bool v, bool i18n = false);
|
||||
|
||||
@@ -26,6 +26,10 @@ namespace BlackMisc
|
||||
|
||||
namespace Geo
|
||||
{
|
||||
|
||||
class CLatitude;
|
||||
class CLongitude;
|
||||
|
||||
/*!
|
||||
* Base class for latitude / longitude
|
||||
*/
|
||||
@@ -134,6 +138,10 @@ namespace BlackMisc
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
LATorLON *derived() { return static_cast<LATorLON *>(this); }
|
||||
};
|
||||
|
||||
extern template class CEarthAngle<CLatitude>;
|
||||
extern template class CEarthAngle<CLongitude>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,22 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
class CAtcStation;
|
||||
class CAtcStationList;
|
||||
class CAircraft;
|
||||
class CAircraftList;
|
||||
class CAirport;
|
||||
class CAirportList;
|
||||
}
|
||||
|
||||
namespace Simulation
|
||||
{
|
||||
class CSimulatedAircraft;
|
||||
class CSimulatedAircraftList;
|
||||
}
|
||||
|
||||
namespace Geo
|
||||
{
|
||||
//! List of objects with geo coordinates.
|
||||
@@ -45,6 +61,11 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
|
||||
//! List of objects with geo coordinates.
|
||||
template<class OBJ, class CONTAINER>
|
||||
class IGeoObjectWithRelativePositionList : public IGeoObjectList<OBJ, CONTAINER>
|
||||
@@ -71,6 +92,11 @@ namespace BlackMisc
|
||||
|
||||
};
|
||||
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -212,6 +212,16 @@ namespace BlackMisc
|
||||
this->m_value = json.value("value").toDouble();
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, mode);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorsCLocale);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
|
||||
@@ -26,7 +26,19 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities { template <class, class> class CPhysicalQuantity; }
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
template <class, class> class CPhysicalQuantity;
|
||||
class CLength;
|
||||
class CPressure;
|
||||
class CFrequency;
|
||||
class CMass;
|
||||
class CTemperature;
|
||||
class CSpeed;
|
||||
class CTime;
|
||||
class CPressure;
|
||||
class CAcceleration;
|
||||
}
|
||||
|
||||
//! \private
|
||||
template <class MU, class PQ> struct CValueObjectPolicy<PhysicalQuantities::CPhysicalQuantity<MU, PQ>> : public CValueObjectPolicy<>
|
||||
@@ -227,16 +239,10 @@ namespace BlackMisc
|
||||
virtual void convertFromJson(const QJsonObject &json) override;
|
||||
|
||||
//! Parse to string, with specified separator
|
||||
virtual void parseFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, mode);
|
||||
}
|
||||
virtual void parseFromString(const QString &value, CPqString::SeparatorMode mode);
|
||||
|
||||
//! \copydoc CValueObject::parseFromString
|
||||
virtual void parseFromString(const QString &value) override
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorsCLocale);
|
||||
}
|
||||
virtual void parseFromString(const QString &value) override;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
@@ -278,6 +284,17 @@ namespace BlackMisc
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
PQ *derived() { return static_cast<PQ *>(this); }
|
||||
};
|
||||
|
||||
extern template class CPhysicalQuantity<CLengthUnit, CLength>;
|
||||
extern template class CPhysicalQuantity<CPressureUnit, CPressure>;
|
||||
extern template class CPhysicalQuantity<CFrequencyUnit, CFrequency>;
|
||||
extern template class CPhysicalQuantity<CMassUnit, CMass>;
|
||||
extern template class CPhysicalQuantity<CTemperatureUnit, CTemperature>;
|
||||
extern template class CPhysicalQuantity<CSpeedUnit, CSpeed>;
|
||||
extern template class CPhysicalQuantity<CAngleUnit, CAngle>;
|
||||
extern template class CPhysicalQuantity<CTimeUnit, CTime>;
|
||||
extern template class CPhysicalQuantity<CAccelerationUnit, CAcceleration>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,24 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
class CAircraftSituation;
|
||||
class CAircraftSituationList;
|
||||
class CAircraftParts;
|
||||
class CAircraftPartsList;
|
||||
}
|
||||
|
||||
namespace Network
|
||||
{
|
||||
class CTextMessage;
|
||||
class CTextMessageList;
|
||||
}
|
||||
|
||||
class CStatusMessage;
|
||||
class CStatusMessageList;
|
||||
|
||||
|
||||
//! List of objects with timestamp.
|
||||
//! Such objects should implement \sa ITimestampBased
|
||||
template<class OBJ, class CONTAINER>
|
||||
@@ -83,6 +101,11 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class ITimestampObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif //guard
|
||||
|
||||
Reference in New Issue
Block a user