1 /* 2 * Copyright (c) 2022 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_BLOCK_DAO_H 16 #define HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_CACHE_APP_EVENT_BLOCK_DAO_H 17 18 #include <cstdint> 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class AppEventStore; 26 27 class AppEventBlockDao { 28 public: 29 AppEventBlockDao(std::shared_ptr<AppEventStore> store, const std::string& name); ~AppEventBlockDao()30 ~AppEventBlockDao() {} 31 32 // insert package to the table 33 int InsertPackage(const std::string& package); 34 35 // delete the data before the seq 36 int DeletePackageBySeq(int64_t seq); 37 38 // delete the oldest num pieces of data 39 int DeletePackageByNum(int num); 40 41 // the total size of data fetched from the table is less than size 42 int GetPackagesBySize(int size, std::vector<std::string> &packages, int64_t& seq); 43 44 // count the total number and size of data in the table 45 int CountPackages(int& num, int64_t& size); 46 47 private: 48 std::shared_ptr<AppEventStore> store_; 49 std::string table_; 50 }; 51 } // namespace HiviewDFX 52 } // namespace OHOS 53 #endif // HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_CACHE_APP_EVENT_BLOCK_DAO_H 54