33 #define BLACKLIST QStringLiteral("") 35 TorcControls::TorcControls()
44 void TorcControls::Create(
const QVariantMap &Details)
48 QVariantMap::const_iterator it = Details.constFind(QStringLiteral(
"controls"));
49 if (Details.constEnd() == it)
52 QVariantMap control = it.value().toMap();
53 it = control.constBegin();
54 for ( ; it != control.constEnd(); ++it)
56 int type = TorcCoreUtils::StringToEnum<TorcControl::Type>(it.key());
59 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Unknown control type '%1'").arg(it.key()));
63 QVariantMap controls = it.value().toMap();
64 QVariantMap::const_iterator it2 = controls.constBegin();
65 for ( ; it2 != controls.constEnd(); ++it2)
67 QVariantMap details = it2.value().toMap();
68 if (!details.contains(QStringLiteral(
"name")))
70 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Ignoring control type '%1' with no <name>").arg(TorcCoreUtils::EnumToLowerString<TorcControl::Type>((
TorcControl::Type)type)));
85 void TorcControls::Destroy(
void)
94 void TorcControls::Validate(
void)
105 QMutableListIterator<TorcControl*> it(
controlList);
111 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Failed to complete device '%1' - deleting").arg(control->
GetUniqueId()));
117 LOG(VB_GENERAL, LOG_INFO, QStringLiteral(
"Registered control '%1'").arg(control->
Name()));
121 LOG(VB_GENERAL, LOG_DEBUG, QStringLiteral(
"Controls validated"));
131 QString path(QStringLiteral(
""));
136 void TorcControls::Graph(QByteArray* Data)
140 control->
Graph(Data);
143 QString TorcControls::GetUIName(
void)
145 return tr(
"Controls");
158 QMetaEnum meta = QMetaEnum::fromType<TorcControl::Type>();
159 for (
int count = meta.keyCount() - 1 ; count >= 0; --count)
162 QStringList controlsfortype;
164 if (control->
GetType() == type)
167 if (!controlsfortype.isEmpty())
168 result.insert(TorcCoreUtils::EnumToLowerString<TorcControl::Type>(static_cast<TorcControl::Type>(type)), controlsfortype);
175 return TorcCoreUtils::EnumList<TorcControl::Type>();
QStringList GetControlTypes(void)
virtual bool Validate(void)
void SubscriberDeleted(QObject *Subscriber)
virtual TorcControl::Type GetType(void) const =0
virtual bool DownRef(void)
QVariantMap GetControlList(void)
void HandleSubscriberDeleted(QObject *Subscriber)
void Graph(QByteArray *Data)
Add this control to the state graph.
#define CONTROLS_DIRECTORY
#define LOG(_MASK_, _LEVEL_, _STRING_)
bool CheckForCircularReferences(const QString &UniqueId, const QString &Path) const
QReadWriteLock m_handlerLock
QString GetUniqueId(void)