2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <sys/inotify.h>
22 #include <shared_mutex>
24 #ifndef COMMON_DB_CHANGE_OBSERVER_HH_
25 #define COMMON_DB_CHANGE_OBSERVER_HH_
27 namespace pkgmgr_common {
30 #define EXPORT_API __attribute__((visibility("default")))
33 class EXPORT_API DbChangeObserver {
37 virtual ~IEvent() = default;
38 virtual void OnDbChanged() = 0;
40 static DbChangeObserver& GetInst();
44 void SetChanged(bool changed);
45 void RegisterEvent(IEvent* listener);
46 void UnRegisterEvent();
55 GIOChannel* channel_ = nullptr;
57 bool changed_ = false;
58 bool disposed_ = true;
59 std::shared_mutex lock_;
60 std::string global_parser_db_path_;
61 IEvent* listener_ = nullptr;
64 bool SetGlobalParserDbPath();
65 static gboolean OnReceiveEvent(GIOChannel* channel, GIOCondition cond,
69 } // namespace pkgmgr_common
71 #endif // COMMON_DB_CHANGE_OBSERVER_HH_