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 namespace OHOS { 25 namespace Location { 26 class WorkRecord : public Parcelable { 27 public: 28 WorkRecord(); 29 ~WorkRecord() override = default; 30 bool Add(int uid, int pid, std::string name, int timeInterval, std::string uuid); 31 bool Remove(int uid, int pid, std::string name, std::string uuid); 32 bool Find(int uid, std::string name, std::string uuid); 33 void Clear(); 34 void Set(WorkRecord &workRecord); 35 bool Remove(std::string name); 36 std::string GetDeviceId(); 37 void SetDeviceId(std::string deviceId); 38 int Size(); 39 bool IsEmpty(); 40 std::string GetName(int index); 41 int GetUid(int index); 42 int GetPid(int index); 43 int GetTimeInterval(int index); 44 std::string GetUuid(int index); 45 void ReadFromParcel(Parcel& parcel); 46 bool Marshalling(Parcel& parcel) const override; 47 bool MarshallingWorkRecord(Parcel& parcel) const; 48 static std::unique_ptr<WorkRecord> Unmarshalling(Parcel& parcel); 49 std::string ToString(); 50 private: 51 int num_; 52 std::vector<int> uids_; 53 std::vector<int> pids_; 54 std::vector<std::string> names_; 55 std::vector<int> timeInterval_; 56 std::vector<std::string> uuid_; 57 std::string deviceId_; 58 mutable std::mutex workRecordMutex_; 59 }; 60 } // namespace Location 61 } // namespace OHOS 62 #endif // WORK_RECORD_H 63