Add UnregisterRGBController method to ResourceManager
Commit amended by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
50adf9ab51
commit
2a6b457324
4 changed files with 42 additions and 0 deletions
|
|
@ -1369,6 +1369,12 @@ void RGBController::UnregisterUpdateCallback(void * callback_arg)
|
|||
}
|
||||
}
|
||||
|
||||
void RGBController::ClearCallbacks()
|
||||
{
|
||||
UpdateCallbacks.clear();
|
||||
UpdateCallbackArgs.clear();
|
||||
}
|
||||
|
||||
void RGBController::SignalUpdate()
|
||||
{
|
||||
UpdateMutex.lock();
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ public:
|
|||
|
||||
virtual void RegisterUpdateCallback(RGBControllerCallback new_callback, void * new_callback_arg) = 0;
|
||||
virtual void UnregisterUpdateCallback(void * callback_arg) = 0;
|
||||
virtual void ClearCallbacks() = 0;
|
||||
virtual void SignalUpdate() = 0;
|
||||
|
||||
virtual void UpdateLEDs() = 0;
|
||||
|
|
@ -253,6 +254,7 @@ public:
|
|||
|
||||
void RegisterUpdateCallback(RGBControllerCallback new_callback, void * new_callback_arg);
|
||||
void UnregisterUpdateCallback(void * callback_arg);
|
||||
void ClearCallbacks();
|
||||
void SignalUpdate();
|
||||
|
||||
void UpdateLEDs();
|
||||
|
|
|
|||
|
|
@ -91,6 +91,38 @@ void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
|
|||
DeviceListChanged();
|
||||
}
|
||||
|
||||
void ResourceManager::UnregisterRGBController(RGBController *rgb_controller)
|
||||
{
|
||||
LOG_NOTICE("Unregistering RGB controller: %s", rgb_controller->name.c_str());
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Clear callbacks from the controller before removal |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
rgb_controller->ClearCallbacks();
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Find the controller to remove and remove it from the hardware list |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
std::vector<RGBController*>::iterator hw_it = std::find(rgb_controllers_hw.begin(), rgb_controllers_hw.end(), rgb_controller);
|
||||
|
||||
if (hw_it != rgb_controllers_hw.end())
|
||||
{
|
||||
rgb_controllers_hw.erase(hw_it);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Find the controller to remove and remove it from the master list |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
std::vector<RGBController*>::iterator rgb_it = std::find(rgb_controllers.begin(), rgb_controllers.end(), rgb_controller);
|
||||
|
||||
if (rgb_it != rgb_controllers.end())
|
||||
{
|
||||
rgb_controllers.erase(rgb_it);
|
||||
}
|
||||
|
||||
DeviceListChanged();
|
||||
}
|
||||
|
||||
std::vector<RGBController*> & ResourceManager::GetRGBControllers()
|
||||
{
|
||||
return rgb_controllers;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public:
|
|||
virtual std::vector<i2c_smbus_interface*> & GetI2CBusses() = 0;
|
||||
|
||||
virtual void RegisterRGBController(RGBController *rgb_controller) = 0;
|
||||
virtual void UnregisterRGBController(RGBController *rgb_controller) = 0;
|
||||
|
||||
virtual void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) = 0;
|
||||
virtual void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg) = 0;
|
||||
|
|
@ -92,6 +93,7 @@ public:
|
|||
std::vector<i2c_smbus_interface*> & GetI2CBusses();
|
||||
|
||||
void RegisterRGBController(RGBController *rgb_controller);
|
||||
void UnregisterRGBController(RGBController *rgb_controller);
|
||||
|
||||
std::vector<RGBController*> & GetRGBControllers();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue