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

📄 notify_constraint_visitors.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 4 页
字号:

            member =
              dyn_enum.current_component (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            break;
          }
        case CORBA::tk_struct:
          {
            TAO_DynStruct_i dyn_struct;
            dyn_struct.init (this->current_value_.in ()
                             ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

            success = dyn_struct.seek (slot
                                       ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

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

            member = dyn_struct.current_component (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            break;
          }
        // @@@ (JP) I think enums and structs are the only two cases handled
        // by Component_Pos, since arrays and sequences are handled by
        // Component_Array, and unions are handled by Union_Pos.
        default:
          return -1;
      }

      CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      TAO_ETCL_Constraint *comp = pos->component ();

      if (comp == 0)
        {
          TAO_ETCL_Literal_Constraint result (value);
          this->queue_.enqueue_head (result);
          return 0;
        }
      else
        {
          this->current_value_ = value._retn ();
          return comp->accept (this);
        }
    }
  ACE_CATCHANY
    {
      return -1;
    }
  ACE_ENDTRY;

  ACE_NOTREACHED (return 0);
}

int
TAO_Notify_Constraint_Visitor::visit_component_assoc (
    TAO_ETCL_Component_Assoc *assoc
  )
{
  CORBA::Any *any = 0;
  ACE_CString name (assoc->identifier ()->value (),
                    0,
                    0);

  switch (this->implicit_id_)
  {
    case FILTERABLE_DATA:
      if (this->filterable_data_.find (name, any) != 0
          || any == 0)
        {
          return -1;
        }

      break;
    case VARIABLE_HEADER:
      if (this->variable_header_.find (name, any) != 0
          || any == 0)
        {
          return -1;
        }

      break;
    // Only the sequence members of CosNotification::StructuredEvent can be
    // treated as associative arrays.
    default:
      return -1;
  }

  TAO_ETCL_Constraint *comp = assoc->component ();
  CORBA::Any *any_ptr = 0;

  if (comp == 0)
    {
      TAO_ETCL_Literal_Constraint result (any);
      this->queue_.enqueue_head (result);

      // If we're at the end of the line, put the name into
      // current_value_ so visit_exist can use it.
      ACE_NEW_RETURN (any_ptr,
                      CORBA::Any,
                      -1);
      (*any_ptr) <<= name.c_str ();
      this->current_value_ = any_ptr;

      return 0;
    }
  else
    {
      ACE_NEW_RETURN (any_ptr,
                      CORBA::Any (*any),
                      -1);
      this->current_value_ = any_ptr;
      return comp->accept (this);
    }
}

int
TAO_Notify_Constraint_Visitor::visit_component_array (
    TAO_ETCL_Component_Array *array
  )
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      // If we are here (from visit_component) the Any containing the
      // component as found in filterable_data_ will be in current_value_.
      CORBA::TypeCode_var tc = this->current_value_->type ();
      CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()
                                                       ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      DynamicAny::DynAny_var member;
      CORBA::Boolean success = 0;
      CORBA::ULong slot = (CORBA::ULong) *array->integer ();

      switch (kind)
      {
        case CORBA::tk_array:
          {
            TAO_DynEnum_i dyn_array;
            dyn_array.init (this->current_value_.in ()
                            ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

            success = dyn_array.seek (slot
                                      ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

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

            member = dyn_array.current_component (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            break;
          }
        case CORBA::tk_sequence:
          {
            TAO_DynStruct_i dyn_sequence;
            dyn_sequence.init (this->current_value_.in ()
                               ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

            success = dyn_sequence.seek (slot
                                         ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

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

            member =
              dyn_sequence.current_component (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            break;
          }
        // Enums and sequences are the only two cases handled
        // by Component_Array.
        default:
          return -1;
      }

      CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      TAO_ETCL_Constraint *comp = array->component ();

      if (comp == 0)
        {
          TAO_ETCL_Literal_Constraint result (value);
          this->queue_.enqueue_head (result);
          return 0;
        }
      else
        {
          this->current_value_ = value._retn ();
          return comp->accept (this);
        }
    }
  ACE_CATCHANY
    {
      return -1;
    }
  ACE_ENDTRY;

  ACE_NOTREACHED (return 0);
}

int
TAO_Notify_Constraint_Visitor::visit_special (TAO_ETCL_Special *special)
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      CORBA::TypeCode_var tc = this->current_value_->type ();

      switch (special->type ())
      {
        case TAO_ETCL_LENGTH:
          {
            // If the TCKind is not a sequence or an array, the
            // call to length() will raise an exception, and the
            // catch block will return -1;
            CORBA::ULong length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            TAO_ETCL_Literal_Constraint lit (length);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case TAO_ETCL_DISCRIMINANT:
          {
            // If the TCKind is not a union, the
            // call to init() will raise an exception, and the
            // catch block will return -1;
            TAO_DynUnion_i dyn_union;
            dyn_union.init (this->current_value_.in ()
                            ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

            DynamicAny::DynAny_var disc =
              dyn_union.get_discriminator (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            CORBA::Any_var disc_any = disc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            TAO_ETCL_Literal_Constraint lit (disc_any);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case TAO_ETCL_TYPE_ID:
          {
            const char *name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            TAO_ETCL_Literal_Constraint lit (name);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        case TAO_ETCL_REPOS_ID:
          {
            const char *id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            TAO_ETCL_Literal_Constraint lit (id);
            this->queue_.enqueue_head (lit);
            return 0;
          }
        default:
          return -1;
      }
    }
  ACE_CATCHANY
    {
      return -1;
    }
  ACE_ENDTRY;

  ACE_NOTREACHED (return 0);
}

int
TAO_Notify_Constraint_Visitor::visit_component (
    TAO_ETCL_Component *component
  )
{
  TAO_ETCL_Constraint *nested = component->component ();
  TAO_ETCL_Identifier *identifier = component->identifier ();
  ACE_CString component_name (identifier->value (),
                              0,
                              0);
  CORBA::Any *any_ptr = 0;

  if (this->implicit_ids_.find (component_name, this->implicit_id_) != 0)
    {
      this->implicit_id_ = TAO_Notify_Constraint_Visitor::EMPTY;
    }

  // If this component has no sub-component, only an identifier,
  // then we just visit the identifier, which puts a literal on
  // the queue to be handled upon returning from this method call.
  // If there is a sub-component, we store the literal's value
  // in our member _var for possible examination at a more
  // nested level, and visit the sub-component. If the identifier
  // matches one of the nested field names in
  // CosNotification::StructuredEvent, we just visit the nested
  // component, if any.
  if (this->implicit_id_ == TAO_Notify_Constraint_Visitor::EMPTY)
    {
      if (nested == 0)
        {
          // If this is the end of the line, we put the component name
          // into current_value_ so visit_exist can use it.
          ACE_NEW_RETURN (any_ptr,
                          CORBA::Any,
                          -1);
          (*any_ptr) <<= component_name.c_str ();
          this->current_value_ = any_ptr;
          return identifier->accept (this);
        }
      else
        {
          int result = identifier->accept (this);

          if (result != 0)
            {
              return result;
            }

          TAO_ETCL_Literal_Constraint id;
          this->queue_.dequeue_head (id);
          ACE_NEW_RETURN (any_ptr,
                          CORBA::Any (*(const CORBA::Any *) id),
                          -1);
          this->current_value_ = any_ptr;
        }
    }

  if (nested != 0)
    {
      return nested->accept (this);
    }
  else
    {
      switch (this->implicit_id_)
      {
        case TYPE_NAME:
          {
            TAO_ETCL_Literal_Constraint tn (this->type_name_.in ());
            this->queue_.enqueue_head (tn);
            return 0;
          }
        case EVENT_NAME:
          {
            TAO_ETCL_Literal_Constraint en (this->event_name_.in ());
            this->queue_.enqueue_head (en);
            return 0;
          }
        case DOMAIN_NAME:
          {
            TAO_ETCL_Literal_Constraint dn (this->domain_name_.in ());
            this->queue_.enqueue_head (dn);
            return 0;
          }
        case REMAINDER_OF_BODY:
          {
            TAO_ETCL_Literal_Constraint rob (&this->remainder_of_body_);
            this->queue_.enqueue_head (rob);
            return 0;
          }
        // The above cases are the leaves of the
        // CosNotification::StructuredEvent "tree". Anything else and we
        // should have a nested component. otherwise, it's an error.
        default:
          return -1;
      }
    }
}

int
TAO_Notify_Constraint_Visitor::visit_dot (TAO_ETCL_Dot *dot)
{

⌨️ 快捷键说明

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