|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
namespace Thunder {
|
|
24
24
|
namespace Plugin {
|
|
25
25
|
|
|
26
26
|
namespace {
|
|
27
27
|
|
|
28
|
-
static Metadata<InProcessPreconditions>metadata(
|
|
28
|
+
static Metadata<InProcessPreconditions> metadata(
|
|
29
29
|
// Version
|
|
30
30
|
1, 0, 0,
|
|
31
31
|
// Preconditions
|
|
32
|
-
{ subsystem::GRAPHICS
|
|
32
|
+
{ subsystem::GRAPHICS},
|
|
33
33
|
// Terminations
|
|
34
|
-
{ subsystem::NOT_GRAPHICS
|
|
34
|
+
{ subsystem::NOT_GRAPHICS},
|
|
35
35
|
// Controls
|
|
36
|
-
{ subsystem::TIME
|
|
36
|
+
{ subsystem::TIME}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const string InProcessPreconditions::Initialize(VARIABLE_IS_NOT_USED PluginHost::IShell* service) {
|
|
41
41
|
string message;
|
|
@@ -51,14 +51,37 @@ namespace Plugin {
|
|
|
51
51
|
|
|
52
52
|
string InProcessPreconditions::Information() const {
|
|
53
53
|
return (string());
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
Core::hresult InProcessPreconditions::Register(INotification*
|
|
56
|
+
Core::hresult InProcessPreconditions::Register(Exchange::ITimeSync::INotification* notification) {
|
|
57
|
+
ASSERT(notification != nullptr);
|
|
58
|
+
|
|
59
|
+
_adminLock.Lock();
|
|
60
|
+
auto item = std::find(_timesyncNotification.begin(), _timesyncNotification.end(), notification);
|
|
61
|
+
ASSERT(item == _timesyncNotification.end());
|
|
62
|
+
|
|
63
|
+
if (item == _timesyncNotification.end()) {
|
|
64
|
+
notification->AddRef();
|
|
65
|
+
_timesyncNotification.push_back(notification);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_adminLock.Unlock();
|
|
57
69
|
return Core::ERROR_NONE;
|
|
58
70
|
}
|
|
59
|
-
Core::hresult InProcessPreconditions::Unregister(const INotification*
|
|
71
|
+
Core::hresult InProcessPreconditions::Unregister(const Exchange::ITimeSync::INotification* notification) {
|
|
72
|
+
ASSERT(notification != nullptr);
|
|
73
|
+
|
|
74
|
+
_adminLock.Lock();
|
|
75
|
+
auto item = std::find(_timesyncNotification.begin(), _timesyncNotification.end(), notification);
|
|
76
|
+
ASSERT(item != _timesyncNotification.end());
|
|
77
|
+
|
|
78
|
+
if (item != _timesyncNotification.end()) {
|
|
79
|
+
_timesyncNotification.erase(item);
|
|
80
|
+
notification->Release();
|
|
81
|
+
}
|
|
82
|
+
_adminLock.Unlock();
|
|
60
83
|
return Core::ERROR_NONE;
|
|
61
84
|
}
|
|
62
85
|
Core::hresult InProcessPreconditions::Synchronize() {
|
|
63
86
|
return Core::ERROR_NONE;
|
|
64
87
|
}
|
|
@@ -69,7 +92,15 @@ namespace Plugin {
|
|
|
69
92
|
return Core::ERROR_NONE;
|
|
70
93
|
}
|
|
71
94
|
Core::hresult InProcessPreconditions::Time(const Core::Time& /* time */) {
|
|
72
95
|
return Core::ERROR_NONE;
|
|
73
96
|
}
|
|
97
|
+
|
|
98
|
+
void InProcessPreconditions::NotifyTimeChanged() const {
|
|
99
|
+
_adminLock.Lock();
|
|
100
|
+
for (auto* notification : _timesyncNotification) {
|
|
101
|
+
notification->TimeChanged();
|
|
102
|
+
}
|
|
103
|
+
_adminLock.Unlock();
|
|
104
|
+
}
|
|
74
105
|
} // Plugin
|
|
75
106
|
} // Thunder
|
|
@@ -40,22 +40,20 @@ namespace Plugin {
|
|
|
40
40
|
, _timesyncNotification()
|
|
41
41
|
{
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
~InProcessPreconditions() override = default;
|
|
45
|
-
private:
|
|
46
|
-
public:
|
|
47
45
|
// IPlugin Methods
|
|
48
46
|
const string Initialize(PluginHost::IShell* service) override;
|
|
49
47
|
void Deinitialize(PluginHost::IShell* service) override;
|
|
50
48
|
string Information() const override;
|
|
51
49
|
|
|
52
50
|
// ITimeSync methods
|
|
53
51
|
|
|
54
|
-
Core::hresult Register(INotification* const /*
|
|
52
|
+
Core::hresult Register(Exchange::ITimeSync::INotification* const /* sink */) override;
|
|
55
53
|
|
|
56
|
-
Core::hresult Unregister(const INotification* const /*
|
|
54
|
+
Core::hresult Unregister(const Exchange::ITimeSync::INotification* const /* sink */) override;
|
|
57
55
|
|
|
58
56
|
Core::hresult Synchronize() override;
|
|
59
57
|
|
|
60
58
|
Core::hresult SyncTime(TimeInfo& /* info */ /* @out */) const override;
|
|
61
59
|
|
|
@@ -70,10 +68,12 @@ namespace Plugin {
|
|
|
70
68
|
END_INTERFACE_MAP
|
|
71
69
|
|
|
72
70
|
private:
|
|
73
71
|
using TimeSyncNotificationContainer = std::vector<Exchange::ITimeSync::INotification*>;
|
|
74
72
|
|
|
73
|
+
void NotifyTimeChanged() const;
|
|
74
|
+
|
|
75
75
|
mutable Core::CriticalSection _adminLock;
|
|
76
76
|
TimeSyncNotificationContainer _timesyncNotification;
|
|
77
77
|
};
|
|
78
78
|
} // Plugin
|
|
79
79
|
} // Thunder
|