1 /* 2 * Copyright (c) 2024 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 API_CORE_IFILE_MONITOR_H 17 #define API_CORE_IFILE_MONITOR_H 18 19 #include <base/containers/refcnt_ptr.h> 20 #include <base/containers/string.h> 21 #include <base/containers/string_view.h> 22 #include <base/namespace.h> 23 #include <base/util/uid.h> 24 #include <core/namespace.h> 25 #include <core/plugin/intf_interface.h> 26 27 BASE_BEGIN_NAMESPACE() 28 template<typename T> 29 class vector; 30 BASE_END_NAMESPACE() 31 32 CORE_BEGIN_NAMESPACE() 33 class IFileManager; 34 35 /** @ingroup group_ifilemonitor */ 36 /** Filemonitor interface 37 * Helper class to monitor changes in filesystems, in hot-reload scenarios. 38 * Usage: 39 */ 40 41 class IFileMonitor : public IInterface { 42 public: 43 static constexpr auto UID = BASE_NS::Uid { "107c2b9f-3be3-4d56-be22-6e3259a486f5" }; 44 45 using Ptr = BASE_NS::refcnt_ptr<IFileMonitor>; 46 47 virtual void Initialize(IFileManager&) = 0; 48 virtual bool AddPath(BASE_NS::string_view path) = 0; 49 virtual bool RemovePath(BASE_NS::string_view path) = 0; 50 virtual void ScanModifications(BASE_NS::vector<BASE_NS::string>& added, BASE_NS::vector<BASE_NS::string>& removed, 51 BASE_NS::vector<BASE_NS::string>& modified) = 0; 52 53 protected: 54 IFileMonitor() = default; 55 virtual ~IFileMonitor() = default; 56 }; 57 GetName(const IFileMonitor *)58inline constexpr BASE_NS::string_view GetName(const IFileMonitor*) 59 { 60 return "IFileMonitor"; 61 } 62 CORE_END_NAMESPACE() 63 64 #endif // API_CORE_IFILE_MONITOR_H 65