示例#1
0
文件: Savable.cpp 项目: manut/TAO
void
Savable::read (TAO::Storable_Base & stream)
{
  stream.rewind ();

  for (int index = 0; index < 2; ++index)
    {
      stream >> this->string_[index];
      stream >> this->i_[index];
      stream >> this->ui_[index];
      stream >> this->bytes_size_[index];
      stream.read (this->bytes_size_[index], this->bytes_[index]);
    }
}
示例#2
0
文件: Savable.cpp 项目: manut/TAO
void
Savable::write (TAO::Storable_Base & stream)
{
  stream.rewind ();

  for (int index = 0; index < 2; ++index)
    {
      stream << this->string_[index];
      stream << this->i_[index];
      stream << this->ui_[index];
      stream << this->bytes_size_[index];
      stream.write (this->bytes_size_[index], this->bytes_[index]);
    }

  stream.flush ();
}
示例#3
0
void
TAO::PG_Group_List_Store::write (TAO::Storable_Base & stream)
{
  stream.rewind ();

  unsigned int next_group_id = static_cast<unsigned int> (this->next_group_id_);
  stream << next_group_id;

  int size = group_ids_.size ();
  stream << size;
  for (Group_Id_Const_Iterator it = group_ids_.begin ();
                               it != group_ids_.end (); ++it)
    {
      int group_id = static_cast<int> (*it);
      stream << group_id;
    }

  stream.flush ();
}
示例#4
0
void
TAO::PG_Group_List_Store::read (TAO::Storable_Base & stream)
{
  group_ids_.clear ();

  stream.rewind ();

  unsigned int next_group_id;
  stream >> next_group_id;
  this->next_group_id_ = next_group_id;

  int size;
  stream >> size;

  // TODO: Look at adding streaming of unsigned long long
  // PortableGroup::ObjectGroupId group_id;
  int group_id;
  for (int i = 0; i < size; ++i)
    {
      stream >> group_id;
      group_ids_.insert (group_id);
    }
}
void
TAO::PG_Object_Group_Storable::write (TAO::Storable_Base & stream)
{
  stream.rewind ();

  ACE_CString group_name = PG_Object_Group::get_name ();
  stream << group_name;
  stream << this->distribute_;
  stream << this->role_;

  TAO_OutputCDR primary_location_cdr;
  primary_location_cdr << PG_Object_Group::get_primary_location ();
  stream << primary_location_cdr;

  CORBA::String_var reference_ior =
    this->orb_->object_to_string (this->reference_.in ());
  stream << reference_ior.in ();

  TAO_OutputCDR tagged_component_cdr;
  tagged_component_cdr << this->tagged_component_;
  stream << tagged_component_cdr;

  TAO_OutputCDR type_id_cdr;
  PortableGroup::TypeId_var type_id = PG_Object_Group::get_type_id ();
  type_id_cdr << type_id;
  stream << type_id_cdr;

  TAO_OutputCDR properties_cdr;
  PortableGroup::Criteria properties;
  this->properties_.export_properties (properties);
  properties_cdr << properties;
  stream << properties_cdr;

  ///// members_ /////
  int num_members = this->members_.current_size  ();
  stream << num_members;
  for (MemberMap_Iterator it = this->members_.begin ();
       it != this->members_.end ();
       ++it)
    {
      PortableGroup::Location the_location = it->key ();
      TAO_OutputCDR the_location_cdr;
      the_location_cdr << the_location;
      stream << the_location_cdr;

      MemberInfo * member = it->item ();
      CORBA::String_var member_ior =
        this->orb_->object_to_string (member->member_.in ());
      stream << member_ior.in ();

      TAO_OutputCDR location_cdr;
      location_cdr << member->location_;
      stream << location_cdr;

      CORBA::String_var factory_ior =
        this->orb_->object_to_string (member->factory_.in ());
      stream << factory_ior.in ();

      TAO_OutputCDR factory_id_cdr;
      factory_id_cdr << member->factory_id_;
      stream << factory_id_cdr;

      stream << (int)member->is_primary_;
    }
  stream.flush ();
  this->write_occurred_ = true;
}
void
TAO::PG_Object_Group_Storable::read (TAO::Storable_Base & stream)
{
  stream.rewind ();

  ACE_CString group_name;
  stream >> group_name;

  PG_Object_Group::set_name(group_name.c_str());

  stream >> this->distribute_;

  stream >> this->role_;

  ///// primary_location_ /////
  read_cdr (stream, this->primary_location_);

  ///// reference_ /////
  ACE_CString reference_ior;
  stream >> reference_ior;
  this->reference_ = this->orb_->string_to_object (reference_ior.c_str ());

  ///// tagged_component_ /////
  read_cdr (stream, this->tagged_component_);

  ///// type_id_ /////
  // special note: A memory leak appears when the type_id_ is read into directly.
  // reading into a temporary string and handing that to the type_id_ does not leak.
  CORBA::String_var tmp;
  read_cdr(stream, tmp);
  this->type_id_ = tmp._retn();

  ///// properties_ /////
  PortableGroup::Criteria properties;
  read_cdr (stream, properties);
  PG_Object_Group::set_properties_dynamically (properties);

  ///// members_ /////
  int num_members;
  stream >> num_members;

  if (num_members == 0)
    this->empty_ = 1;
  else
    this->empty_ = 0;

  this->clear_members_map ();

  for (int i = 0; i < num_members; ++i)
    {
      ///// location used as members_ key /////
      PortableGroup::Location the_location;
      read_cdr (stream, the_location);

      ///// member /////
      ACE_CString member_ior;
      stream >> member_ior;
      CORBA::Object_var member =
        this->orb_->string_to_object (member_ior.c_str ());
      if (CORBA::is_nil (member.in ()))
        {
          if (TAO_debug_level > 0)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) PG_Object_Group_Storable::")
                              ACE_TEXT ("string_to_object failed\n")));
            }
          throw CORBA::INV_OBJREF ();
        }

      ///// location /////
      PortableGroup::Location location;
      read_cdr (stream, location);

      ///// factory /////
      ACE_CString factory_ior;
      stream >> factory_ior;
      CORBA::Object_var obj =
        this->orb_->string_to_object (factory_ior.c_str ());
      PortableGroup::GenericFactory_var factory =
        PortableGroup::GenericFactory::_narrow (obj.in());

      ///// factory_id (typedef of CORBA::Any) /////
      PortableGroup::GenericFactory::FactoryCreationId factory_id;
      read_cdr (stream, factory_id);

      ///// is_primary /////
      int is_primary;
      stream >> is_primary;

      MemberInfo * info = 0;
      ACE_NEW_THROW_EX (info, MemberInfo(member.in (),
                                         the_location,
                                         factory.in (),
                                         factory_id),
                        CORBA::NO_MEMORY());

      info->is_primary_ = is_primary;

      if (this->members_.bind (the_location, info) != 0)
        {
          throw CORBA::NO_MEMORY();
        }
    }
}