📄 log_constraint_visitors.cpp
字号:
case TAO_ETCL_LE:
result = left_operand <= right_operand;
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
break;
case TAO_ETCL_GT:
result = left_operand > right_operand;
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
break;
case TAO_ETCL_GE:
result = left_operand >= right_operand;
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
break;
case TAO_ETCL_EQ:
result = left_operand == right_operand;
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
break;
case TAO_ETCL_NE:
result = left_operand != right_operand;
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
break;
case TAO_ETCL_PLUS:
this->queue_.enqueue_head (left_operand + right_operand);
break;
case TAO_ETCL_MINUS:
this->queue_.enqueue_head (left_operand - right_operand);
break;
case TAO_ETCL_MULT:
this->queue_.enqueue_head (left_operand * right_operand);
break;
case TAO_ETCL_DIV:
this->queue_.enqueue_head (left_operand / right_operand);
break;
default:
return_value = -1;
}
}
}
return return_value;
}
int
TAO_Log_Constraint_Visitor::visit_twiddle (
TAO_ETCL_Binary_Expr *binary
)
{
int return_value = -1;
TAO_ETCL_Constraint *lhs = binary->lhs ();
// Determine if the left operand is a substring of the right.
if (lhs->accept (this) == 0)
{
TAO_ETCL_Literal_Constraint left;
this->queue_.dequeue_head (left);
TAO_ETCL_Constraint *rhs = binary->rhs ();
if (rhs->accept (this) == 0)
{
TAO_ETCL_Literal_Constraint right;
this->queue_.dequeue_head (right);
CORBA::Boolean result =
(ACE_OS::strstr ((const char *) left,
(const char *) right) != 0);
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
return_value = 0;
}
}
return return_value;
}
int
TAO_Log_Constraint_Visitor::visit_in (
TAO_ETCL_Binary_Expr *binary
)
{
int return_value = -1;
TAO_ETCL_Constraint *lhs = binary->lhs ();
// Determine if the left operand is contained in the right.
if (lhs->accept (this) == 0)
{
TAO_ETCL_Literal_Constraint left;
this->queue_.dequeue_head (left);
TAO_ETCL_Constraint *rhs = binary->rhs ();
if (rhs->accept (this) == 0)
{
TAO_ETCL_Literal_Constraint bag;
this->queue_.dequeue_head (bag);
if (bag.expr_type () == TAO_ETCL_COMPONENT)
{
const CORBA::Any *component = (const CORBA::Any *) bag;
CORBA::TCKind kind = CORBA::tk_null;
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
CORBA::TypeCode_var tc = component->type ();
kind = TAO_DynAnyFactory::unalias (tc.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
return return_value;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (return_value);
CORBA::Boolean result = 0;
switch (kind)
{
case CORBA::tk_sequence:
result = this->sequence_does_contain (component,
left);
break;
case CORBA::tk_array:
result = this->array_does_contain (component,
left);
break;
case CORBA::tk_struct:
result = this->struct_does_contain (component,
left);
break;
case CORBA::tk_union:
result = this->union_does_contain (component,
left);
break;
case CORBA::tk_any:
result = this->any_does_contain (component,
left);
break;
default:
return return_value;
}
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
return_value = 0;
}
}
}
return return_value;
}
int
TAO_Log_Constraint_Visitor::visit_preference (
TAO_ETCL_Preference *
)
{
// According to OMG 00-06-20 section 2.4.1, the Notification Service
// does not use the preference operators. The method must be here
// because it is called by the ETCL node, which may be used by other
// CORBA services that do use the preference operators.
return -1;
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::sequence_does_contain (
const CORBA::Any *any,
TAO_ETCL_Literal_Constraint &item
)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
CORBA::TypeCode_var type = any->type ();
CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// The literal and the array elements must be
// of the same simple type.
CORBA::Boolean match = this->simple_type_match (item.expr_type (),
kind);
if (match == 0)
{
return 0;
}
TAO_DynSequence_i dyn_seq;
dyn_seq.init (*any
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
DynamicAny::AnySeq_var any_seq =
dyn_seq.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ULong length = any_seq->length ();
for (CORBA::ULong i = 0; i < length; ++i)
{
TAO_ETCL_Literal_Constraint element (&any_seq[i]);
if (item == element)
{
return 1;
}
}
}
ACE_CATCHANY
{
return 0;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
return 0;
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::array_does_contain (
const CORBA::Any *any,
TAO_ETCL_Literal_Constraint &item
)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
CORBA::TypeCode_var type = any->type ();
CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// The literal and the array elements must be
// of the same simple type.
CORBA::Boolean match = this->simple_type_match (item.expr_type (),
kind);
if (match == 0)
{
return 0;
}
TAO_DynArray_i dyn_array;
dyn_array.init (*any
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
DynamicAny::AnySeq_var any_seq =
dyn_array.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ULong length = any_seq->length ();
for (CORBA::ULong i = 0; i < length; ++i)
{
TAO_ETCL_Literal_Constraint element (&any_seq[i]);
if (item == element)
{
return 1;
}
}
}
ACE_CATCHANY
{
return 0;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
return 0;
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::struct_does_contain (
const CORBA::Any *any,
TAO_ETCL_Literal_Constraint &item
)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
TAO_DynStruct_i dyn_struct;
dyn_struct.init (*any
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
DynamicAny::NameValuePairSeq_var members =
dyn_struct.get_members (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ULong length = members->length ();
CORBA::TypeCode_var tc;
CORBA::TCKind kind;
for (CORBA::ULong i = 0; i < length; ++i)
{
tc = members[i].value.type ();
kind = TAO_DynAnyFactory::unalias (tc.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// The literal and the struct member must be
// of the same simple type.
CORBA::Boolean match = this->simple_type_match (item.expr_type (),
kind);
if (match == 0)
{
continue;
}
TAO_ETCL_Literal_Constraint element (&members[i].value);
if (item == element)
{
return 1;
}
}
}
ACE_CATCHANY
{
return 0;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
return 0;
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::union_does_contain (
const CORBA::Any *any,
TAO_ETCL_Literal_Constraint &item
)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
TAO_DynUnion_i dyn_union;
dyn_union.init (*any
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
DynamicAny::DynAny_var cc =
dyn_union.current_component (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::Any_var member = cc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::TypeCode_var tc = member->type ();
CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// The literal and the union member must be
// of the same simple type.
CORBA::Boolean match = this->simple_type_match (item.expr_type (),
kind);
if (match == 0)
{
return 0;
}
TAO_ETCL_Literal_Constraint element (&member.inout ());
return (item == element);
}
ACE_CATCHANY
{
return 0;
}
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
return 0;
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::any_does_contain (
const CORBA::Any *any,
TAO_ETCL_Literal_Constraint &item
)
{
const CORBA::Any *result = 0;
*any >>= result;
TAO_ETCL_Literal_Constraint element (ACE_const_cast (CORBA::Any *,
result));
return (item == element);
}
CORBA::Boolean
TAO_Log_Constraint_Visitor::simple_type_match (int expr_type,
CORBA::TCKind tc_kind)
{
switch (expr_type)
{
case TAO_ETCL_STRING:
if (tc_kind != CORBA::tk_string)
{
return 0;
}
case TAO_ETCL_DOUBLE:
if (tc_kind != CORBA::tk_double
&& tc_kind != CORBA::tk_float)
{
return 0;
}
case TAO_ETCL_INTEGER:
case TAO_ETCL_SIGNED:
if (tc_kind != CORBA::tk_short
&& tc_kind != CORBA::tk_long
&& tc_kind != CORBA::tk_longlong)
{
return 0;
}
case TAO_ETCL_UNSIGNED:
if (tc_kind != CORBA::tk_ushort
&& tc_kind != CORBA::tk_ulong
&& tc_kind != CORBA::tk_ulonglong)
{
return 0;
}
case TAO_ETCL_BOOLEAN:
if (tc_kind != CORBA::tk_boolean)
{
return 0;
}
default:
return 0;
}
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*>;
template class ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>;
template class ACE_Node<TAO_ETCL_Literal_Constraint>;
template class ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint>;
template class ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*>
#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>
#pragma instantiate ACE_Node<TAO_ETCL_Literal_Constraint>
#pragma instantiate ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint>
#pragma instantiate ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -