Diff to HTML by rtfpessoa

{baseline/home/runner/work/ThunderTools/ThunderTools/ghpages_baseline/PluginSkeletonGenerator/master/latest_raw/InProcessConfig → generated/artifacts/PluginSkeleton-InProcessConfig}/InProcessConfig.cpp RENAMED
@@ -25,7 +25,7 @@ namespace Plugin {
25
25
 
26
26
  namespace {
27
27
 
28
- static Metadata<InProcessConfig>metadata(
28
+ static Metadata<InProcessConfig> metadata(
29
29
  // Version
30
30
  1, 0, 0,
31
31
  // Preconditions
@@ -56,10 +56,33 @@ namespace Plugin {
56
56
  return (string());
57
57
  }
58
58
 
59
- Core::hresult InProcessConfig::Register(INotification* const /* sink */) {
59
+ Core::hresult InProcessConfig::Register(Exchange::IPower::INotification* notification) {
60
+ ASSERT(notification != nullptr);
61
+
62
+ _adminLock.Lock();
63
+ auto item = std::find(_powerNotification.begin(), _powerNotification.end(), notification);
64
+ ASSERT(item == _powerNotification.end());
65
+
66
+ if (item == _powerNotification.end()) {
67
+ notification->AddRef();
68
+ _powerNotification.push_back(notification);
69
+ }
70
+
71
+ _adminLock.Unlock();
60
72
  return Core::ERROR_NONE;
61
73
  }
62
- Core::hresult InProcessConfig::Unregister(const INotification* const /* sink */) {
74
+ Core::hresult InProcessConfig::Unregister(const Exchange::IPower::INotification* notification) {
75
+ ASSERT(notification != nullptr);
76
+
77
+ _adminLock.Lock();
78
+ auto item = std::find(_powerNotification.begin(), _powerNotification.end(), notification);
79
+ ASSERT(item != _powerNotification.end());
80
+
81
+ if (item != _powerNotification.end()) {
82
+ _powerNotification.erase(item);
83
+ notification->Release();
84
+ }
85
+ _adminLock.Unlock();
63
86
  return Core::ERROR_NONE;
64
87
  }
65
88
  Core::hresult InProcessConfig::GetState(PCState& /* state */ /* @out */) const {
@@ -69,7 +92,14 @@ namespace Plugin {
69
92
  return Core::ERROR_NONE;
70
93
  }
71
94
  void InProcessConfig::PowerKey() {
72
- return Core::ERROR_NONE;
95
+ }
96
+
97
+ void InProcessConfig::NotifyStateChange(const PCState origin, const PCState destination, const PCPhase phase) const {
98
+ _adminLock.Lock();
99
+ for (auto* notification : _powerNotification) {
100
+ notification->StateChange(origin, destination, phase);
101
+ }
102
+ _adminLock.Unlock();
73
103
  }
74
104
  } // Plugin
75
105
  } // Thunder
{baseline/home/runner/work/ThunderTools/ThunderTools/ghpages_baseline/PluginSkeletonGenerator/master/latest_raw/InProcessConfig → generated/artifacts/PluginSkeleton-InProcessConfig}/InProcessConfig.h RENAMED
@@ -42,6 +42,7 @@ namespace Plugin {
42
42
  }
43
43
 
44
44
  ~InProcessConfig() override = default;
45
+ private:
45
46
  class Config : public Core::JSON::Container {
46
47
  public:
47
48
  Config(const Config&) = delete;
@@ -86,6 +87,8 @@ namespace Plugin {
86
87
  private:
87
88
  using PowerNotificationContainer = std::vector<Exchange::IPower::INotification*>;
88
89
 
90
+ void NotifyStateChange(const PCState /* origin */, const PCState /* destination */, const PCPhase /* phase */) const;
91
+
89
92
  mutable Core::CriticalSection _adminLock;
90
93
  PowerNotificationContainer _powerNotification;
91
94
  };