• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 #ifndef HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_CACHE_APP_EVENT_CACHE_COMMON_H
16 #define HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_CACHE_APP_EVENT_CACHE_COMMON_H
17 
18 #include <string>
19 
20 #include "hiappevent_base.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 namespace AppEventCacheCommon {
25 constexpr int DB_SUCC = 0;
26 constexpr int DB_FAILED = -1;
27 
28 namespace Events {
29 const std::string TABLE = "events";
30 const std::string FIELD_SEQ = "seq";
31 const std::string FIELD_DOMAIN = "domain";
32 const std::string FIELD_NAME = "name";
33 const std::string FIELD_TYPE = "type";
34 const std::string FIELD_TIME = "time";
35 const std::string FIELD_TZ = "tz";
36 const std::string FIELD_PID = "pid";
37 const std::string FIELD_TID = "tid";
38 const std::string FIELD_TRACE_ID = "trace_id";
39 const std::string FIELD_SPAN_ID = "span_id";
40 const std::string FIELD_PSPAN_ID = "pspan_id";
41 const std::string FIELD_TRACE_FLAG = "trace_flag";
42 const std::string FIELD_PARAMS = "params";
43 const std::string FIELD_SIZE = "size";
44 const std::string FIELD_RUNNING_ID = "running_id";
45 } // namespace Events
46 
47 namespace Observers {
48 const std::string TABLE = "observers";
49 const std::string FIELD_SEQ = "seq";
50 const std::string FIELD_NAME = "name";
51 const std::string FIELD_HASH = "hash";
52 const std::string FIELD_FILTERS = "filters";
53 } // namespace Observers
54 
55 struct Observer {
ObserverObserver56     Observer(int64_t seq, const std::string& name, const std::string& filters)
57         : seq(seq), name(name), filters(filters) {}
58     Observer(const std::string& name, int64_t hashCode, const std::string& filters = "")
nameObserver59         : name(name), hashCode(hashCode), filters(filters) {}
~ObserverObserver60     ~Observer() {}
61     int64_t seq = 0;
62     std::string name;
63     int64_t hashCode = 0;
64     std::string filters;
65 };
66 
67 namespace AppEventMapping {
68 const std::string TABLE = "event_observer_mapping";
69 const std::string FIELD_SEQ = "seq";
70 const std::string FIELD_EVENT_SEQ = "event_seq";
71 const std::string FIELD_OBSERVER_SEQ = "observer_seq";
72 } // namespace AppEventMapping
73 
74 struct EventObserverInfo {
EventObserverInfoEventObserverInfo75     EventObserverInfo(int64_t eventSeq, int64_t observerSeq) : eventSeq(eventSeq), observerSeq(observerSeq) {}
76     int64_t eventSeq = 0;
77     int64_t observerSeq = 0;
78 };
79 
80 namespace UserIds {
81 const std::string TABLE = "user_ids";
82 const std::string FIELD_SEQ = "seq";
83 const std::string FIELD_NAME = "name";
84 const std::string FIELD_VALUE = "value";
85 } // namespace UserIds
86 
87 namespace UserProperties {
88 const std::string TABLE = "user_properties";
89 const std::string FIELD_SEQ = "seq";
90 const std::string FIELD_NAME = "name";
91 const std::string FIELD_VALUE = "value";
92 } // namespace UserProperties
93 
94 namespace CustomEventParams {
95 const std::string TABLE = "custom_event_params";
96 const std::string FIELD_SEQ = "seq";
97 const std::string FIELD_RUNNING_ID = "running_id";
98 const std::string FIELD_DOMAIN = "domain";
99 const std::string FIELD_NAME = "name";
100 const std::string FIELD_PARAM_KEY = "param_key";
101 const std::string FIELD_PARAM_VALUE = "param_value";
102 const std::string FIELD_PARAM_TYPE = "param_type";
103 } // namespace CustomEventParams
104 
105 struct CustomEvent {
CustomEventCustomEvent106     CustomEvent(const std::string& runningId, const std::string& domain, const std::string& name)
107         : runningId(runningId), domain(domain), name(name) {}
108     std::string runningId;
109     std::string domain;
110     std::string name;
111     std::vector<CustomEventParam> params;
112 };
113 } // namespace AppEventCacheCommon
114 } // namespace HiviewDFX
115 } // namespace OHOS
116 #endif // HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_CACHE_APP_EVENT_CACHE_COMMON_H
117