File indexing completed on 2024-12-29 04:50:10
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "kitinerary_export.h" 0010 #include "alphaid.h" 0011 0012 #include <QMetaType> 0013 0014 #include <cstdint> 0015 0016 0017 namespace KItinerary { 0018 namespace KnowledgeDb { 0019 KITINERARY_EXPORT Q_NAMESPACE 0020 0021 /** ISO 3166-1 alpha 2 country identifier. */ 0022 using CountryId = AlphaId<uint16_t, 2>; 0023 0024 /** Driving side. */ 0025 enum class DrivingSide : uint8_t { 0026 Unknown, 0027 Left, 0028 Right, 0029 }; 0030 Q_ENUM_NS(DrivingSide) 0031 0032 /** Power plug types. 0033 * @note This cannot be an enum class due to QTBUG-47652. 0034 */ 0035 enum PowerPlugType : uint16_t { 0036 Unknown = 0, 0037 TypeA = 1 << 0, ///< US two-pin plugs 0038 TypeB = 1 << 1, ///< US three-pin plugs 0039 TypeC = 1 << 2, ///< Europlug 0040 TypeD = 1 << 3, ///< Type D 0041 TypeE = 1 << 4, ///< French plug 0042 TypeF = 1 << 5, ///< Schuko plug 0043 TypeG = 1 << 6, ///< UK plug 0044 TypeH = 1 << 7, ///< Israel plug 0045 TypeI = 1 << 8, ///< Australian plug 0046 TypeJ = 1 << 9, ///< Swiss plug 0047 TypeK = 1 << 10, ///< Danish plug 0048 TypeL = 1 << 11, ///< Type L 0049 TypeM = 1 << 12, ///< Type M 0050 TypeN = 1 << 13, ///< Type N (Brasilian) 0051 }; 0052 0053 Q_DECLARE_FLAGS(PowerPlugTypes, PowerPlugType) 0054 Q_DECLARE_OPERATORS_FOR_FLAGS(PowerPlugTypes) 0055 Q_FLAG_NS(PowerPlugTypes) 0056 0057 /** Returns the power plugs out of @p plugs that won't fit into @p sockets. */ 0058 KITINERARY_EXPORT PowerPlugTypes incompatiblePowerPlugs(PowerPlugTypes plugs, PowerPlugTypes sockets); 0059 /** Returns the power sockets out pf @p sockets that are unable to receive plugs 0060 * out of @p plugs, excluding those in @p plugs. 0061 */ 0062 KITINERARY_EXPORT PowerPlugTypes incompatiblePowerSockets(PowerPlugTypes plugs, PowerPlugTypes sockets); 0063 0064 /** Country information. */ 0065 struct Country 0066 { 0067 CountryId id; 0068 DrivingSide drivingSide; 0069 PowerPlugTypes powerPlugTypes; 0070 // TODO voltage/frequency 0071 }; 0072 0073 0074 /** Look up country information by id. */ 0075 KITINERARY_EXPORT Country countryForId(CountryId id); 0076 0077 /** Look up country ISO code from a UIC country code. */ 0078 KITINERARY_EXPORT CountryId countryIdForUicCode(uint16_t uicCountryCode); 0079 0080 } 0081 } 0082 0083 Q_DECLARE_METATYPE(KItinerary::KnowledgeDb::DrivingSide) 0084 Q_DECLARE_METATYPE(KItinerary::KnowledgeDb::PowerPlugTypes) 0085