void 
UnionIntSwitchPath::extract_from_dynany(const DynamicAny::DynAny_ptr& from,
                                        DynamicAny::DynAny_ptr& value) const
  throw (BadTypeException)
{
  CORBA::TCKind tk;
  DynamicAny::DynUnion_var any_union;
  DynamicAny::DynAny_var discriminator;
  
  tk = from->type()->kind();
  if (tk != CORBA::tk_union)
    throw BadTypeException();

  any_union = DynamicAny::DynUnion::_narrow(from);
  if (any_union == DynamicAny::DynUnion::_nil())
    throw BadTypeException();

  discriminator->insert_short(switch_value);
  try{
    any_union->set_discriminator(discriminator);
  }
  catch (CORBA::Exception& e)
  {
    throw BadTypeException();
  }

  value = any_union->member();


}
Beispiel #2
0
CORBA::Boolean
TAO_DynSequence_i::equal (DynamicAny::DynAny_ptr rhs)
{
  if (this->destroyed_)
    {
      throw ::CORBA::OBJECT_NOT_EXIST ();
    }

  CORBA::TypeCode_var tc = rhs->type ();

  CORBA::Boolean equivalent = tc->equivalent (this->type_.in ());

  if (!equivalent)
    {
      return false;
    }

  if (rhs->component_count () != this->component_count_)
    {
      return false;
    }

  DynamicAny::DynAny_var tmp;
  CORBA::Boolean member_equal;

  for (CORBA::ULong i = 0; i < this->component_count_; ++i)
    {
      rhs->seek (static_cast<CORBA::Long> (i));

      tmp = rhs->current_component ();

      // Recursive step.
      member_equal = tmp->equal (this->da_members_[i].in ());

      if (!member_equal)
        {
          return false;
        }
    }

  return true;
}
Beispiel #3
0
CORBA::Boolean
TAO_DynEnum_i::equal (DynamicAny::DynAny_ptr rhs)
{
  CORBA::TypeCode_var tc = rhs->type ();

  CORBA::Boolean equivalent = tc->equivalent (this->type_.in ());

  if (!equivalent)
    {
      return false;
    }

  CORBA::Any_var any = rhs->to_any ();

  TAO::Any_Impl *impl = any->impl ();
  CORBA::ULong value;

  if (impl->encoded ())
    {
      TAO::Unknown_IDL_Type * const unk =
        dynamic_cast<TAO::Unknown_IDL_Type *> (impl);

      if (!unk)
        throw CORBA::INTERNAL ();

      // We don't want unk's rd_ptr to move, in case we are shared by
      // another Any, so we use this to copy the state, not the buffer.
      TAO_InputCDR for_reading (unk->_tao_get_cdr ());
      for_reading.read_ulong (value);
    }
  else
    {
      TAO_OutputCDR out;
      impl->marshal_value (out);
      TAO_InputCDR in (out);
      in.read_ulong (value);
    }

  return value == this->value_;
}
Beispiel #4
0
void DynAnyAnalyzer::analyze (DynamicAny::DynAny_ptr da)
{
  CORBA::TypeCode_var tc = da->type ();

  CORBA::TCKind kind = tc->kind ();

  CORBA::TypeCode_var dup = CORBA::TypeCode::_duplicate (tc.in ());

  // strip aliases
  while (kind == CORBA::tk_alias)
    {
      dup = dup->content_type ();

      kind = dup->kind ();
    }

  switch (kind)
   {
     case CORBA::tk_struct:
      {
        DynamicAny::DynStruct_var ds
          = DynamicAny::DynStruct::_narrow (da);

        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG,
                      "STRUCT\n"));
          }

        if (da->seek (0) )
          {
            level_++;

            do
              {
                DynamicAny::DynAny_var cc =
                  ds->current_component ();

                DynamicAny::FieldName_var fn =
                  ds->current_member_name ();

                tab(level_);

                if (debug_)
                  {
                    ACE_DEBUG ((LM_DEBUG,
                              "Member = %C\n", fn.in ()));
                  }

                if (!CORBA::is_nil (cc.in ()))
                  {
                    this->analyze (cc.in ());
                  }

              } while (da->next ());

            level_--;
          }
      }
      break; // end tk_struct

    case CORBA::tk_sequence:
      {
        if (TAO_DynCommon::is_basic_type_seq (tc.in ()))
          {
            this->analyze_basic_seq (dup.in (), da);
          }
        else
          {
            DynamicAny::DynSequence_var ds =
              DynamicAny::DynSequence::_narrow (da);

            int i = 0;
            tab(level_);

            if (debug_)
              {
                ACE_DEBUG ((LM_DEBUG,
                            "SEQUENCE\n"));
              }

            if (ds->seek (0UL))
              {
                level_++;

                do
                  {
                    tab(level_);

                    if (debug_)
                      ACE_DEBUG ((LM_DEBUG,
                                  "[%d]\n", i));

                    DynamicAny::DynAny_var cc (ds->current_component ());

                    if (!CORBA::is_nil (cc.in ()))
                      {
                        analyze (cc.in ());
                      }

                    i++;
                  } while (da->next ());

                level_--;
              }
          }
      }
      break; // end tk_sequence

    case CORBA::tk_array:
      {
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "ARRAY\n"));
          }

        level_++;

        CORBA::ULong const len =
          dup->length ();

        for (CORBA::ULong i = 0 ; i < len; ++i)
          {
            tab (level_);

            if (debug_)
              {
                ACE_DEBUG ((LM_DEBUG, "[%d]\n", i));
              }

            DynamicAny::DynAny_var cc = da->current_component();

            if (!CORBA::is_nil (cc.in ()))
              {
                analyze (cc.in ());
              }

            da->next ();
          }
        level_--;
      }
      break;

    case CORBA::tk_union:
      {
        DynamicAny::DynUnion_var value =
          DynamicAny::DynUnion::_narrow (da);

        if (!value->has_no_active_member ())
          {
            DynamicAny::DynAny_var disc = value->member ();

            if (!CORBA::is_nil (disc.in ()))
              {
                this->analyze (disc.in ());
              }
          }
      }
      break;

    case CORBA::tk_any:
      {
        DynamicAny::DynAny_var dynany;
        CORBA::Any_var any = da->get_any ();

        dynany =
          dynany_factory_->create_dyn_any (any.in ());

        if (!CORBA::is_nil (dynany.in ()))
          {
            this->analyze (dynany.in ());
          }

        dynany->destroy ();
      }
      break;

    case CORBA::tk_enum:
      {
        DynamicAny::DynEnum_var value =
          DynamicAny::DynEnum::_narrow (da);

        CORBA::String_var s = value->get_as_string ();
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG, "  Value (enum) = %C\n", s.in()));
          }
      }
      break;

    CASEE (boolean, Boolean, "  Value (bool) = %d\n");
    CASEE (short, Short, "  Value (short) = %d\n");
    CASEE (ushort, UShort, "  Value (ushort) = %u\n");
    CASEE (long, Long, "  Value (long) = %d\n");
    CASEE (ulong, ULong, "  Value (ulong) = %u\n");
    CASEE (longlong, LongLong, "  Value (longlong) %Ld\n");
    CASEE (ulonglong, ULongLong, "  Value (ulonglong) %Lu\n");
    CASEE (char, Char, "  Value (char) = %c\n");
    CASEE (float, Float, "  Value (float) = %f\n");
    CASEE (double, Double, "  Value (double) = %f\n");
    CASEE (octet, Octet, "  Value (octet) = %c\n");

    case CORBA::tk_string:
      {
        CORBA::String_var b (da->get_string ());
        tab (level_);

        if (debug_)
          {
            ACE_DEBUG ((LM_DEBUG, "  Value (string) = %C\n", b.in ()));
          }
      }
      break;

    case CORBA::tk_TypeCode:
      {
        tab (level_);

        if (debug_)
          {
            CORBA::TCKind const kind =
              da->get_typecode ()->kind ();

            ACE_DEBUG ((LM_DEBUG,
                        "  Value (TypeCode) = %d\n",
                        static_cast<int> (kind)));
          }
      }
      break;

    default:
      {
        tab (level_);

        if (debug_)
          {
            CORBA::TCKind const kind =
              tc->kind ();

            ACE_DEBUG ((LM_DEBUG,
                        "  unhandled typecode = %d\n",
                        static_cast<int> (kind)));
          }
      }
      break;
  }

  if (debug_)
    {
      ACE_DEBUG ((LM_DEBUG, "\n"));
    }
}