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 16 #ifndef WORK_RECORD_H 17 #define WORK_RECORD_H 18 19 #include <mutex> 20 #include <parcel.h> 21 #include <string> 22 #include <vector> 23 24 #include "request.h" 25 26 namespace OHOS { 27 namespace Location { 28 class WorkRecord : public Parcelable { 29 public: 30 WorkRecord(); 31 ~WorkRecord() override = default; 32 bool Add(const std::shared_ptr<Request>& request); 33 bool Add(WorkRecord &workRecord, int32_t index); 34 bool Remove(int uid, int pid, std::string name, std::string uuid); 35 bool Find(int uid, std::string name, std::string uuid); 36 void Clear(); 37 void Set(WorkRecord &workRecord); 38 bool Remove(std::string name); 39 std::string GetDeviceId(); 40 void SetDeviceId(std::string deviceId); 41 int Size(); 42 bool IsEmpty(); 43 std::string GetName(int index); 44 int GetUid(int index); 45 int GetPid(int index); 46 uint32_t GetTokenId(int index); 47 uint32_t GetFirstTokenId(int index); 48 int GetTimeInterval(int index); 49 int GetNlpRequestType(int index); 50 std::string GetUuid(int index); 51 void ReadFromParcel(Parcel& parcel); 52 bool Marshalling(Parcel& parcel) const override; 53 bool MarshallingWorkRecord(Parcel& parcel) const; 54 static std::unique_ptr<WorkRecord> Unmarshalling(Parcel& parcel); 55 std::string ToString(); 56 private: 57 int num_; 58 std::vector<int> uids_; 59 std::vector<int> pids_; 60 std::vector<std::string> names_; 61 std::vector<int> timeInterval_; 62 std::vector<std::string> uuid_; 63 std::vector<int> nlpRequestType_; 64 std::vector<uint32_t> tokenId_; 65 std::vector<uint32_t> firstTokenId_; 66 std::string deviceId_; 67 mutable std::mutex workRecordMutex_; 68 }; 69 } // namespace Location 70 } // namespace OHOS 71 #endif // WORK_RECORD_H 72