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();
}
/*!
\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 &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"
/*! 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 &param, 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();

View File

@ -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 &param, *this) {

View File

@ -174,7 +174,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap &params)
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 &params)
// 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);
}
}

View File

@ -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}

View File

@ -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.
*/

View File

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