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

A simple memory-mapped RuleManagement implementation that does not load its rules from an external data source. More...

#include <MMapRuleManagement.h>

Inheritance diagram for dynrules::MMapRuleManagement:
dynrules::RuleManagement

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.
 
- Public Member Functions inherited from dynrules::RuleManagement
 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.
 
- Protected Attributes inherited from dynrules::RuleManagement
unsigned int _maxrules
 The maximum amount of Rule objects the RuleManagement will manage.
 

Detailed Description

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.

Constructor & Destructor Documentation

dynrules::MMapRuleManagement::MMapRuleManagement ( unsigned int  maxrules)

Creates a new MMapRuleManagement instance.

Parameters
maxrulesThe amount of Rule objects to create.

Definition at line 13 of file MMapRuleManagement.cpp.

dynrules::MMapRuleManagement::~MMapRuleManagement ( )
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.

Member Function Documentation

std::vector< Rule * > dynrules::MMapRuleManagement::loadRules ( )
virtual

Loads all existing rules.

Returns
A vector containing the Rule objects hold by this instance. The caller should not free the returned results.

Implements dynrules::RuleManagement.

Definition at line 32 of file MMapRuleManagement.cpp.

std::vector< Rule * > dynrules::MMapRuleManagement::loadRules ( unsigned int  maxrules)
virtual

Loads a specific amount of rules.

This behaves exactly like loadRules().

Parameters
maxrulesThe amount of rules to load.
Returns
A std::vector containing the loaded rules.

Implements dynrules::RuleManagement.

Definition at line 37 of file MMapRuleManagement.cpp.

bool dynrules::MMapRuleManagement::saveRules ( std::vector< Rule * >  rules)
virtual

Saves the passed rules to the underlying data source.

This does nothing.

Parameters
rulesA std::vector containing the rules to save.
Returns
true, if saving the rules was successful, false otherwise.

Implements dynrules::RuleManagement.

Definition at line 42 of file MMapRuleManagement.cpp.


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