Rule management added.
[platform/core/security/suspicious-activity-monitor.git] / communication / inc / event.h
1 /**
2  * Samsung Ukraine R&D Center (SRK under a contract between)
3  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 /**
19  * @file   event.h
20  * @brief  Communication level event class
21  * @date   Created Feb 15, 2018
22  * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
23  */
24
25 #ifndef EVENT_H
26 #define EVENT_H
27
28 #include <string>
29 #include <jsoncpp/json/value.h>
30 #include "connection.h"
31
32 namespace communication
33 {
34
35 /**
36  * @brief The Event class represents communication event
37  */
38 class Event
39 {
40 public:
41     Event(const Json::Value& value, Connection& conn);
42
43     /**
44      * @brief isValid validates event
45      * @return true if event is valid and false otherwise
46      */
47     bool isValid() const
48     {
49         return !type.empty() && !uri.empty();
50     }
51
52     /**
53      * @brief getContent return content of the event
54      * @return event content as string or empty string upon failure
55      */
56     const std::string& getContent();
57
58     /**
59      * @brief confirm Confirms that event processed correctly
60      * @param response optional confirmation response body
61      */
62     void confirm(const std::string& response = std::string{});
63
64     /**
65      * @brief getType returns event type
66      * @return event type
67      */
68     const std::string& getType() const
69     {
70         return type;
71     }
72
73     /**
74      * @brief getDescription returns event description
75      * @return event description text
76      */
77     const std::string& getDescription() const
78     {
79         return descr;
80     }
81
82 private:
83     Connection& connection;
84     std::string type;
85     std::string uri;
86     std::string confirmUri;
87     std::string descr;
88     std::string content;
89     bool loaded;
90     bool confirmed;
91 };
92
93 } // namespace communication
94
95 #endif // EVENT_H