• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_DISTRIBUTED_BUNDLE_OPTION_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_DISTRIBUTED_BUNDLE_OPTION_H
18 
19 #include "notification_json_convert.h"
20 #include "notification_bundle_option.h"
21 #include "parcel.h"
22 
23 namespace OHOS {
24 namespace Notification {
25 class DistributedBundleOption : public Parcelable, public NotificationJsonConvertionBase {
26 public:
27     DistributedBundleOption() = default;
28 
29     /**
30      * @brief A constructor used to create a DistributedBundleOption instance based on the creator bundles and enable.
31      *
32      * @param bundles Indicates the bundles.
33      * @param enable Indicates the status.
34      */
35     DistributedBundleOption(std::shared_ptr<NotificationBundleOption> &bundle, const bool enable);
36 
37     virtual ~DistributedBundleOption();
38 
39     /**
40      * @brief Get bundle.
41      *
42      * @return Returns bundle info.
43      */
44     std::shared_ptr<NotificationBundleOption> GetBundle() const;
45 
46     /**
47      * @brief Sets bundle.
48      *
49      * @param bundle bundle info.
50      */
51     void SetBundle(std::shared_ptr<NotificationBundleOption> bundle);
52 
53     /**
54      * @brief Get enable.
55      *
56      * @return Returns enable value.
57      */
58     bool isEnable() const;
59 
60     /**
61      * @brief Sets enable.
62      *
63      * @param enable enable status.
64      */
65     void SetEnable(const bool& enable);
66 
67     /**
68      * @brief Returns a string representation of the object.
69      *
70      * @return Returns a string representation of the object.
71      */
72     std::string Dump();
73 
74     /**
75      * @brief Marshal a object into a Parcel.
76      *
77      * @param parcel Indicates the object into the parcel
78      * @return Returns true if succeed; returns false otherwise.
79      */
80     virtual bool Marshalling(Parcel &parcel) const override;
81 
82     /**
83      * @brief Unmarshal object from a Parcel.
84      *
85      * @param parcel Indicates the parcel object.
86      * @return Returns the DistributedBundleOption
87      */
88     static DistributedBundleOption *Unmarshalling(Parcel &parcel);
89 
90     /**
91      * @brief Converts a distributed bundle option object into a Json.
92      *
93      * @param jsonObject Indicates the Json object.
94      * @return Returns true if succeed; returns false otherwise.
95      */
96     bool ToJson(nlohmann::json &jsonObject) const override;
97 
98     /**
99      * @brief Creates a distributed bundle option object from a Json.
100      *
101      * @param jsonObject Indicates the Json object.
102      * @return Returns the DistributedBundleOption.
103      */
104     static DistributedBundleOption *FromJson(const nlohmann::json &jsonObject);
105 
106 private:
107     /**
108      * @brief Read data from a Parcel.
109      *
110      * @param parcel Indicates the parcel object.
111      * @return Returns true if read success; returns false otherwise.
112      */
113     bool ReadFromParcel(Parcel &parcel);
114 
115 private:
116     std::shared_ptr<NotificationBundleOption> bundle_ {};
117     bool enable_ = false;
118 };
119 }  // namespace Notification
120 }  // namespace OHOS
121 
122 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_DISTRIBUTED_BUNDLE_OPTION_H