hyperion.ng/include/hyperion/ComponentRegister.h
SJunkies 3ff7fe483f
fix: small collection of bugfixed debugger hints and warnings (#801)
* small collection of bugfixed debugger hints / warnings

* 'toStdVector' has been explicitly marked deprecated

* fixed double zip naming in artifacts

* V4L2 WebUI Fix

* Some code fixes based on alerts from lgtm.com

* only execute dynamic v4l2 enum code, if V4L2_AVAIL

* very high critical bugfix ;)

* merge fix

* some lgtm.com fixes

* lgtm fixes

* undo localtime_r fix

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-25 21:51:11 +02:00

69 lines
2.0 KiB
C++

#pragma once
#include <utils/Components.h>
#include <utils/Logger.h>
// STL includes
#include <map>
#include <QObject>
class Hyperion;
///
/// @brief The component register reflects and manages the current state of all components and Hyperion as a whole
/// It emits also real component state changes (triggert from the specific component), which can be used for listening APIs (Network Clients/Plugins)
///
class ComponentRegister : public QObject
{
Q_OBJECT
public:
ComponentRegister(Hyperion* hyperion);
~ComponentRegister();
///
/// @brief Check if a component is currently enabled
/// @param comp The component from enum
/// @return True if component is running else false. Not found is -1
///
int isComponentEnabled(const hyperion::Components& comp) const;
/// contains all components and their state
std::map<hyperion::Components, bool> getRegister() { return _componentStates; };
signals:
///
/// @brief Emits whenever a component changed (really) the state
/// @param comp The component
/// @param state The new state of the component
///
void updatedComponentState(const hyperion::Components comp, const bool state);
public slots:
///
/// @brief is called whenever a component change a state, DO NOT CALL FROM API, use signal hyperion->compStateChangeRequest
/// @param comp The component
/// @param state The new state of the component
///
void setNewComponentState(const hyperion::Components comp, const bool activated);
private slots:
///
/// @brief Handle COMP_ALL changes from Hyperion->compStateChangeRequest
///
void handleCompStateChangeRequest(const hyperion::Components comps, const bool activated);
private:
/// Hyperion instance
Hyperion * _hyperion;
/// Logger instance
Logger * _log;
/// current state of all components
std::map<hyperion::Components, bool> _componentStates;
/// on hyperion off we save the previous states of all components
std::map<hyperion::Components, bool> _prevComponentStates;
// helper to prevent self emit chains
bool _inProgress = false;
};