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>
23 #include <shared_mutex>
25 #ifndef COMMON_DB_CHANGE_OBSERVER_HH_
26 #define COMMON_DB_CHANGE_OBSERVER_HH_
28 namespace pkgmgr_common {
31 #define EXPORT_API __attribute__((visibility("default")))
34 class EXPORT_API DbChangeObserver {
38 virtual ~IEvent() = default;
39 virtual void OnDbChanged() = 0;
41 static DbChangeObserver& GetInst();
45 void SetChanged(bool changed);
46 void RegisterEvent(IEvent* listener);
47 void UnRegisterEvent();
56 GIOChannel* channel_ = nullptr;
58 bool changed_ = false;
59 bool disposed_ = true;
60 std::shared_mutex lock_;
61 std::string global_parser_db_path_;
62 IEvent* listener_ = nullptr;
65 bool SetGlobalParserDbPath();
66 static gboolean OnReceiveEvent(GIOChannel* channel, GIOCondition cond,
70 } // namespace pkgmgr_common
72 #endif // COMMON_DB_CHANGE_OBSERVER_HH_