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

#include <ball_ruleset.h>

Public Types

enum  { e_MAX_NUM_RULES = 8 * sizeof(MaskType) , BAEL_MAX_NUM_RULES = e_MAX_NUM_RULES , MAX_NUM_RULES = e_MAX_NUM_RULES }
 
typedef unsigned int MaskType
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (RuleSet, bslma::UsesBslmaAllocator)
 
 RuleSet (bslma::Allocator *basicAllocator=0)
 
 RuleSet (const RuleSet &original, bslma::Allocator *basicAllocator=0)
 
 ~RuleSet ()=default
 Destroy this object.
 
int addRule (const Rule &value)
 
int addRules (const RuleSet &rules)
 
int removeRuleById (int id)
 
int removeRule (const Rule &value)
 
int removeRules (const RuleSet &rules)
 
void removeAllRules ()
 Remove every rule in the rule set maintained by this object.
 
RuleSetoperator= (const RuleSet &rhs)
 Assign to this object the value of the specified rhs object.
 
int ruleId (const Rule &value) const
 
const RulegetRuleById (int id) const
 
int numRules () const
 
int numPredicates () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Static Public Member Functions

static int maxNumRules ()
 
static void printMask (bsl::ostream &stream, MaskType mask, int level=0, int spacesPerLevel=0)
 

Friends

bool operator== (const RuleSet &, const RuleSet &)
 
bool operator!= (const RuleSet &, const RuleSet &)
 
bsl::ostream & operator<< (bsl::ostream &, const RuleSet &)
 

Detailed Description

This class manages a set of unique rule values. Rules may be added to or removed from the set; however, rules having duplicate values will not be added. For the definition of two rules having the same value, please refer to the function-level documentation associated with the Rule::operator== function.

See ball_ruleset

Member Typedef Documentation

◆ MaskType

typedef unsigned int ball::RuleSet::MaskType

MaskType is an alias for the fundamental integral type used to indicate rule subsets compactly.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
e_MAX_NUM_RULES 
BAEL_MAX_NUM_RULES 
MAX_NUM_RULES 

Constructor & Destructor Documentation

◆ RuleSet() [1/2]

ball::RuleSet::RuleSet ( bslma::Allocator basicAllocator = 0)
explicit

Create an empty rule set. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator will be used.

◆ RuleSet() [2/2]

ball::RuleSet::RuleSet ( const RuleSet original,
bslma::Allocator basicAllocator = 0 
)

Create a RuleSet object having the same value as that of the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator will be used.

◆ ~RuleSet()

ball::RuleSet::~RuleSet ( )
default

Member Function Documentation

◆ addRule()

int ball::RuleSet::addRule ( const Rule value)

Create a new Rule object having the specified value. Return the non-negative id of this non-modifiable object on success, and a negative value otherwise. A return value of -1 indicates that another rule having this value already exists. A return value of -2 indicates that the maximum number of rules for this rule set has been reached.

◆ addRules()

int ball::RuleSet::addRules ( const RuleSet rules)

Add each rule in the specified rules to this rule set. Return the number of rules added. Note that a rule in rules will be ignored if there is an existing rule having the same value or if the number of rules in the set has reached the upper limit. Also note that if not all valid rules will fit, the (possibly empty) subset of unique values that will be added is implementation dependent.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::RuleSet::BSLMF_NESTED_TRAIT_DECLARATION ( RuleSet  ,
bslma::UsesBslmaAllocator   
)

◆ getRuleById()

const Rule * ball::RuleSet::getRuleById ( int  id) const
inline

Return the address of the rule having the specified id if such a rule exists, and 0 otherwise. The behavior is undefined unless 0 <= id < maxNumRules(). Note that rules may be assigned non-sequential identifiers, and that there may be a valid rule whose identifier is greater than numRules() (i.e., valid rules may appear anywhere in the range 0 <= id < maxNumRules()).

◆ maxNumRules()

int ball::RuleSet::maxNumRules ( )
inlinestatic

Return the maximum number of rules that can be simultaneously maintained by this object.

◆ numPredicates()

int ball::RuleSet::numPredicates ( ) const
inline

Return the total number of predicates in all rules maintained by this object.

◆ numRules()

int ball::RuleSet::numRules ( ) const
inline

Return the number of unique rules maintained in this RuleSet object. Note that this value is not the maximum identifier for the rules currently in this container.

◆ operator=()

RuleSet & ball::RuleSet::operator= ( const RuleSet rhs)

◆ print()

bsl::ostream & ball::RuleSet::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.

◆ printMask()

static void ball::RuleSet::printMask ( bsl::ostream &  stream,
MaskType  mask,
int  level = 0,
int  spacesPerLevel = 0 
)
static

Format the specified mask to the specified output stream at the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress line breaks and format the entire output on one line. If stream is initially invalid, this operation has no effect.

◆ removeAllRules()

void ball::RuleSet::removeAllRules ( )

◆ removeRule()

int ball::RuleSet::removeRule ( const Rule value)

Remove the rule having the specified value from this rule set. Return the number of rules removed (i.e., 1 on success and 0 if there is no such a rule).

◆ removeRuleById()

int ball::RuleSet::removeRuleById ( int  id)

Remove from this rule set the rule having the specified id. Return the number of rules removed (i.e., 1 on success and 0 if there is no rule whose id is id). The behavior is undefined unless 0 <= id < e_MAX_NUM_RULES.

◆ removeRules()

int ball::RuleSet::removeRules ( const RuleSet rules)

Remove each rule in the specified rules from this rule set. Return the number of rules removed.

◆ ruleId()

int ball::RuleSet::ruleId ( const Rule value) const

Return the id of the rule having the specified value if such a rule exists, and a negative value otherwise. Note that if there are multiple rules having value, the id of the first one found will be returned and the order in which rules are searched is implementation dependent.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const RuleSet ,
const RuleSet  
)
friend

Return true if the specified lhs and rhs rule sets do not have the same value, and false otherwise. Two rule sets do not have the same value if there is at least one rule that exists in one rule but does not exist in the other.

◆ operator<<

bsl::ostream & operator<< ( bsl::ostream &  ,
const RuleSet  
)
friend

Write the value of the specified rules to the specified output stream. Return the specified output stream

◆ operator==

bool operator== ( const RuleSet ,
const RuleSet  
)
friend

Return true if the specified lhs and rhs rule sets have the same value, and false otherwise. Two rule sets have the same value if every rule that exists in one rule set also exists in the other.


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