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

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

#include <MMapRuleManager.h>

Inheritance diagram for dynrules::MMapRuleManager:
dynrules::RuleManager

Public Member Functions

 MMapRuleManager (unsigned int maxrules)
 Creates a new MMapRuleManager instance. More...
 
virtual ~MMapRuleManager ()
 Destroys the MMapRuleManager. More...
 
std::vector< Rule * > loadRules ()
 Loads all existing rules. More...
 
std::vector< Rule * > loadRules (unsigned int maxrules)
 Loads a specific amount of rules. More...
 
bool saveRules (std::vector< Rule * > rules)
 Saves the passed rules to the underlying data source. More...
 
- Public Member Functions inherited from dynrules::RuleManager
 RuleManager (unsigned int maxrules)
 Creates a new RuleManager instance. More...
 
virtual ~RuleManager ()
 Destroys the RuleManager. More...
 
bool saveRulesHintFile (std::string filename, LearnSystem &lsystem) const
 Saves a LearnSystem/RuleSet combination to a physical file. More...
 
unsigned int getMaxRules () const
 Gets the maximum number of rules, an instance will deal with. More...
 

Protected Attributes

std::vector< Rule * > _rules
 In-memory set of Rule objects to use.
 
- Protected Attributes inherited from dynrules::RuleManager
unsigned int _maxrules
 The maximum amount of Rule objects the RuleManager will manage.
 

Detailed Description

A simple memory-mapped RuleManager 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 MMapRuleManager 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 MMapRuleManager.h.

Constructor & Destructor Documentation

dynrules::MMapRuleManager::MMapRuleManager ( unsigned int  maxrules)

Creates a new MMapRuleManager instance.

Parameters
maxrulesThe amount of Rule objects to create.

Definition at line 13 of file MMapRuleManager.cpp.

dynrules::MMapRuleManager::~MMapRuleManager ( )
virtual

Destroys the MMapRuleManager.

Destroys the MMapRuleManager and frees the memory hold by the attached Rule instances.

Definition at line 22 of file MMapRuleManager.cpp.

Member Function Documentation

std::vector< Rule * > dynrules::MMapRuleManager::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::RuleManager.

Definition at line 32 of file MMapRuleManager.cpp.

std::vector< Rule * > dynrules::MMapRuleManager::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::RuleManager.

Definition at line 37 of file MMapRuleManager.cpp.

bool dynrules::MMapRuleManager::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::RuleManager.

Definition at line 42 of file MMapRuleManager.cpp.


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