File indexing completed on 2024-05-05 16:49:20

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #pragma once
0007 #include <QObject>
0008 #include <QDateTime>
0009 #include <vector>
0010 #include <memory>
0011 #include "kweathercore/kweathercore_export.h"
0012 namespace KWeatherCore
0013 {
0014 class AlertInfo;
0015 /**
0016  * @short Class represents single CAP
0017  *
0018  * This class contains the information of a parsed
0019  * CAP file
0020  * @see AlertInfo
0021  *
0022  * @author Anjani Kumar <anjanik012@gmail.com>
0023  */
0024 class KWEATHERCORE_EXPORT AlertEntry
0025 {
0026     Q_GADGET
0027     Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier)
0028     Q_PROPERTY(QString sender READ sender WRITE setSender)
0029     Q_PROPERTY(QDateTime sentTime READ sentTime WRITE setSentTime)
0030     Q_PROPERTY(QString note READ note WRITE setNote)
0031 public:
0032     enum class Status {
0033         Unknown,
0034         Actual,
0035         Exercise,
0036         System,
0037         Test,
0038         Draft
0039     };
0040     enum class MsgType {
0041         Unknown,
0042         Alert,
0043         Update,
0044         Cancel,
0045         Ack,
0046         Error
0047     };
0048     enum class Scope {
0049         Unknown,
0050         Public,
0051         Restricted,
0052         Private
0053     };
0054     /**
0055      * Default constructor, Status, MsgType, Scope
0056      * are set to Unknown
0057      */
0058     AlertEntry();
0059     /**
0060      * Copy Constructor
0061      */
0062     AlertEntry(const AlertEntry &other);
0063     /**
0064      * overloaded copy constructor
0065      */
0066     AlertEntry(AlertEntry &&other);
0067     ~AlertEntry();
0068 
0069     /**
0070      * identifier of CAP
0071      */
0072     const QString &identifier() const;
0073     /**
0074      * CAP file sender
0075      */
0076     const QString &sender() const;
0077     /**
0078      * sentTime of CAP
0079      * @return
0080      */
0081     const QDateTime &sentTime() const;
0082     /**
0083      * status enum, initilized to Unknown
0084      */
0085     Status status() const;
0086     /**
0087      * msgType enum, initilized to Unknown
0088      */
0089     MsgType msgType() const;
0090     /**
0091      * scope enum, initilized to Unknown
0092      */
0093     Scope scope() const;
0094     /**
0095      * note of CAP
0096      */
0097     const QString &note() const;
0098     /**
0099      * the parsed info entries in CAP
0100      * see @AlertInfo
0101      */
0102     const std::vector<AlertInfo> &infoVec() const;
0103 
0104     void setIdentifier(const QString &identifier);
0105     void setSender(const QString &sender);
0106     void setSentTime(const QDateTime &dateTime);
0107     void setStatus(Status status);
0108     void setMsgType(MsgType msgType);
0109     void setScope(Scope scope);
0110     void setNote(const QString &note);
0111     void setInfoVec(const std::vector<AlertInfo> &infoVec);
0112     void setInfoVec(std::vector<AlertInfo> &&infoVec);
0113     void addInfo(const AlertInfo &alertInfo);
0114     void addInfo(AlertInfo &&alertInfo);
0115     AlertEntry &operator=(const AlertEntry &other);
0116     AlertEntry &operator=(AlertEntry &&other);
0117 private:
0118     class AlertEntryPrivate;
0119     std::unique_ptr<AlertEntryPrivate> d;
0120 };
0121 }