17405867cSopenharmony_ci/*
27405867cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
37405867cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47405867cSopenharmony_ci * you may not use this file except in compliance with the License.
57405867cSopenharmony_ci * You may obtain a copy of the License at
67405867cSopenharmony_ci *
77405867cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87405867cSopenharmony_ci *
97405867cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107405867cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117405867cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127405867cSopenharmony_ci * See the License for the specific language governing permissions and
137405867cSopenharmony_ci * limitations under the License.
147405867cSopenharmony_ci */
157405867cSopenharmony_ci#ifndef HIAPPEVENT_INTERFACES_NATIVE_INNER_API_INCLUDE_APP_EVENT_H
167405867cSopenharmony_ci#define HIAPPEVENT_INTERFACES_NATIVE_INNER_API_INCLUDE_APP_EVENT_H
177405867cSopenharmony_ci
187405867cSopenharmony_ci#include <string>
197405867cSopenharmony_ci#include <vector>
207405867cSopenharmony_ci
217405867cSopenharmony_cinamespace OHOS {
227405867cSopenharmony_cinamespace HiviewDFX {
237405867cSopenharmony_ciclass AppEventPack;
247405867cSopenharmony_cinamespace HiAppEvent {
257405867cSopenharmony_cienum EventType {
267405867cSopenharmony_ci    FAULT = 1,
277405867cSopenharmony_ci    STATISTIC = 2,
287405867cSopenharmony_ci    SECURITY = 3,
297405867cSopenharmony_ci    BEHAVIOR = 4
307405867cSopenharmony_ci};
317405867cSopenharmony_ci
327405867cSopenharmony_ciclass Event {
337405867cSopenharmony_cipublic:
347405867cSopenharmony_ci    Event(const std::string& domain, const std::string& name, EventType type);
357405867cSopenharmony_ci    ~Event() = default;
367405867cSopenharmony_ci
377405867cSopenharmony_ci    void AddParam(const std::string& key, bool value);
387405867cSopenharmony_ci    void AddParam(const std::string& key, int32_t value);
397405867cSopenharmony_ci    void AddParam(const std::string& key, int64_t value);
407405867cSopenharmony_ci    void AddParam(const std::string& key, double value);
417405867cSopenharmony_ci    /**
427405867cSopenharmony_ci     * Note: To avoid implicit type conversion problems, do not support direct input
437405867cSopenharmony_ci     * of string literal constants, for example:
447405867cSopenharmony_ci     *     AddParam("str_key", "str_value") // Not supported
457405867cSopenharmony_ci     */
467405867cSopenharmony_ci    void AddParam(const std::string& key, const std::string& value);
477405867cSopenharmony_ci
487405867cSopenharmony_ci    void AddParam(const std::string& key, const std::vector<bool>& value);
497405867cSopenharmony_ci    void AddParam(const std::string& key, const std::vector<int32_t>& value);
507405867cSopenharmony_ci    void AddParam(const std::string& key, const std::vector<int64_t>& value);
517405867cSopenharmony_ci    void AddParam(const std::string& key, const std::vector<double>& value);
527405867cSopenharmony_ci    /**
537405867cSopenharmony_ci     * Note: To avoid implicit type conversion problems, do not support direct input of
547405867cSopenharmony_ci     * initialization list and string literal constants, for example:
557405867cSopenharmony_ci     *     AddParam("str_key", {"str1"}) // Not supported
567405867cSopenharmony_ci     *     AddParam("str_key", {"str1", "str2"}) // Not supported
577405867cSopenharmony_ci     *     AddParam("str_key", {str1}) // Not supported
587405867cSopenharmony_ci     *     AddParam("str_key", {str1, str2}) // Supported
597405867cSopenharmony_ci     */
607405867cSopenharmony_ci    void AddParam(const std::string& key, const std::vector<std::string>& value);
617405867cSopenharmony_ci
627405867cSopenharmony_ci    friend int Write(const Event& event);
637405867cSopenharmony_ci
647405867cSopenharmony_ciprivate:
657405867cSopenharmony_ci    std::shared_ptr<AppEventPack> eventPack_;
667405867cSopenharmony_ci};
677405867cSopenharmony_ci
687405867cSopenharmony_ciint Write(const Event& event);
697405867cSopenharmony_ci} // namespace HiAppEvent
707405867cSopenharmony_ci} // namespace HiviewDFX
717405867cSopenharmony_ci} // namespace OHOS
727405867cSopenharmony_ci#endif // HIAPPEVENT_INTERFACES_NATIVE_INNER_API_INCLUDE_APP_EVENT_H
73