-
-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...-frontmost_application_monitor/install/include/pqrs/osx/frontmost_application_monitor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...cation_monitor/install/include/pqrs/osx/frontmost_application_monitor/monitor_manager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
// (C) Copyright Takayama Fumihiko 2023. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See https://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include "application.hpp" | ||
#include "impl/impl.h" | ||
#include <nod/nod.hpp> | ||
#include <pqrs/dispatcher.hpp> | ||
|
||
namespace pqrs { | ||
namespace osx { | ||
namespace frontmost_application_monitor { | ||
class monitor; | ||
|
||
// Manage valid frontmost_application_monitor::monitor instances with monitor_manager because | ||
// the callbacks implemented in PQRSOSXFrontmostApplicationMonitor.swift are not cleanly consistent with the lifetime of monitor. | ||
class monitor_manager final { | ||
public: | ||
static std::shared_ptr<monitor_manager> get_global_monitor_manager(void) { | ||
if (!monitor_manager_) { | ||
monitor_manager_ = std::make_shared<monitor_manager>(); | ||
} | ||
|
||
return monitor_manager_; | ||
} | ||
|
||
monitor_manager(void) { | ||
} | ||
|
||
bool contains(const monitor* monitor_pointer) const { | ||
return monitor_pointers_.contains(monitor_pointer); | ||
} | ||
|
||
void insert(const monitor* monitor_pointer) { | ||
monitor_pointers_.insert(monitor_pointer); | ||
} | ||
|
||
void erase(const monitor* monitor_pointer) { | ||
monitor_pointers_.erase(monitor_pointer); | ||
} | ||
|
||
private: | ||
static inline std::shared_ptr<monitor_manager> monitor_manager_; | ||
|
||
std::unordered_set<const monitor*> monitor_pointers_; | ||
}; | ||
} // namespace frontmost_application_monitor | ||
} // namespace osx | ||
} // namespace pqrs |
1 change: 1 addition & 0 deletions
1
src/vendor/cget/include/pqrs/osx/frontmost_application_monitor/monitor_manager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../cget/pkg/pqrs-org__cpp-osx-frontmost_application_monitor/install/include/pqrs/osx/frontmost_application_monitor/monitor_manager.hpp |