KWeatherCore

capalertinfo.h
1/*
2 * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
3 * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#pragma once
7#include "capnamedvalue.h"
8#include "kweathercore/kweathercore_export.h"
9#include <QDateTime>
10#include <QObject>
11#include <QString>
12#include <tuple>
13#include <vector>
14
15namespace KWeatherCore
16{
17class CAPAlertInfoPrivate;
18class CAPArea;
19/**
20 * @short Represents a single CAP alert message info element.
21 *
22 * @see CAPAlertMessage
23 * @see https://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2.html ยง3.2.2
24 * @author Han Young <hanyoung@protonmail.com>
25 * @author Anjani Kumar <anjanik012@gmail.com>
26 */
27class KWEATHERCORE_EXPORT CAPAlertInfo
28{
29 Q_GADGET
30 Q_PROPERTY(QString headline READ headline)
31 Q_PROPERTY(QString description READ description)
32 Q_PROPERTY(QString event READ event)
33 Q_PROPERTY(QDateTime effectiveTime READ effectiveTime)
34 Q_PROPERTY(QDateTime onsetTime READ onsetTime)
35 Q_PROPERTY(QDateTime expireTime READ expireTime)
36 Q_PROPERTY(Categories categories READ categories)
37 Q_PROPERTY(Urgency urgency READ urgency)
38 Q_PROPERTY(Severity severity READ severity)
39 Q_PROPERTY(Certainty certainty READ certainty)
40 Q_PROPERTY(QString sender READ sender)
41 Q_PROPERTY(QString instruction READ instruction)
42 Q_PROPERTY(QString language READ language)
43 Q_PROPERTY(ResponseTypes responseTypes READ responseTypes)
44 Q_PROPERTY(QString contact READ contact)
45 Q_PROPERTY(QString web READ web)
46
47public:
48 enum class Category {
49 Unknown = 0,
50 Geophysical = 0b1,
51 Meteorological = 0b10,
52 Safety = 0b100,
53 Security = 0b1000,
54 Rescue = 0b10000,
55 Fire = 0b100000,
56 Health = 0b1000000,
57 Environmental = 0b10000000,
58 Transport = 0b100000000,
59 Infrastructure = 0b1000000000,
60 CBRNE = 0b10000000000,
61 Other = 0b100000000000
62 };
63 Q_DECLARE_FLAGS(Categories, Category)
64 Q_FLAG(Categories)
65 enum class Urgency { Immediate, Expected, Future, Past, UnknownUrgency };
66 Q_ENUM(Urgency)
67 enum class Severity { Extreme, Severe, Moderate, Minor, UnknownSeverity };
68 Q_ENUM(Severity)
69 enum class Certainty { Observed, Likely, Possible, Unlikely, UnknownCertainty };
70 Q_ENUM(Certainty)
71
72 enum class ResponseType {
73 UnknownResponseType = 0,
74 Shelter = 1 << 0,
75 Evacuate = 1 << 1,
76 Prepare = 1 << 2,
77 Execute = 1 << 3,
78 Avoid = 1 << 4,
79 Monitor = 1 << 5,
80 Assess = 1 << 6,
81 AllClear = 1 << 7,
82 None = 1 << 8,
83 };
84 Q_DECLARE_FLAGS(ResponseTypes, ResponseType)
85 Q_FLAG(ResponseTypes)
86
88 CAPAlertInfo(const CAPAlertInfo &other);
91 /**
92 * The text denoting the type of the subject
93 * event of the alert message
94 */
95 QString event() const;
96 /**
97 * The effective time of the information of the alert message
98 */
99 QDateTime effectiveTime() const;
100 /**
101 * The onset time of the information of the alert message
102 */
103 QDateTime onsetTime() const;
104 /**
105 * The expire time of the information of the alert message
106 */
107 QDateTime expireTime() const;
108 /**
109 * The text headline of the alert message
110 */
111 QString headline() const;
112 /**
113 * The description of the alert message
114 */
115 QString description() const;
116 /**
117 * The instruction of the alert message
118 */
119 QString instruction() const;
120 /**
121 * The sender of the alert message
122 */
123 QString sender() const;
124 /**
125 * The code denoting the language of the info
126 * default to "en-US"
127 * @return Natural language identifier per [RFC 3066].
128 */
129 QString language() const;
130 /**
131 * The category of the alert message
132 * @return default to Unknown, value is bit or-ed
133 */
134 Categories categories() const;
135 /**
136 * The urgency of the alert message
137 * @return default to UnknownUrgency
138 */
139 Urgency urgency() const;
140 /**
141 * The severity of the alert message
142 * @return default to UnknownSeverity
143 */
144 Severity severity() const;
145 /**
146 * The certainty of the alert message
147 * @return default to UnknownCertainty
148 */
149 Certainty certainty() const;
150 /**
151 * Type of action recommended for the target audience of the alert.
152 */
153 ResponseTypes responseTypes() const;
154 /**
155 * Describing the contact for follow-up and confirmation of the alert message.
156 */
157 QString contact() const;
158 /**
159 * Link associating additional information with the alert message.
160 */
161 QString web() const;
162 /**
163 * The Parameter of the alert message
164 * refer to CAP protocol v1.2
165 */
166 const std::vector<CAPNamedValue> &parameters() const;
167 /** The areas targeted by this CAP alert message. */
168 const std::vector<CAPArea> &areas() const;
169 /** System-specific codes for event typing. */
170 const std::vector<CAPNamedValue> &eventCodes() const;
171
172 ///@cond internal
173 void setHeadline(const QString &headline);
174 void setDescription(const QString &description);
175 void setInstruction(const QString &instruction);
176 void setSender(const QString &sender);
177 void setLanguage(const QString &language);
178 void addCategory(Category category);
179 void setEvent(const QString &event);
180 void setEffectiveTime(const QDateTime &time);
181 void setOnsetTime(const QDateTime &time);
182 void setExpireTime(const QDateTime &time);
183 void setUrgency(Urgency urgency);
184 void setSeverity(Severity severity);
185 void setCertainty(Certainty certainty);
186 void addResponseType(ResponseType responseType);
187 void setContact(const QString &contact);
188 void setWeb(const QString &web);
189 void addParameter(CAPNamedValue &&param);
190 void addArea(CAPArea &&area);
191 void addEventCode(CAPNamedValue &&code);
192 ///@endcond
193
194 CAPAlertInfo &operator=(const CAPAlertInfo &other);
195 CAPAlertInfo &operator=(CAPAlertInfo &&other);
196
197private:
199};
200}
201
202Q_DECLARE_OPERATORS_FOR_FLAGS(KWeatherCore::CAPAlertInfo::Categories)
203Q_DECLARE_OPERATORS_FOR_FLAGS(KWeatherCore::CAPAlertInfo::ResponseTypes)
Represents a single CAP alert message info element.
Affected area of a CAP alert message.
Definition caparea.h:53
CAP key/value pairs as found in area geo codes, alert event codes or alert parameters.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.