📄 constraint_visitors.h
字号:
public:
/// Constructor.
TAO_Constraint_Evaluator (void);
/**
* Evaluate returns 1 if the offer satisfies the constraints
* represented by the the expression tree rooted at <root>, 0 if it
* doesn't. If an error occurs during process, the constraint
* automatically fails.
*/
CORBA::Boolean evaluate_constraint (TAO_Constraint* root);
/// The result of the preference evaluation is stored in result. The
/// method returns 0 upon success, -1 upon failure.
int evaluate_preference (TAO_Constraint* root,
TAO_Literal_Constraint& result);
// = Visitor Methods
virtual int visit_constraint (TAO_Unary_Constraint* constraint);
virtual int visit_with (TAO_Unary_Constraint* unary_with);
virtual int visit_min (TAO_Unary_Constraint* unary_min);
virtual int visit_max (TAO_Unary_Constraint* unary_max);
virtual int visit_first (TAO_Noop_Constraint* noop_first);
virtual int visit_random (TAO_Noop_Constraint* noop_random);
/**
* Takes the logical and of the results of both operands. Note that
* in the case where the left operand returns zero, the result is
* immediately known.
*/
virtual int visit_and (TAO_Binary_Constraint* boolean_and);
/**
* Takes the logical or of the results of both operands. Note that
* in the case where the left operand returns one, the result is
* immediately known.
*/
virtual int visit_or (TAO_Binary_Constraint* boolean_or);
/// Logically negates the value of the operand.
virtual int visit_not (TAO_Unary_Constraint* unary_not);
/// The property exists if its name is bound to a value in the
/// <props_> map.
virtual int visit_exist (TAO_Unary_Constraint* unary_exist);
/// Mathematically negates the return value the operand.
virtual int visit_unary_minus (TAO_Unary_Constraint* unary_minus);
/// Add the results of evaluating the left and right operands.
virtual int visit_add (TAO_Binary_Constraint* boolean_add);
/// Subtract the results of evaluating the left and right operands.
virtual int visit_sub (TAO_Binary_Constraint* boolean_sub);
/// Multiply the results of evaluating the left and right operands.
virtual int visit_mult (TAO_Binary_Constraint* boolean_mult);
/// Divide the results of evaluating the left and right operands.
virtual int visit_div (TAO_Binary_Constraint* boolean_div);
/// Determines if the right operand is a substring of the left.
virtual int visit_twiddle (TAO_Binary_Constraint* binary_twiddle);
/// Determines if the sequence represented by the right operand
/// contains the left operand.
virtual int visit_in (TAO_Binary_Constraint* binary_in);
// = Compare the results of evaluating left and right operands.
virtual int visit_less_than (TAO_Binary_Constraint* boolean_lt);
virtual int visit_less_than_equal (TAO_Binary_Constraint* boolean_lte);
virtual int visit_greater_than (TAO_Binary_Constraint* boolean_gt);
virtual int visit_greater_than_equal (TAO_Binary_Constraint* boolean_gte);
virtual int visit_equal (TAO_Binary_Constraint* boolean_eq);
virtual int visit_not_equal (TAO_Binary_Constraint* boolean_neq);
/// Copy the value of the literal into the result container.
virtual int visit_literal (TAO_Literal_Constraint* literal);
/// Copy the value of the property into the result container.
virtual int visit_property (TAO_Property_Constraint* literal);
private:
class TAO_Trading_Export Operand_Queue :
public ACE_Unbounded_Queue <TAO_Literal_Constraint>
// = TITLE
// A queue adapter with methods to setting and getting operands
// from the expression evaluation results.
{
public:
Operand_Queue (void);
/// In a binary operation, obtain the left operand.
TAO_Literal_Constraint& get_left_operand (void);
/// In a binary operation, obtain the right operand.
TAO_Literal_Constraint& get_right_operand (void);
/// In a unary operation, obtain the only operand.
TAO_Literal_Constraint& get_operand (void);
/// Remove an operand from the queue.
void dequeue_operand (void);
};
/// Method for performing a arithmetic or comparison operation.
void do_the_op (int operation);
/// Method for evaluating a binary operation.
int visit_bin_op (TAO_Binary_Constraint* op, int operation);
/// Determine if sequence contains <element>, a literal of the same
/// simple type as <sequence_type>. Return 1 in this eventuality.
CORBA::Boolean sequence_does_contain (CORBA::Any* sequence,
TAO_Literal_Constraint& element);
/// Disallow copying.
TAO_Constraint_Evaluator (const TAO_Constraint_Evaluator&);
TAO_Constraint_Evaluator& operator= (const TAO_Constraint_Evaluator&);
protected:
/// The map of property names to their values for a property.
TAO_Lookup_Table props_;
/// The result of a non_boolean operation.
Operand_Queue queue_;
};
// Forward declaration
template <class ELEMENT_TYPE> class TAO_Element_Equal;
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::Short>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::Short element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::UShort>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::UShort element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::Long>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::Long element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::ULong>
{
public:
/// Calls the correct method on dyn_seq to extract the element type, then
/// uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::ULong element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::Float>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::Float element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::Double>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::Double element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<CORBA::Boolean>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
CORBA::Boolean element) const;
};
ACE_TEMPLATE_SPECIALIZATION
class TAO_Element_Equal<const char*>
{
public:
/// Calls the correct method on dyn_seq to extract the element type,
/// then uses the appropriate form of equals comparison.
int operator () (TAO_DynSequence_i& dyn_any,
const char* element) const;
};
#include /**/ "ace/post.h"
#endif /* CONSTRAINT_VISITORS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -