BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::AttributeContext_RuleEvaluationCache Class Reference

#include <ball_attributecontext.h>

Public Member Functions

 AttributeContext_RuleEvaluationCache ()
 Create an empty rule evaluation cache having a sequence number of -1.
 
 ~AttributeContext_RuleEvaluationCache ()=default
 Destroy this object.
 
void clear ()
 
RuleSet::MaskType update (bsls::Types::Int64 sequenceNumber, RuleSet::MaskType relevantRulesMask, const RuleSet &rules, const AttributeContainerList &attributes)
 
bool isDataAvailable (bsls::Types::Int64 sequenceNumber, RuleSet::MaskType relevantRulesMask) const
 
RuleSet::MaskType knownActiveRules () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Detailed Description

This is an implementation type of AttributeContext and should not be used by clients of this package. A rule evaluation cache is a mechanism for evaluating and caching whether a rule is active. A rule is considered active if all of its attributes are satisfied by the collection of attributes held in a AttributeContainerList object (i.e., Rule::evaluate returns true for the AttributeContainerList object). The rules this cache evaluates are contained in a RuleSet object. RuleSet::MaskType is a bit mask for a rule set, where each bit is a boolean value associated with the rule at the corresponding index in a rule set. An AttributeContext determines, using the isDataAvailable method, if a particular set of rules (described using a bit mask) have already been evaluated. A context accesses the current cache of rule evaluations using the knownActiveRules method. Finally, a context updates the cache of rule evaluations using the update method. Note that the isDataAvailable method should be used prior to using knownActiveRules in order to ensure the relevant rules have been evaluated and that those evaluations are up-to-date.

See ball_attributecontext

Constructor & Destructor Documentation

◆ AttributeContext_RuleEvaluationCache()

ball::AttributeContext_RuleEvaluationCache::AttributeContext_RuleEvaluationCache ( )
inline

◆ ~AttributeContext_RuleEvaluationCache()

ball::AttributeContext_RuleEvaluationCache::~AttributeContext_RuleEvaluationCache ( )
default

Member Function Documentation

◆ clear()

void ball::AttributeContext_RuleEvaluationCache::clear ( )
inline

Clear any currently cached rule evaluation data, restoring this object to its default constructed state (empty).

◆ isDataAvailable()

bool ball::AttributeContext_RuleEvaluationCache::isDataAvailable ( bsls::Types::Int64  sequenceNumber,
RuleSet::MaskType  relevantRulesMask 
) const
inline

Return true if this cache contains up-to-date cached rule evaluations having the specified sequenceNumber for the set of rules indicated by the specified relevantRulesMask bit mask, and false otherwise.

◆ knownActiveRules()

RuleSet::MaskType ball::AttributeContext_RuleEvaluationCache::knownActiveRules ( ) const
inline

Return a bit mask indicating those rules, from the set of rules provided in the last call to update, that are known to be active (as of that last call to update). If a bit in the returned value is set to 1, the rule at the corresponding index is active; however, if a bit is set to 0, the corresponding rule is either not active or has not been evaluated. Note that isDataAvailable should be called to test if this cache contains up-to-date evaluated rule information for the rules in which they are interested before using the result of this method.

◆ print()

bsl::ostream & ball::AttributeContext_RuleEvaluationCache::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ update()

RuleSet::MaskType ball::AttributeContext_RuleEvaluationCache::update ( bsls::Types::Int64  sequenceNumber,
RuleSet::MaskType  relevantRulesMask,
const RuleSet rules,
const AttributeContainerList attributes 
)

Update, for the specified sequenceNumber, the cache for those rules indicated by the specified relevantRulesMask bit mask in the specified set of rules, by evaluating those rules for the specified attributes; return the bit mask indicating those rules that are known to be active. If a bit in the returned bit mask value is set to 1, the rule at the corresponding index in rules is "active"; however, if a bit is set to 0, the corresponding rule is either not active or has not been evaluated. This operation does, however, guarantee that all the rules indicated by the relevantRulesMask will be evaluated. A particular rule is considered "active" if all of its attributes are satisfied by attributes (i.e., if Rule::evaluate returns true for attributes). The behavior is undefined unless rules is not modified during this operation (i.e., any lock associated with rules must be locked during this operation).


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