A simple memory-mapped RuleManagement implementation that does not load its rules from an external data source. More...
#include <MMapRuleManagement.h>
Public Member Functions | |
MMapRuleManagement (unsigned int maxrules) | |
Creates a new MMapRuleManagement instance. | |
virtual | ~MMapRuleManagement () |
Destroys the MMapRuleManagement. | |
std::vector< Rule * > | loadRules () |
Loads all existing rules. | |
std::vector< Rule * > | loadRules (unsigned int maxrules) |
Loads a specific amount of rules. | |
bool | saveRules (std::vector< Rule * > rules) |
Saves the passed rules to the underlying data source. | |
![]() | |
RuleManagement (unsigned int maxrules) | |
Creates a new RuleManagement instance. | |
virtual | ~RuleManagement () |
Destroys the RuleManagement. | |
bool | saveRulesHintFile (std::string filename, LearnSystem &lsystem) const |
Saves a LearnSystem/RuleSet combination to a physical file. | |
unsigned int | getMaxRules () const |
Gets the maximum number of rules, an instance will deal with. | |
Protected Attributes | |
std::vector< Rule * > | _rules |
In-memory set of Rule objects to use. | |
![]() | |
unsigned int | _maxrules |
The maximum amount of Rule objects the RuleManagement will manage. | |
A simple memory-mapped RuleManagement implementation that does not load its rules from an external data source.
It is an extremely useful class for testing rules and basic algorithms, but due to the in-memory management of all rules, it should not be used in a productive environment, especially if large rule sets have to be managed.
By default, the MMapRuleManagement will reserve enough memory for the rules to manage, when it is constructed. It will NOT fill the rules with useful values though. It is up to caller to use loadRules() afterwards and fill the returned Rule instances with the necessary data.
Definition at line 29 of file MMapRuleManagement.h.
dynrules::MMapRuleManagement::MMapRuleManagement | ( | unsigned int | maxrules | ) |
Creates a new MMapRuleManagement instance.
maxrules | The amount of Rule objects to create. |
Definition at line 13 of file MMapRuleManagement.cpp.
|
virtual |
Destroys the MMapRuleManagement.
Destroys the MMapRuleManagement and frees the memory hold by the attached Rule instances.
Definition at line 22 of file MMapRuleManagement.cpp.
|
virtual |
Loads all existing rules.
Implements dynrules::RuleManagement.
Definition at line 32 of file MMapRuleManagement.cpp.
|
virtual |
Loads a specific amount of rules.
This behaves exactly like loadRules().
maxrules | The amount of rules to load. |
Implements dynrules::RuleManagement.
Definition at line 37 of file MMapRuleManagement.cpp.
|
virtual |
Saves the passed rules to the underlying data source.
This does nothing.
rules | A std::vector containing the rules to save. |
Implements dynrules::RuleManagement.
Definition at line 42 of file MMapRuleManagement.cpp.