• 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 FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_MATCHING_SKILLS_H
17 #define FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_MATCHING_SKILLS_H
18 
19 #include "parcel.h"
20 #include "want.h"
21 
22 namespace OHOS {
23 namespace EventFwk {
24 using Want = OHOS::AAFwk::Want;
25 
26 class MatchingSkills : public Parcelable {
27 public:
28     /**
29      * A constructor used to create an empty MatchingSkills instance.
30      */
31     MatchingSkills();
32 
33     /**
34      * A constructor used to create a MatchingSkills instance by using the parameters of an existing MatchingSkills
35      * object.
36      */
37     MatchingSkills(const MatchingSkills &matchingSkills);
38 
39     /**
40      * A deconstructor used to deconstruct
41      */
42     ~MatchingSkills();
43 
44     /**
45      * Obtain an entity.
46      *
47      * @return entity
48      */
49     std::string GetEntity(int index) const;
50 
51     /**
52      * Add an event to this MatchingSkills object.
53      *
54      * @param entity the entity
55      */
56     void AddEntity(const std::string &entity);
57 
58     /**
59      * Has entity.
60      *
61      * @param event  the entity in MatchingSkills
62      * @return whether the entity in MatchingSkills or not
63      */
64     bool HasEntity(const std::string &entity) const;
65 
66     /**
67      * Remove entity.
68      *
69      * @param event  the entity in MatchingSkills
70      * @return remove entity success or not
71      */
72     void RemoveEntity(const std::string &entity);
73 
74     /**
75      * Gets entity count.
76      *
77      * @return entity count
78      */
79     int CountEntities() const;
80 
81     /**
82      * Adds an event to this MatchingSkills object.
83      *
84      * @param event the event
85      */
86     void AddEvent(const std::string &event);
87 
88     /**
89      * Get event count.
90      *
91      * @return the event count in MatchingSkills
92      */
93     int CountEvent() const;
94 
95     /**
96      * Get event.
97      *
98      * @return the event in MatchingSkills
99      */
100     std::string GetEvent(int index) const;
101 
102     /**
103      * Get events.
104      *
105      * @return the events in MatchingSkills
106      */
107     std::vector<std::string> GetEvents() const;
108 
109     /**
110      * Remove events.
111      *
112      * @return event the event in MatchingSkills
113      */
114     void RemoveEvent(const std::string &event);
115 
116     /**
117      * Has event.
118      *
119      * @param event the event in MatchingSkills
120      * @return whether the event in MatchingSkills or not
121      */
122     bool HasEvent(const std::string &event) const;
123 
124     /**
125      * obtain an Scheme.
126      *
127      * @return Scheme
128      */
129     std::string GetScheme(int index) const;
130 
131     /**
132      * Add scheme to this MatchingSkills object.
133      *
134      * @param scheme the scheme
135      */
136     void AddScheme(const std::string &scheme);
137 
138     /**
139      * Has scheme.
140      *
141      * @param event  the scheme in MatchingSkills
142      * @return whether the scheme in MatchingSkills or not
143      */
144     bool HasScheme(const std::string &scheme) const;
145 
146     /**
147      * Remove entity.
148      *
149      * @param event  the entity in MatchingSkills
150      * @return remove entity success or not
151      */
152     void RemoveScheme(const std::string &scheme);
153 
154     /**
155      * Get scheme count.
156      *
157      * @return scheme count
158      */
159     int CountSchemes() const;
160 
161     /**
162      * Match want.
163      *
164      * @param want the want in MatchingSkills
165      * @return match the want result
166      */
167     bool Match(const Want &want) const;
168 
169     /**
170      * Marshal this MatchingSkills object into a Parcel.
171      *
172      * @param parcel  parcel
173      * @return marshalling result
174      */
175     virtual bool Marshalling(Parcel &parcel) const override;
176 
177     /**
178      * Unmarshal this MatchingSkills object from a Parcel.
179      *
180      * @param parcel  parcel
181      * @return MatchingSkills
182      */
183     static MatchingSkills *Unmarshalling(Parcel &parcel);
184 
185 private:
186     /**
187      * Read MatchingSkills object from a Parcel.
188      *
189      * @param parcel the parcel
190      * @return read from parcel success or fail
191      */
192     bool ReadFromParcel(Parcel &parcel);
193 
194     /**
195      * Match event.
196      *
197      * @param parcel the event in want
198      * @return match event success or fail
199      */
200     bool MatchEvent(const std::string &event) const;
201 
202     /**
203      * Match entity.
204      *
205      * @param parcel the entity in want
206      * @return match entity success or fail
207      */
208     bool MatchEntity(const std::vector<std::string> &entities) const;
209 
210     /**
211      * Match scheme.
212      *
213      * @param parcel the scheme in want
214      * @return match scheme success or fail
215      */
216     bool MatchScheme(const std::string &scheme) const;
217 
218 private:
219     std::vector<std::string> entities_;
220     std::vector<std::string> events_;
221     std::vector<std::string> schemes_;
222 };
223 }  // namespace EventFwk
224 }  // namespace OHOS
225 
226 #endif  // FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_MATCHING_SKILLS_H