⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notify_constraint_visitors.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 4 页
字号:
  // If we are here, we know we're headed for a more nested
  // level, so we just visit it, there's nothing else in this
  // constraint.
  return dot->component ()->accept (this);
}

int
TAO_Notify_Constraint_Visitor::visit_eval (TAO_ETCL_Eval *eval)
{
  // Nothing to do but visit the contained component.
  return eval->component ()->accept (this);
}

int
TAO_Notify_Constraint_Visitor::visit_default (TAO_ETCL_Default *def)
{
  TAO_ETCL_Constraint *comp = def->component ();

  if (comp == 0)
    {
      return -1;
    }

  if (comp->accept (this) != 0)
    {
      return -1;
    }

  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      CORBA::TypeCode_var tc = this->current_value_->type ();

      // If the current member is not a union, this call will
      // throw BadKind and the catch block will return -1.
      CORBA::Long default_index = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // No default index.
      if (default_index == -1)
        {
          TAO_ETCL_Literal_Constraint result ((CORBA::Boolean) 0);
          this->queue_.enqueue_head (result);
          return 0;
        }

      // Okay, there's a default index, but is it active?

      TAO_ETCL_Literal_Constraint disc;
      this->queue_.dequeue_head (disc);
      TAO_ETCL_Literal_Constraint default_index_value (default_index);
      return (disc == default_index_value);
    }
  ACE_CATCHANY
    {
      return -1;
    }
  ACE_ENDTRY;

  ACE_NOTREACHED (return 0);
}

int
TAO_Notify_Constraint_Visitor::visit_exist (TAO_ETCL_Exist *exist)
{
  TAO_ETCL_Constraint *component = exist->component ();

  if (component->accept (this) == 0)
    {
      const char *value = 0;
      CORBA::Boolean result = 0;

      // For the two cases below, we don't want the item at the top of
      // the queue, because it's the result of a hash table lookup. For
      // an existence test, we want the key value, which is stored in
      // the current_value_ member.
      if (this->implicit_id_ == FILTERABLE_DATA
          || this->implicit_id_ == VARIABLE_HEADER)
        {
          TAO_ETCL_Literal_Constraint current (
                                          &this->current_value_.inout ()
                                        );
          value = CORBA::string_dup ((const char *) current);
        }

      switch (this->implicit_id_)
      {
        case FILTERABLE_DATA:
          result =
            (this->filterable_data_.find (ACE_CString (value, 0, 0)) == 0);
          break;
        case VARIABLE_HEADER:
          result =
            (this->variable_header_.find (ACE_CString (value, 0, 0)) == 0);
          break;
        case TYPE_NAME:
          result = (this->type_name_.in () != 0);
          break;
        case EVENT_NAME:
          result = (this->event_name_.in () != 0);
          break;
        case DOMAIN_NAME:
          result = (this->domain_name_.in () != 0);
          break;
        // Anything other than the above cases is an error.
        default:
          return -1;
      }

      this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));

      return 0;
    }

  return -1;
}

int
TAO_Notify_Constraint_Visitor::visit_unary_expr (
    TAO_ETCL_Unary_Expr *unary_expr
  )
{
  TAO_ETCL_Constraint *subexpr = unary_expr->subexpr ();

  if (subexpr->accept (this) == 0)
    {
      TAO_ETCL_Literal_Constraint subexpr_result;
      CORBA::Boolean result = 0;
      int op_type = unary_expr->type ();

      switch (op_type)
      {
        case TAO_ETCL_NOT:
          this->queue_.dequeue_head (subexpr_result);
          result = ! (CORBA::Boolean) subexpr_result;
          this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
          return 0;
        case TAO_ETCL_MINUS:
          // The leading '-' was parsed separately, so we have to pull
          // the literal constraint off the queue, apply the class' own
          // unary minus operator, and put it back.
          this->queue_.dequeue_head (subexpr_result);
          this->queue_.enqueue_head (-subexpr_result);
          return 0;
        case TAO_ETCL_PLUS:
          // Leave the literal constraint on the queue. The leading
          // '+' was just syntactic sugar - no action is necessary.
          return 0;
        default:
          // The parser should never construct a TAO_ETCL_Unary_Constraint
          // behind any operators except the above three.
          return -1;
      }
    }

  return -1;
}

int
TAO_Notify_Constraint_Visitor::visit_binary_expr (
    TAO_ETCL_Binary_Expr *binary_expr
  )
{
  int bin_op_type = binary_expr->type ();

  switch (bin_op_type)
  {
    case TAO_ETCL_OR:
      return this->visit_or (binary_expr);
    case TAO_ETCL_AND:
      return this->visit_and (binary_expr);
    case TAO_ETCL_LT:
    case TAO_ETCL_LE:
    case TAO_ETCL_GT:
    case TAO_ETCL_GE:
    case TAO_ETCL_EQ:
    case TAO_ETCL_NE:
    case TAO_ETCL_PLUS:
    case TAO_ETCL_MINUS:
    case TAO_ETCL_MULT:
    case TAO_ETCL_DIV:
      return this->visit_binary_op (binary_expr,
                                    bin_op_type);
    case TAO_ETCL_TWIDDLE:
      return this->visit_twiddle (binary_expr);
    case TAO_ETCL_IN:
      return this->visit_in (binary_expr);
    default:
      return -1;
  }
}

int
TAO_Notify_Constraint_Visitor::visit_or (
    TAO_ETCL_Binary_Expr *binary
  )
{
  int return_value = -1;
  CORBA::Boolean result = 0;
  TAO_ETCL_Constraint *lhs = binary->lhs ();

  if (lhs->accept (this) == 0)
    {
      TAO_ETCL_Literal_Constraint lhs_result;
      this->queue_.dequeue_head (lhs_result);
      result = (CORBA::Boolean) lhs_result;

      // Short-circuiting OR.
      if (result == 0)
        {
          TAO_ETCL_Constraint *rhs = binary->rhs ();

          if (rhs->accept (this) == 0)
            {
              TAO_ETCL_Literal_Constraint rhs_result;
              this->queue_.dequeue_head (rhs_result);
              result = (CORBA::Boolean) rhs_result;
              return_value = 0;
            }
        }
      else
        {
          return_value = 0;
        }
    }

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

  return return_value;
}

int
TAO_Notify_Constraint_Visitor::visit_and (
    TAO_ETCL_Binary_Expr *binary
  )
{
  int return_value = -1;
  CORBA::Boolean result = 0;
  TAO_ETCL_Constraint *lhs = binary->lhs ();

  if (lhs->accept (this) == 0)
    {
      TAO_ETCL_Literal_Constraint lhs_result;
      this->queue_.dequeue_head (lhs_result);
      result = (CORBA::Boolean) lhs_result;

      // Short-circuiting AND.
      if (result == 1)
        {
          TAO_ETCL_Constraint *rhs = binary->rhs ();

          if (rhs->accept (this) == 0)
            {
              TAO_ETCL_Literal_Constraint rhs_result;
              this->queue_.dequeue_head (rhs_result);
              result = (CORBA::Boolean) rhs_result;
              return_value = 0;
            }
        }
      else
        {
          return_value = 0;
        }
    }

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

  return return_value;
}

int
TAO_Notify_Constraint_Visitor::visit_binary_op (
    TAO_ETCL_Binary_Expr *binary,
    int op_type
  )
{
  int return_value = -1;
  TAO_ETCL_Constraint *lhs = binary->lhs ();
  CORBA::Boolean result = 0;

  // Perform an operation on the results of evaluating the left and
  // right branches of this subtree.
  if (lhs->accept (this) == 0)
    {
      TAO_ETCL_Literal_Constraint left_operand;
      this->queue_.dequeue_head (left_operand);
      TAO_ETCL_Constraint *rhs = binary->rhs ();

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

          switch (op_type)
          {
            case TAO_ETCL_LT:
              result = left_operand < right_operand;
              this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
              break;
            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_Notify_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 *) right,
                             (const char *) left) != 0);
          this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result));
          return_value = 0;
        }
    }

  return return_value;
}

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -