コード例 #1
0
CORBA::Boolean
TAO_Log_Constraint_Visitor::struct_does_contain (
    const CORBA::Any *any,
    TAO_ETCL_Literal_Constraint &item
)
{
    try
    {
        TAO_DynStruct_i dyn_struct;
        dyn_struct.init (*any);

        DynamicAny::NameValuePairSeq_var members =
            dyn_struct.get_members ();

        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 ());

            // 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)
            {
                return false;
            }

            TAO_ETCL_Literal_Constraint element (&members[i].value);

            if (item == element)
            {
                return true;
            }
        }
    }
    catch (const CORBA::Exception&)
    {
        return false;
    }

    return false;
}
コード例 #2
0
CORBA::Boolean
TAO_Log_Constraint_Visitor::array_does_contain (
    const CORBA::Any *any,
    TAO_ETCL_Literal_Constraint &item
)
{
    try
    {
        CORBA::TypeCode_var type = any->type ();
        CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in ());

        // 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)
        {
            return false;
        }


        TAO_DynArray_i dyn_array;
        dyn_array.init (*any);

        DynamicAny::AnySeq_var any_seq = dyn_array.get_elements ();

        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 true;
            }
        }
    }
    catch (const CORBA::Exception&)
    {
        return false;
    }

    return false;
}
コード例 #3
0
CORBA::Boolean
TAO_Log_Constraint_Visitor::union_does_contain (
    const CORBA::Any *any,
    TAO_ETCL_Literal_Constraint &item
)
{
    try
    {
        TAO_DynUnion_i dyn_union;
        dyn_union.init (*any);

        DynamicAny::DynAny_var cc =
            dyn_union.current_component ();

        CORBA::Any_var member = cc->to_any ();

        CORBA::TypeCode_var tc = member->type ();
        CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());

        // 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)
        {
            return false;
        }

        TAO_ETCL_Literal_Constraint element (&member.inout ());

        return (item == element);
    }
    catch (const CORBA::Exception&)
    {
        return false;
    }
}
コード例 #4
0
int
TAO_Log_Constraint_Visitor::visit_in (
    ETCL_Binary_Expr *binary)
{
  int return_value = -1;
  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);

      ETCL_Constraint *rhs = binary->rhs ();

      if (rhs->accept (this) == 0)
        {
          TAO_ETCL_Literal_Constraint bag;
          this->queue_.dequeue_head (bag);

          if (bag.expr_type () == ETCL_COMPONENT)
            {
              CORBA::Any_ptr any_ptr = 0;
              ACE_NEW_RETURN (any_ptr,
                              CORBA::Any,
                              -1);

              CORBA::Any_var component = any_ptr;
              component->replace (bag);
              component->impl ()->_add_ref ();
              CORBA::TCKind kind = CORBA::tk_null;

              try
                {
                  CORBA::TypeCode_var tc = component->type ();
                  kind = TAO_DynAnyFactory::unalias (tc.in ());
                }
              catch (const CORBA::Exception&)
                {
                  return return_value;
                }

              CORBA::Boolean result = 0;

              switch (kind)
              {
                case CORBA::tk_sequence:
                  result = this->sequence_does_contain (&component.in (),
                                                        left);
                  break;
                case CORBA::tk_array:
                  result = this->array_does_contain (&component.in (),
                                                     left);
                  break;
                case CORBA::tk_struct:
                  result = this->struct_does_contain (&component.in (),
                                                      left);
                  break;
                case CORBA::tk_union:
                  result = this->union_does_contain (&component.in (),
                                                     left);
                  break;
                case CORBA::tk_any:
                  result = this->any_does_contain (&component.in (),
                                                   left);
                  break;
                default:
                  return return_value;
              }

              this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
              return_value = 0;
            }
        }
    }

  return return_value;
}