add documentation

This commit is contained in:
Simon Stürz 2015-03-12 15:50:41 +01:00 committed by Michael Zanetti
parent 0603b8a3b7
commit a29b3a75eb
7 changed files with 50 additions and 10 deletions

View File

@ -86,6 +86,16 @@ QDebug operator<<(QDebug dbg, const ParamList &params)
return dbg.space(); 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. */ /*! Returns true if this Param contains a Param with the given \a paramName. */
bool ParamList::hasParam(const QString &paramName) const bool ParamList::hasParam(const QString &paramName) const
{ {

View File

@ -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" #include "ruleaction.h"
/*! Constructs a RuleAction with the given by \a actionTypeId and \a deviceId. */
RuleAction::RuleAction(const ActionTypeId &actionTypeId, const DeviceId &deviceId) : RuleAction::RuleAction(const ActionTypeId &actionTypeId, const DeviceId &deviceId) :
m_id(ActionId::createActionId()), m_id(ActionId::createActionId()),
m_actionTypeId(actionTypeId), 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) : RuleAction::RuleAction(const RuleAction &other) :
m_id(other.id()), m_id(other.id()),
m_actionTypeId(other.actionTypeId()), m_actionTypeId(other.actionTypeId()),
@ -35,16 +49,19 @@ RuleAction::RuleAction(const RuleAction &other) :
} }
/*! Return the ActionId of this RuleAction.*/
ActionId RuleAction::id() const ActionId RuleAction::id() const
{ {
return m_id; return m_id;
} }
/*! Return true, if the actionTypeId and the deviceId of this RuleAction are valid (set).*/
bool RuleAction::isValid() const bool RuleAction::isValid() const
{ {
return !m_actionTypeId.isNull() && !m_deviceId.isNull(); 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 bool RuleAction::isEventBased() const
{ {
foreach (const RuleActionParam &param, m_ruleActionParams) { foreach (const RuleActionParam &param, m_ruleActionParams) {
@ -55,6 +72,8 @@ bool RuleAction::isEventBased() const
return false; return false;
} }
/*! Converts this \l{RuleAction} to a normal \l{Action}.
* \sa Action, */
Action RuleAction::toAction() const Action RuleAction::toAction() const
{ {
Action action(m_actionTypeId, m_deviceId); Action action(m_actionTypeId, m_deviceId);
@ -69,26 +88,35 @@ Action RuleAction::toAction() const
return action; return action;
} }
/*! Returns the actionTypeId of this RuleAction. */
ActionTypeId RuleAction::actionTypeId() const ActionTypeId RuleAction::actionTypeId() const
{ {
return m_actionTypeId; return m_actionTypeId;
} }
/*! Returns the deviceId of this RuleAction. */
DeviceId RuleAction::deviceId() const DeviceId RuleAction::deviceId() const
{ {
return m_deviceId; return m_deviceId;
} }
/*! Returns the \l{RuleActionParamList} of this RuleAction.
* \sa RuleActionParam, */
RuleActionParamList RuleAction::ruleActionParams() const RuleActionParamList RuleAction::ruleActionParams() const
{ {
return m_ruleActionParams; return m_ruleActionParams;
} }
/*! Set the \l{RuleActionParamList} of this RuleAction to the given \a ruleActionParams.
* \sa RuleActionParam, */
void RuleAction::setRuleActionParams(const RuleActionParamList &ruleActionParams) void RuleAction::setRuleActionParams(const RuleActionParamList &ruleActionParams)
{ {
m_ruleActionParams = 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 RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName) const
{ {
foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) { foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) {
@ -99,6 +127,7 @@ RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName)
return RuleActionParam(QString()); return RuleActionParam(QString());
} }
/*! Copy the data to a \l{RuleAction} from an \a other rule action. */
void RuleAction::operator=(const RuleAction &other) void RuleAction::operator=(const RuleAction &other)
{ {
m_id = other.id(); m_id = other.id();

View File

@ -100,7 +100,6 @@ QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam)
} }
// ActionTypeParamList // ActionTypeParamList
/*! /*!
\class RuleActionParamList \class RuleActionParamList
\brief Holds a list of \l{RuleActionParam}{RuleActionParams} \brief Holds a list of \l{RuleActionParam}{RuleActionParams}
@ -111,7 +110,7 @@ QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam)
\sa RuleActionParam, RuleAction, \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 bool RuleActionParamList::hasParam(const QString &ruleActionParamName) const
{ {
foreach (const RuleActionParam &param, *this) { foreach (const RuleActionParam &param, *this) {

View File

@ -174,7 +174,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap &params)
if (eventDescriptorList.isEmpty()) { if (eventDescriptorList.isEmpty()) {
QVariantMap returns; QVariantMap returns;
qWarning() << "RuleAction" << ruleAction.actionTypeId() << "contains an eventTypeId, but there are no eventDescriptors."; 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); return createReply(returns);
} }
// now check if this eventType is in the eventDescriptorList of this rule // now check if this eventType is in the eventDescriptorList of this rule
@ -186,7 +186,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap &params)
// the given eventTypeId is not in the eventDescriptorList // the given eventTypeId is not in the eventDescriptorList
QVariantMap returns; QVariantMap returns;
qWarning() << "eventTypeId from RuleAction" << ruleAction.actionTypeId() << "missing in eventDescriptors."; 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); return createReply(returns);
} }
} }

View File

@ -20,7 +20,7 @@
\class Rule \class Rule
\brief This class represents a rule. \brief This class represents a rule.
\ingroup rules \ingroup core
\inmodule server \inmodule server
A Rule is always triggered by an \l{EventDescriptor}, has \l{State}{States} A Rule is always triggered by an \l{EventDescriptor}, has \l{State}{States}

View File

@ -21,7 +21,7 @@
\brief The Engine that evaluates \l{Rule}{Rules} and finds \brief The Engine that evaluates \l{Rule}{Rules} and finds
\l{Action}{Actions} to be executed. \l{Action}{Actions} to be executed.
\ingroup rules \ingroup core
\inmodule server \inmodule server
You can add, remove and update rules and query the engine for actions to be executed You can add, remove and update rules and query the engine for actions to be executed
@ -57,12 +57,14 @@
\value RuleErrorInvalidRuleFormat \value RuleErrorInvalidRuleFormat
The format of the rule is not valid. (i.e. add \l{Rule} with exitActions and eventDescriptors) The format of the rule is not valid. (i.e. add \l{Rule} with exitActions and eventDescriptors)
\value RuleErrorMissingParameter \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 /*! \enum RuleEngine::RemovePolicy
\value RemovePolicyCascade \value RemovePolicyCascade
Remove the whole Rule. Remove the whole \l{Rule}.
\value RemovePolicyUpdate \value RemovePolicyUpdate
Remove a \l{Device} from a rule. Remove a \l{Device} from a rule.
*/ */

View File

@ -43,7 +43,7 @@ public:
RuleErrorInvalidParameter, RuleErrorInvalidParameter,
RuleErrorInvalidRuleFormat, RuleErrorInvalidRuleFormat,
RuleErrorMissingParameter, RuleErrorMissingParameter,
RuleErrorInvalidRuleActionPatameter RuleErrorInvalidRuleActionParameter
}; };
enum RemovePolicy { enum RemovePolicy {