dynrules
 All Classes Functions Variables
Public Member Functions | Protected Attributes | List of all members
dynrules::Rule Class Reference

A simple rule container. More...

#include <Rule.h>

Public Member Functions

 Rule ()
 Creates a new Rule instance.
 
 Rule (int id)
 Creates a new Rule instance with an unique id.
 
 Rule (int id, std::string code)
 Creates a new Rule instance with an unique id and code.
 
 Rule (int id, double weight)
 Creates a new Rule instance with an unique id and weight.
 
 Rule (int id, std::string code, double weight)
 Creates a new Rule instance.
 
virtual ~Rule ()
 Destroys the Rule.
 
double getWeight () const
 Gets the weight of the Rule.
 
void setWeight (double weight)
 Sets the weight of the Rule.
 
bool getUsed () const
 Gets whether the Rule was used or not.
 
void setUsed (bool used)
 Sets whether the Rule was used or not.
 
int getId () const
 Gets the (unique) id of the Rule.
 
void setId (int id)
 Sets the (unique) id of the Rule.
 
std::string getCode () const
 Gets the code hold by the Rule.
 
void setCode (const std::string &code)
 Sets the code to hold by the Rule.
 
bool operator== (const Rule &rule)
 Compares the rule with another Rule.
 

Protected Attributes

int _id
 The (unique) id.
 
double _weight
 The current weight.
 
bool _used
 Usage flag indicating whether the Rule was executed.
 
std::string _code
 The code to execute.
 

Detailed Description

A simple rule container.

Rule is a simple class type that carries a weight indicator and arbitrary code data for usage in the dynamic script generation process.

Definition at line 23 of file Rule.h.

Constructor & Destructor Documentation

dynrules::Rule::Rule ( int  id)

Creates a new Rule instance with an unique id.

Parameters
idThe unique id to use.

Definition at line 22 of file Rule.cpp.

dynrules::Rule::Rule ( int  id,
std::string  code 
)

Creates a new Rule instance with an unique id and code.

Parameters
idThe unique id to use.
codeThe code hold by the Rule.

Definition at line 30 of file Rule.cpp.

dynrules::Rule::Rule ( int  id,
double  weight 
)

Creates a new Rule instance with an unique id and weight.

Parameters
idThe unique id to use.
weightThe weight of the Rule.

Definition at line 38 of file Rule.cpp.

dynrules::Rule::Rule ( int  id,
std::string  code,
double  weight 
)

Creates a new Rule instance.

Parameters
idThe unique id to use.
codeThe code hold by the Rule.
weightThe weight of the Rule.

Definition at line 46 of file Rule.cpp.

Member Function Documentation

std::string dynrules::Rule::getCode ( ) const

Gets the code hold by the Rule.

Returns
The code hold by the Rule.

Definition at line 88 of file Rule.cpp.

int dynrules::Rule::getId ( ) const

Gets the (unique) id of the Rule.

Returns
The id of the Rule.

Definition at line 78 of file Rule.cpp.

bool dynrules::Rule::getUsed ( ) const

Gets whether the Rule was used or not.

Returns
The usage state of the Rule.

Definition at line 68 of file Rule.cpp.

double dynrules::Rule::getWeight ( ) const

Gets the weight of the Rule.

Returns
The weight of the Rule.

Definition at line 58 of file Rule.cpp.

bool dynrules::Rule::operator== ( const Rule rule)

Compares the rule with another Rule.

Compares this Rule with another Rule instance. Note that this will only check, whether the id attributes of both rules are the same!

Returns
true, if the id of this Rule is equal to the id of the passed Rule, false otherwise.

Definition at line 98 of file Rule.cpp.

void dynrules::Rule::setCode ( const std::string &  code)

Sets the code to hold by the Rule.

Parameters
codeThe code to hold.

Definition at line 93 of file Rule.cpp.

void dynrules::Rule::setId ( int  id)

Sets the (unique) id of the Rule.

Parameters
idThe id to set.

Definition at line 83 of file Rule.cpp.

void dynrules::Rule::setUsed ( bool  used)

Sets whether the Rule was used or not.

Parameters
usedThe usage state to set.

Definition at line 73 of file Rule.cpp.

void dynrules::Rule::setWeight ( double  weight)

Sets the weight of the Rule.

Parameters
weightThe weight to set.

Definition at line 63 of file Rule.cpp.


The documentation for this class was generated from the following files: