예제 #1
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_repository_id (TAO_OutputCDR &strm,
                                            ACE_CString& id)
{
#ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION

  VERIFY_MAP (TAO_OutputCDR, repo_id_map, Repo_Id_Map);
  char* pos = 0;
  if (strm.get_repo_id_map ()->get()->find (id, pos) == 0)
  {
    if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag))
      {
        return false;
      }
    CORBA::Long offset= -strm.offset (pos);
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id,  id %C indirection %d\n"),
          id.c_str(), offset));
      }
    if (!strm.write_long (offset))
      {
        return false;
      }
  }
  else
  {
    if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (strm.get_repo_id_map ()->get ()->bind (id, strm.current()->wr_ptr ()) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id, bound %C - %x\n"),
          id.c_str (), strm.current()->wr_ptr ()));
      }
    if (! strm.write_string (id.c_str ()))
      {
        return false;
      }
  }
#else
  if (! strm.write_string (id.c_str ()))
    {
      return 0;
    }
#endif

  return 1;
}
예제 #2
0
CORBA::Boolean
TAO_ChunkInfo::reserve_chunk_size(TAO_OutputCDR &strm)
{
  // This is called in the start_chunk().
  // Reserve the chunk size the first time the start_chunk () is called
  // if there are several start_chunk () called continuously without
  // calling end_chunk (). This could happen in the _tao_marshal_state()
  // in the most derived valuetype.

  if (this->chunk_size_pos_ == 0)
    {
      // Align the wr_ptr before we reserve the space for chunk size.
      strm.align_write_ptr (ACE_CDR::LONG_SIZE);
      // Remember begin of the chunk (at chunk size position) that is needed
      // when we write back actual chunk size to the stream.
      this->chunk_size_pos_ = strm.current ()->wr_ptr ();

      // Insert four bytes here as a place-holder, we need to go back
      // later and write the actual size.
      if (! strm.write_long (0))
        {
          return 0;
        }

      // Remember length before writing chunk data. This is used to calculate
      // the actual size of the chunk.
      this->length_to_chunk_octets_pos_ = strm.total_length ();
    }

  return 1;
}
예제 #3
0
// this method is called by the IDL generated _tao_marshal_state() method.
CORBA::Boolean
TAO_ChunkInfo::end_chunk(TAO_OutputCDR &strm)
{
  if (this->chunking_)
    {
      // Write actual chunk size at the reserved chunk size place.
      if (! this->write_previous_chunk_size(strm))
        {
          return false;
        }

      // Write an end tag which is negation of value_nesting_level_.
      if (! strm.write_long(- this->value_nesting_level_))
        {
          return false;
        }

      //      -- this->value_nesting_level_;
      if ( -- this->value_nesting_level_ == 0 )
        {
          // ending chunk for outermost value
          this->chunking_ = 0;
        }
    }
  return true;
}
예제 #4
0
파일: Principal.cpp 프로젝트: asdlei00/ACE
CORBA::Boolean
operator<< (TAO_OutputCDR & cdr, CORBA::Principal * x)
{
  if (x != 0)
    {
      CORBA::ULong length  = x->id.length ();
      cdr.write_long (length);
      cdr.write_octet_array (x->id.get_buffer (), length);
    }
  else
    {
      cdr.write_ulong (0);
    }

  return (CORBA::Boolean) cdr.good_bit ();
}
예제 #5
0
파일: growth.cpp 프로젝트: OspreyHub/ATCD
static int
test_write (TAO_OutputCDR &cdr, int n)
{
  CORBA::Long l = 0xdeadbeef;

  for (int i = 0; i < n; ++i)
    {
      if (cdr.write_long (l) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "write_long[%d] failed\n",
                           i),
                          1);
    }

  return 0;
}
예제 #6
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_value_header (TAO_OutputCDR &strm,
                                           ptrdiff_t formal_type_id) const
{
#ifdef TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING
  // this case allows TAO to avoid marshaling the typeID for values
  // where the actual type matches the formal type (ie not a derived
  // type).
  //
  // I would much prefer that there be a way to have a -ORB option to
  // control this behavior, but for now there is no reference to the
  // ORB Core available during marshaling (there is during unmarshaling)
  // and no other way to communicate such configuration values.

  CORBA::Boolean const is_formal_type =
    this->_tao_match_formal_type (formal_type_id);
#else
  // Unfortunately, all versions of tao prior to TAO 1.5.2 did not
  // support unmarshaling of valuetypes that did not explicitly
  // marshal the type id. At least it is benign to always encode the
  // typecode value, even if it can be a little verbose.
  CORBA::Boolean const is_formal_type = 0;
  ACE_UNUSED_ARG (formal_type_id);
#endif /* TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING */

  // Get the list of repository ids for this valuetype.
  Repository_Id_List repository_ids;
  this->_tao_obv_truncatable_repo_ids (repository_ids);
  CORBA::Long const num_ids =
    static_cast <CORBA::Long> (repository_ids.size ());

  // Build <value-tag>, which states if chunking is used
  // and if type information ((list of) repository id(s))
  // is provided. The latter is necessary if the formal_type_id
  // is unequal the 'true derived' type of this object.
  CORBA::Long valuetag = TAO_OBV_GIOP_Flags::Value_tag_base;

  // Truncatable value type, must use chunking and list all repository
  // ids in its "truncatable" derivation hierarchy.
  if (this->is_truncatable_ || this->chunking_)
    valuetag |= TAO_OBV_GIOP_Flags::Chunking_tag_sigbits;

  if (!is_formal_type || this->is_truncatable_)
    valuetag |= TAO_OBV_GIOP_Flags::Type_info_single;

  if (num_ids > 1)
    {
      valuetag |= TAO_OBV_GIOP_Flags::Type_info_list;
    }

  if (! strm.write_long (valuetag)                    // Write <value-tag>.
      || (num_ids > 1 && !strm.write_long (num_ids))) // Write <num-ids>.
    {
      return false;
    }

#ifndef TAO_HAS_OPTIMIMIZED_VALUETYPE_MARSHALING
  if (this->is_truncatable_
      || !is_formal_type  /* Always evaluates to 1 in the
                             !TAO_HAS_OPTIMIMIZED_VALUETYPE_MARSHALING
                             case */
      || num_ids > 1)
    {
#endif  /* !TAO_HAS_OPTIMIMIZED_VALUETYPE_MARSHALING */
      // Marshal type information.
      for (CORBA::Long i = 0; i < num_ids; ++i )
        {
          if (! _tao_write_repository_id (strm, repository_ids[i]))
            {
              return false;
            }
        }
#ifndef TAO_HAS_OPTIMIMIZED_VALUETYPE_MARSHALING
    }
#endif  /* !TAO_HAS_OPTIMIMIZED_VALUETYPE_MARSHALING */

  return true;
}
예제 #7
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_special_value (TAO_OutputCDR &strm,
                                            const CORBA::ValueBase *value)
{
  // If the 'value' is null then write the null value to the stream.
  if (value == 0)
  {
    return strm.write_long (TAO_OBV_GIOP_Flags::Null_tag);
  }
  else
  {
#ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION
    // value indirection

    VERIFY_MAP (TAO_OutputCDR, value_map, Value_Map);
    char* pos = 0;
    if (strm.get_value_map ()->get()->find (
      reinterpret_cast<void*>(const_cast <CORBA::ValueBase *> (value)), pos) == 0)
    {
      if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%P|%t)ValueBase::_tao_write_special_value, found value %x=%x\n"),
            value, pos));
        }

      if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag))
        {
          return false;
        }

      CORBA::Long const offset= -strm.offset (pos);
      if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_special_value, indirection %d=%x\n"),
            offset, (void *)(strm.current()->wr_ptr () + offset) ));
        }

      return strm.write_long (offset);
    }
    else {
      if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0)
        {
          throw CORBA::INTERNAL ();
        }
      if (strm.get_value_map ()->get()->bind (
        reinterpret_cast<void*>(const_cast <CORBA::ValueBase *> (value)),
        strm.current()->wr_ptr() ) != 0)
        {
          throw CORBA::INTERNAL ();
        }
      else if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_marshal, bound value %x=%x\n"),
            value, strm.current()->wr_ptr()));
        }

      return false;
    }
#endif

    return false;
  }
}