1 /*
2  * Copyright (c) 2024 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 APPEVENT_PACKAGEHOLDER_IMPL_H
17 #define APPEVENT_PACKAGEHOLDER_IMPL_H
18 
19 #include "app_event_store.h"
20 #include "cj_ffi/cj_common_ffi.h"
21 #include "common.h"
22 #include "hiappevent_base.h"
23 #include "native/ffi_remote_data.h"
24 
25 namespace OHOS {
26 namespace CJSystemapi {
27 namespace HiAppEvent {
28 int64_t GetObserverSeqByName(const std::string& name);
29 char* MallocCString(const std::string& origin);
30 class AppEventPackageHolderImpl : public OHOS::FFI::FFIData {
31 public:
GetRuntimeType()32     OHOS::FFI::RuntimeType* GetRuntimeType() override
33     {
34         return GetClassType();
35     }
36     AppEventPackageHolderImpl(const std::string& name, int64_t observerSeq);
37     void SetSize(int size);
38     std::tuple<int32_t, RetAppEventPackage> TakeNext();
39 
40 private:
41     std::string name_;
42     int64_t takeSize_ = 0;
43     int packageId_ = 0;
44     int64_t observerSeq_ = 0;
45     friend class OHOS::FFI::RuntimeType;
46     friend class OHOS::FFI::TypeBase;
GetClassType()47     static OHOS::FFI::RuntimeType* GetClassType()
48     {
49         static OHOS::FFI::RuntimeType runtimeType =
50             OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("AppEventPackageHolderImpl");
51         return &runtimeType;
52     }
53 };
54 } // HiAppEvent
55 } // CJSystemapi
56 } // OHOS
57 
58 #endif
59