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
@@ -23,11 +23,11 @@
23
23
  namespace Thunder {
24
24
  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
32
32
  {},
33
33
  // Terminations
@@ -39,11 +39,11 @@ namespace Plugin {
39
39
 
40
40
  const string InProcessConfig::Initialize(PluginHost::IShell* service) {
41
41
  string message;
42
42
 
43
43
  ASSERT(service != nullptr);
44
- Config config;
44
+ PluginConfig config;
45
45
  config.FromString(service->ConfigLine());
46
46
  TRACE(Trace::Information, (_T("This is just an example: [%s]"), config.Example.Value().c_str()));
47
47
  Exchange::JPower::Register(*this, this);
48
48
  return (message);
49
49
  }
@@ -54,22 +54,52 @@ namespace Plugin {
54
54
 
55
55
  string InProcessConfig::Information() const {
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 {
66
89
  return Core::ERROR_NONE;
67
90
  }
68
91
  Core::hresult InProcessConfig::SetState(const PCState& /* state */, const uint32_t /* waitTime */) {
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
@@ -40,24 +40,25 @@ namespace Plugin {
40
40
  , _powerNotification()
41
41
  {
42
42
  }
43
43
 
44
44
  ~InProcessConfig() override = default;
45
- class Config : public Core::JSON::Container {
45
+ private:
46
+ class PluginConfig : public Core::JSON::Container {
46
47
  public:
47
- Config(const Config&) = delete;
48
- Config& operator=(const Config&) = delete;
49
- Config(Config&&) = delete;
50
- Config& operator=(Config&&) = delete;
48
+ PluginConfig(const PluginConfig&) = delete;
49
+ PluginConfig& operator=(const PluginConfig&) = delete;
50
+ PluginConfig(PluginConfig&&) = delete;
51
+ PluginConfig& operator=(PluginConfig&&) = delete;
51
52
 
52
- Config()
53
+ PluginConfig()
53
54
  : Core::JSON::Container()
54
55
  , Example()
55
56
  {
56
57
  Add(_T("example"), &Example);
57
58
  }
58
- ~Config() override = default;
59
+ ~PluginConfig() override = default;
59
60
  public:
60
61
  Core::JSON::String Example;
61
62
  };
62
63
  public:
63
64
  // IPlugin Methods
@@ -65,13 +66,13 @@ namespace Plugin {
65
66
  void Deinitialize(PluginHost::IShell* service) override;
66
67
  string Information() const override;
67
68
 
68
69
  // IPower methods
69
70
 
70
- Core::hresult Register(INotification* const /* sink */) override;
71
+ Core::hresult Register(Exchange::IPower::INotification* const /* sink */) override;
71
72
 
72
- Core::hresult Unregister(const INotification* const /* sink */) override;
73
+ Core::hresult Unregister(const Exchange::IPower::INotification* const /* sink */) override;
73
74
 
74
75
  Core::hresult GetState(PCState& /* state */ /* @out */) const override;
75
76
 
76
77
  Core::hresult SetState(const PCState& /* state */, const uint32_t /* waitTime */) override;
77
78
 
@@ -84,10 +85,12 @@ namespace Plugin {
84
85
  END_INTERFACE_MAP
85
86
 
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
  };
92
95
  } // Plugin
93
96
  } // Thunder