From a29b3a75ebf0532fa05a5b3588916618df958c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 12 Mar 2015 15:50:41 +0100 Subject: [PATCH] add documentation --- libguh/types/param.cpp | 10 ++++++++++ libguh/types/ruleaction.cpp | 31 ++++++++++++++++++++++++++++++- libguh/types/ruleactionparam.cpp | 3 +-- server/jsonrpc/ruleshandler.cpp | 4 ++-- server/rule.cpp | 2 +- server/ruleengine.cpp | 8 +++++--- server/ruleengine.h | 2 +- 7 files changed, 50 insertions(+), 10 deletions(-) diff --git a/libguh/types/param.cpp b/libguh/types/param.cpp index 05500fbd..3c55c61e 100644 --- a/libguh/types/param.cpp +++ b/libguh/types/param.cpp @@ -86,6 +86,16 @@ QDebug operator<<(QDebug dbg, const ParamList ¶ms) return dbg.space(); } +/*! + \class ParamList + \brief Holds a list of \l{Param}{Params} + + \ingroup types + \inmodule libguh + + \sa Param, +*/ + /*! Returns true if this Param contains a Param with the given \a paramName. */ bool ParamList::hasParam(const QString ¶mName) const { diff --git a/libguh/types/ruleaction.cpp b/libguh/types/ruleaction.cpp index b01387c5..92776c91 100644 --- a/libguh/types/ruleaction.cpp +++ b/libguh/types/ruleaction.cpp @@ -16,8 +16,22 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/*! + \class RuleAction + \brief Describes an action for a \l{Rule}. + + \ingroup types + \inmodule libguh + + A RuleAction describes a special form of an \l{Action} for a \l{Rule}. The main difference is + the \l{RuleActionParam}, which allows to use an EventTypeId within a \l{Rule} to execute this \l{RuleAction}. + + \sa Rule, RuleActionParam, +*/ + #include "ruleaction.h" +/*! Constructs a RuleAction with the given by \a actionTypeId and \a deviceId. */ RuleAction::RuleAction(const ActionTypeId &actionTypeId, const DeviceId &deviceId) : m_id(ActionId::createActionId()), m_actionTypeId(actionTypeId), @@ -25,7 +39,7 @@ RuleAction::RuleAction(const ActionTypeId &actionTypeId, const DeviceId &deviceI { } - +/*! Constructs a copy of the given \a other RuleAction. */ RuleAction::RuleAction(const RuleAction &other) : m_id(other.id()), m_actionTypeId(other.actionTypeId()), @@ -35,16 +49,19 @@ RuleAction::RuleAction(const RuleAction &other) : } +/*! Return the ActionId of this RuleAction.*/ ActionId RuleAction::id() const { return m_id; } +/*! Return true, if the actionTypeId and the deviceId of this RuleAction are valid (set).*/ bool RuleAction::isValid() const { return !m_actionTypeId.isNull() && !m_deviceId.isNull(); } +/*! Return true, if this RuleAction contains a \l{RuleActionParam} which is based on an EventTypeId.*/ bool RuleAction::isEventBased() const { foreach (const RuleActionParam ¶m, m_ruleActionParams) { @@ -55,6 +72,8 @@ bool RuleAction::isEventBased() const return false; } +/*! Converts this \l{RuleAction} to a normal \l{Action}. + * \sa Action, */ Action RuleAction::toAction() const { Action action(m_actionTypeId, m_deviceId); @@ -69,26 +88,35 @@ Action RuleAction::toAction() const return action; } +/*! Returns the actionTypeId of this RuleAction. */ ActionTypeId RuleAction::actionTypeId() const { return m_actionTypeId; } +/*! Returns the deviceId of this RuleAction. */ DeviceId RuleAction::deviceId() const { return m_deviceId; } +/*! Returns the \l{RuleActionParamList} of this RuleAction. + * \sa RuleActionParam, */ RuleActionParamList RuleAction::ruleActionParams() const { return m_ruleActionParams; } +/*! Set the \l{RuleActionParamList} of this RuleAction to the given \a ruleActionParams. + * \sa RuleActionParam, */ void RuleAction::setRuleActionParams(const RuleActionParamList &ruleActionParams) { m_ruleActionParams = ruleActionParams; } +/*! Returns the \l{RuleActionParam} of this RuleAction with the given \a ruleActionParamName. + * If there is no \l{RuleActionParam} with th given name an invalid \l{RuleActionParam} will be returnend. + * \sa RuleActionParam, */ RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName) const { foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) { @@ -99,6 +127,7 @@ RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName) return RuleActionParam(QString()); } +/*! Copy the data to a \l{RuleAction} from an \a other rule action. */ void RuleAction::operator=(const RuleAction &other) { m_id = other.id(); diff --git a/libguh/types/ruleactionparam.cpp b/libguh/types/ruleactionparam.cpp index a735a77a..b83da7bd 100644 --- a/libguh/types/ruleactionparam.cpp +++ b/libguh/types/ruleactionparam.cpp @@ -100,7 +100,6 @@ QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam) } // ActionTypeParamList - /*! \class RuleActionParamList \brief Holds a list of \l{RuleActionParam}{RuleActionParams} @@ -111,7 +110,7 @@ QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam) \sa RuleActionParam, RuleAction, */ -/*! Returns true if this \l{RuleActionParamList} contains a RuleActionParam with the given \a paramName. */ +/*! Returns true if this \l{RuleActionParamList} contains a \l{RuleActionParam} with the given \a ruleActionParamName. */ bool RuleActionParamList::hasParam(const QString &ruleActionParamName) const { foreach (const RuleActionParam ¶m, *this) { diff --git a/server/jsonrpc/ruleshandler.cpp b/server/jsonrpc/ruleshandler.cpp index 8a5ec6aa..73c7e19e 100644 --- a/server/jsonrpc/ruleshandler.cpp +++ b/server/jsonrpc/ruleshandler.cpp @@ -174,7 +174,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms) if (eventDescriptorList.isEmpty()) { QVariantMap returns; qWarning() << "RuleAction" << ruleAction.actionTypeId() << "contains an eventTypeId, but there are no eventDescriptors."; - returns.insert("ruleErorr", JsonTypes::ruleErrorToString(RuleEngine::RuleErrorInvalidRuleActionPatameter)); + returns.insert("ruleErorr", JsonTypes::ruleErrorToString(RuleEngine::RuleErrorInvalidRuleActionParameter)); return createReply(returns); } // now check if this eventType is in the eventDescriptorList of this rule @@ -186,7 +186,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms) // the given eventTypeId is not in the eventDescriptorList QVariantMap returns; qWarning() << "eventTypeId from RuleAction" << ruleAction.actionTypeId() << "missing in eventDescriptors."; - returns.insert("ruleErorr", JsonTypes::ruleErrorToString(RuleEngine::RuleErrorInvalidRuleActionPatameter)); + returns.insert("ruleErorr", JsonTypes::ruleErrorToString(RuleEngine::RuleErrorInvalidRuleActionParameter)); return createReply(returns); } } diff --git a/server/rule.cpp b/server/rule.cpp index e63bb009..8ebe10e0 100644 --- a/server/rule.cpp +++ b/server/rule.cpp @@ -20,7 +20,7 @@ \class Rule \brief This class represents a rule. - \ingroup rules + \ingroup core \inmodule server A Rule is always triggered by an \l{EventDescriptor}, has \l{State}{States} diff --git a/server/ruleengine.cpp b/server/ruleengine.cpp index a4af338d..b431fec6 100644 --- a/server/ruleengine.cpp +++ b/server/ruleengine.cpp @@ -21,7 +21,7 @@ \brief The Engine that evaluates \l{Rule}{Rules} and finds \l{Action}{Actions} to be executed. - \ingroup rules + \ingroup core \inmodule server You can add, remove and update rules and query the engine for actions to be executed @@ -57,12 +57,14 @@ \value RuleErrorInvalidRuleFormat The format of the rule is not valid. (i.e. add \l{Rule} with exitActions and eventDescriptors) \value RuleErrorMissingParameter - One of the given \l{Param}s is missing. + One of the given \l{Param}{Params} is missing. + \value RuleErrorInvalidRuleActionParameter + One of the given \l{RuleActionParam}{RuleActionParams} is not valid. */ /*! \enum RuleEngine::RemovePolicy \value RemovePolicyCascade - Remove the whole Rule. + Remove the whole \l{Rule}. \value RemovePolicyUpdate Remove a \l{Device} from a rule. */ diff --git a/server/ruleengine.h b/server/ruleengine.h index 942da597..42961eda 100644 --- a/server/ruleengine.h +++ b/server/ruleengine.h @@ -43,7 +43,7 @@ public: RuleErrorInvalidParameter, RuleErrorInvalidRuleFormat, RuleErrorMissingParameter, - RuleErrorInvalidRuleActionPatameter + RuleErrorInvalidRuleActionParameter }; enum RemovePolicy {