diff --git a/libguh/libguh.pro b/libguh/libguh.pro index 1dc3eb62..8da0ac89 100644 --- a/libguh/libguh.pro +++ b/libguh/libguh.pro @@ -34,6 +34,7 @@ SOURCES += plugin/device.cpp \ types/paramtype.cpp \ types/param.cpp \ types/paramdescriptor.cpp \ + types/ruleactionparam.cpp \ types/statedescriptor.cpp \ network/networkmanager.cpp \ @@ -64,6 +65,7 @@ HEADERS += plugin/device.h \ types/paramtype.h \ types/param.h \ types/paramdescriptor.h \ + types/ruleactionparam.h \ types/statedescriptor.h \ typeutils.h \ network/networkmanager.h \ diff --git a/libguh/types/ruleactionparam.cpp b/libguh/types/ruleactionparam.cpp new file mode 100644 index 00000000..53359cd3 --- /dev/null +++ b/libguh/types/ruleactionparam.cpp @@ -0,0 +1,69 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! + \class RuleActionParam + \brief Holds the parameters for a rule action. + + \ingroup types + \inmodule libguh + + A RuleActionParam allows in rules to take over an \l{Event} parameter into a rule + \l{Action}. + + \sa Rule, Action, Param, ParamType, ParamDescriptor +*/ + +#include "ruleactionparam.h" + +/*! Constructs a \l{RuleActionParam} with the given \a param. + * \sa Param, */ +RuleActionParam::RuleActionParam(const Param ¶m) +{ + m_name = param.name(); + m_value = param.value(); +} + +/*! Constructs a \l{RuleActionParam} with the given \a name, \a value and \a eventId. + * \sa Param, Event, */ +RuleActionParam::RuleActionParam(const QString &name, const QVariant &value, const EventId &eventId) : + m_name(name), + m_value(value), + m_eventId(eventId) +{ +} + +/*! Return the EventId of the \l{Event} with the \l{Param} which will be taken over in the \l{Rule}{rule} \l{Action}{action}. */ +EventId RuleActionParam::eventId() const +{ + return m_eventId; +} + +/*! Sets the \a eventId of the \l{Event} with the \l{Param} which will be taken over in the \l{Rule}{rule} \l{Action}{action}. */ +void RuleActionParam::setEventId(const EventId &eventId) +{ + m_eventId = eventId; +} + +/*! Writes the name and value of the given \a param to \a dbg. */ +QDebug operator<<(QDebug dbg, const RuleActionParam ¶m) +{ + dbg.nospace() << "RuleActionParam(Name: " << param.name() << ", Value:" << param.value() << ", EventId:" << param.eventId().toString() << ")"; + + return dbg.space(); +} diff --git a/libguh/types/ruleactionparam.h b/libguh/types/ruleactionparam.h new file mode 100644 index 00000000..7795ae5a --- /dev/null +++ b/libguh/types/ruleactionparam.h @@ -0,0 +1,43 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef RULEACTIONPARAM_H +#define RULEACTIONPARAM_H + +#include + +#include "param.h" +#include "typeutils.h" + +class RuleActionParam : public Param +{ +public: + RuleActionParam(const Param ¶m); + RuleActionParam(const QString &name = QString(), const QVariant &value = QVariant(), const EventId &eventId = EventId()); + + EventId eventId() const; + void setEventId(const EventId &eventId); + +private: + EventId m_eventId; + +}; +Q_DECLARE_METATYPE(RuleActionParam) +QDebug operator<<(QDebug dbg, const RuleActionParam ¶ms); + +#endif // RULEACTIONPARAM_H