KWeatherCore

alertinfo.cpp
1 /*
2  * SPDX-FileCopyrightText: 2021 Han Young <[email protected]>
3  * SPDX-FileCopyrightText: 2021 Anjani Kumar <[email protected]>
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #include "alertinfo.h"
7 namespace KWeatherCore
8 {
9 class AlertInfo::AlertInfoPrivate
10 {
11 public:
14  QString event;
16  QString language = QStringLiteral("en-US"); // default value according to CAP specification
20  Category category = Category::Unknown;
22  Urgency urgency = Urgency::Unknown;
23  Severity severity = Severity::Unknown;
24  Certainty certainty = Certainty::Unknown;
25  Parameter parameter;
27  AreaCodeVec areaCodes;
28  std::vector<std::vector<std::pair<float, float>>> polygon;
29 };
31  : d(std::make_unique<AlertInfoPrivate>())
32 {
33 }
34 AlertInfo::AlertInfo(const AlertInfo &other)
35  : d(std::make_unique<AlertInfoPrivate>(*other.d))
36 {
37 }
38 AlertInfo::AlertInfo(AlertInfo &&other) = default;
39 AlertInfo::~AlertInfo() = default;
40 AlertInfo &AlertInfo::operator=(AlertInfo &&other) = default;
41 
42 const QString &AlertInfo::event() const
43 {
44  return d->event;
45 }
46 const AreaCodeVec &AlertInfo::areaCodes() const
47 {
48  return d->areaCodes;
49 }
51 {
52  return d->effectiveTime;
53 }
55 {
56  return d->onsetTime;
57 }
58 const QDateTime &AlertInfo::expireTime() const
59 {
60  return d->expireTime;
61 }
62 AlertInfo::Category AlertInfo::category() const
63 {
64  return d->category;
65 }
66 const QString &AlertInfo::headline() const
67 {
68  return d->headline;
69 }
70 const QString &AlertInfo::description() const
71 {
72  return d->description;
73 }
75 {
76  return d->instruction;
77 }
78 const QString &AlertInfo::sender() const
79 {
80  return d->sender;
81 }
83 {
84  return d->language;
85 }
86 AlertInfo::Urgency AlertInfo::urgency() const
87 {
88  return d->urgency;
89 }
90 AlertInfo::Severity AlertInfo::severity() const
91 {
92  return d->severity;
93 }
94 AlertInfo::Certainty AlertInfo::certainty() const
95 {
96  return d->certainty;
97 }
98 const Parameter &AlertInfo::parameter() const
99 {
100  return d->parameter;
101 }
103 {
104  return d->areaDesc;
105 }
106 const std::vector<std::vector<std::pair<float, float>>> &AlertInfo::polygon() const
107 {
108  return d->polygon;
109 }
110 void AlertInfo::setHeadline(const QString &headline)
111 {
112  d->headline = headline;
113 }
114 void AlertInfo::setDescription(const QString &description)
115 {
116  d->description = description;
117 }
118 void AlertInfo::setInstruction(const QString &instruction)
119 {
120  d->instruction = instruction;
121 }
122 void AlertInfo::setSender(const QString &sender)
123 {
124  d->sender = sender;
125 }
126 void AlertInfo::setLanguage(const QString &language)
127 {
128  d->language = language;
129 }
130 void AlertInfo::setCategory(Category category)
131 {
132  d->category = category;
133 }
134 void AlertInfo::addCategory(Category category)
135 {
136  d->category |= category;
137 }
138 void AlertInfo::setEvent(const QString &event)
139 {
140  d->event = event;
141 }
142 void AlertInfo::setAreaCodes(const AreaCodeVec &areaCodes)
143 {
144  d->areaCodes = areaCodes;
145 }
146 void AlertInfo::addAreaCode(std::pair<QString, QString> &areaCode)
147 {
148  d->areaCodes.push_back(areaCode);
149 }
150 
151 void AlertInfo::setEffectiveTime(const QDateTime &time)
152 {
153  d->effectiveTime = time;
154 }
155 void AlertInfo::setOnsetTime(const QDateTime &time)
156 {
157  d->onsetTime = time;
158 }
159 void AlertInfo::setExpireTime(const QDateTime &time)
160 {
161  d->expireTime = time;
162 }
163 void AlertInfo::setUrgency(Urgency urgency)
164 {
165  d->urgency = urgency;
166 }
167 void AlertInfo::setSeverity(Severity severity)
168 {
169  d->severity = severity;
170 }
171 void AlertInfo::setCertainty(Certainty certainty)
172 {
173  d->certainty = certainty;
174 }
175 void AlertInfo::setParameter(const Parameter &parameter)
176 {
177  d->parameter = parameter;
178 }
179 void AlertInfo::addParameter(std::pair<QString, QString> &p)
180 {
181  d->parameter.push_back(p);
182 }
183 
184 void AlertInfo::setAreaDesc(const QString &areaDesc)
185 {
186  d->areaDesc = areaDesc;
187 }
188 void AlertInfo::setPolygon(const std::vector<std::vector<std::pair<float, float>>> &polygon)
189 {
190  d->polygon = polygon;
191 }
192 void AlertInfo::setPolygon(std::vector<std::vector<std::pair<float, float>>> &&polygon)
193 {
194  d->polygon = std::move(polygon);
195 }
196 void AlertInfo::addPolygon(const std::vector<std::pair<float, float>> &area)
197 {
198  d->polygon.push_back(area);
199 }
200 void AlertInfo::addPolygon(std::vector<std::pair<float, float>> &&area)
201 {
202  d->polygon.emplace_back(area);
203 }
204 AlertInfo &AlertInfo::operator=(const AlertInfo &other)
205 {
206  *d = *other.d;
207  return *this;
208 }
209 }
Class represents single CAP.
Definition: alertinfo.h:27
Urgency urgency() const
The urgency of the alert message.
Definition: alertinfo.cpp:86
const QDateTime & expireTime() const
The expire time of the information of the alert message.
Category category() const
The category of the alert message.
Definition: alertinfo.cpp:62
const QDateTime & onsetTime() const
The onset time of the information of the alert message.
Definition: alertinfo.cpp:54
const QDateTime & effectiveTime() const
The effective time of the information of the alert message.
AlertInfo()
default constructor
Definition: alertinfo.cpp:30
Certainty certainty() const
The certainty of the alert message.
Definition: alertinfo.cpp:94
const QString & headline() const
The text headline of the alert message.
const QString & instruction() const
The instruction of the alert message.
Definition: alertinfo.cpp:74
Severity severity() const
The severity of the alert message.
Definition: alertinfo.cpp:90
const std::vector< std::vector< std::pair< float, float > > > & polygon() const
area polygon
Definition: alertinfo.cpp:106
const QString & event() const
The text denoting the type of the subject event of the alert message.
const AreaCodeVec & areaCodes() const
areaCodes
Definition: alertinfo.cpp:46
const Parameter & parameter() const
The Parameter of the alert message refer to CAP protocol v1.2.
Definition: alertinfo.cpp:98
const QString & sender() const
The sender of the alert message.
Definition: alertinfo.cpp:78
const QString & areaDesc() const
Text describe the area of the alert message.
Definition: alertinfo.cpp:102
const QString & language() const
The code denoting the language of the info default to "en-US".
Definition: alertinfo.cpp:82
const QString & description() const
The description of the alert message.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:05:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.