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 int GetTimeInterval(int index); 47 int GetNlpRequestType(int index); 48 std::string GetUuid(int index); 49 void ReadFromParcel(Parcel& parcel); 50 bool Marshalling(Parcel& parcel) const override; 51 bool MarshallingWorkRecord(Parcel& parcel) const; 52 static std::unique_ptr<WorkRecord> Unmarshalling(Parcel& parcel); 53 std::string ToString(); 54 private: 55 int num_; 56 std::vector<int> uids_; 57 std::vector<int> pids_; 58 std::vector<std::string> names_; 59 std::vector<int> timeInterval_; 60 std::vector<std::string> uuid_; 61 std::vector<int> nlpRequestType_; 62 std::string deviceId_; 63 mutable std::mutex workRecordMutex_; 64 }; 65 } // namespace Location 66 } // namespace OHOS 67 #endif // WORK_RECORD_H 68