Propagate FacilityType and LoginMode to value objects

This commit is contained in:
Roland Rossgotterer
2019-09-13 11:07:38 +02:00
parent 4772aadc1a
commit fa6e7108c7
21 changed files with 243 additions and 56 deletions

View File

@@ -0,0 +1,36 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "blackmisc/network/facilitytype.h"
namespace BlackMisc
{
namespace Network
{
QString CFacilityType::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
switch (m_facilityType)
{
case OBS: return QStringLiteral("OBS");
case FSS: return QStringLiteral("FSS");
case DEL: return QStringLiteral("DEL");
case GND: return QStringLiteral("GND");
case TWR: return QStringLiteral("TWR");
case APP: return QStringLiteral("APP");
case CTR: return QStringLiteral("CTR");
case Unknown: return QStringLiteral("Unknown");
}
Q_UNREACHABLE();
return {};
}
} // namespace
} // namespace

View File

@@ -0,0 +1,66 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_NETWORK_FACILITYTYPE_H
#define BLACKMISC_NETWORK_FACILITYTYPE_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/valueobject.h"
namespace BlackMisc
{
namespace Network
{
//! Value object encapsulating the ATC facility type, e.g. TWR, DEP, APP
class BLACKMISC_EXPORT CFacilityType : public CValueObject<CFacilityType>
{
public:
//! Login modes
enum FacilityType
{
OBS, /*!< OBS */
FSS, /*!< FSS */
DEL, /*!< Delivery */
GND, /*!< Ground */
TWR, /*!< Tower */
APP, /*!< Approach */
CTR, /*!< Center */
Unknown /*!< Unknown */
};
//! Default constructor.
CFacilityType() = default;
//! Constructor
CFacilityType(FacilityType mode) : m_facilityType(mode) {}
//! Get type
FacilityType getFacilityType() const { return m_facilityType; }
//! Set type
void setFacilityType(FacilityType type) { m_facilityType = type; }
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
private:
FacilityType m_facilityType = Unknown;
BLACK_METACLASS(
CFacilityType,
BLACK_METAMEMBER(facilityType)
);
};
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Network::CFacilityType)
#endif // guard

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "blackmisc/network/loginmode.h"
namespace BlackMisc
{
namespace Network
{
QString CLoginMode::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
switch (m_loginMode)
{
case Pilot: return QStringLiteral("Pilot");
case Observer: return QStringLiteral("Observer");
}
Q_UNREACHABLE();
return {};
}
} // namespace
} // namespace

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_NETWORK_LOGINMODE_H
#define BLACKMISC_NETWORK_LOGINMODE_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/valueobject.h"
namespace BlackMisc
{
namespace Network
{
//! Value object encapsulating information about login mode
class BLACKMISC_EXPORT CLoginMode : public CValueObject<CLoginMode>
{
public:
//! Login modes
enum LoginMode
{
Pilot, //!< Normal login
Observer, //!< Login as observer
};
//! Default constructor.
CLoginMode() = default;
//! Constructor
CLoginMode(LoginMode mode) : m_loginMode(mode) {}
bool isPilot() const { return m_loginMode == Pilot; }
bool isObserver() const { return m_loginMode == Observer; }
//! Get status
LoginMode getLoginMode() const { return m_loginMode; }
//! Set status
void setLoginMode(LoginMode mode) { m_loginMode = mode; }
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
private:
LoginMode m_loginMode = Pilot;
BLACK_METACLASS(
CLoginMode,
BLACK_METAMEMBER(loginMode)
);
};
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Network::CLoginMode)
#endif // guard

View File

@@ -23,7 +23,9 @@
#include "blackmisc/network/ecosystem.h"
#include "blackmisc/network/ecosystemlist.h"
#include "blackmisc/network/entityflags.h"
#include "blackmisc/network/facilitytype.h"
#include "blackmisc/network/fsdsetup.h"
#include "blackmisc/network/loginmode.h"
#include "blackmisc/network/rawfsdmessage.h"
#include "blackmisc/network/rawfsdmessagelist.h"
#include "blackmisc/network/role.h"

View File

@@ -24,7 +24,9 @@ namespace BlackMisc
CEcosystem::registerMetadata();
CEcosystemList::registerMetadata();
CEntityFlags::registerMetadata();
CFacilityType::registerMetadata();
CFsdSetup::registerMetadata();
CLoginMode::registerMetadata();
CRawFsdMessage::registerMetadata();
CRawFsdMessageList::registerMetadata();
CRemoteFile::registerMetadata();
@@ -44,6 +46,7 @@ namespace BlackMisc
CUserList::registerMetadata();
CVoiceCapabilities::registerMetadata();
Settings::CNetworkSettings::registerMetadata();
}
} // ns
} // ns