// compareAnys function compares both Any type inputs
// returns FIRST_BIGGER if the first argument is bigger
// returns SECOND_BIGGER is the second argument is bigger
// and BOTH_EQUAL if they are equal
Service_impl::AnyComparisonType Service_impl::compareAnys (CORBA::Any& first,
                                                         CORBA::Any& second)
{
    CORBA::TypeCode_var tc1 = first.type ();
    CORBA::TypeCode_var tc2 = second.type ();

    switch (tc1->kind ()) {
    case CORBA::tk_ulong: {
        CORBA::ULong frst, scnd;
        first >>= frst;
        second >>= scnd;

        if (frst > scnd) {
            return FIRST_BIGGER;
        } else if (frst == scnd) {
            return BOTH_EQUAL;
        } else {
            return SECOND_BIGGER;
        }
    }

    case CORBA::tk_long: {
        CORBA::Long frst, scnd;
        first >>= frst;
        second >>= scnd;

        if (frst > scnd) {
            return FIRST_BIGGER;
        } else if (frst == scnd) {
            return BOTH_EQUAL;
        } else {
            return SECOND_BIGGER;
        }
    }

    case CORBA::tk_short: {
        CORBA::Short frst, scnd;
        first >>= frst;
        second >>= scnd;

        if (frst > scnd) {
            return FIRST_BIGGER;
        } else if (frst == scnd) {
            return BOTH_EQUAL;
        } else {
            return SECOND_BIGGER;
        }
    }

    default:
        return UNKNOWN;
    }

    return UNKNOWN;
}
//-----------------------------------------------------------------------------//
std::string CCorbaErrorHelper::ToString(const CORBA::Exception& err)
{
	CORBA::Any tmp;
	tmp <<= err;
	CORBA::TypeCode_var tc = tmp.type();
	return std::string(tc->name());
}
Example #3
0
void
TAO_ConstantDef_i::value_i (const CORBA::Any &value)
{
  CORBA::TypeCode_var my_tc =
    this->type_i ();

  CORBA::TypeCode_var val_tc = value.type ();

  CORBA::Boolean const equal_tc =
    my_tc.in ()->equal (val_tc.in ());

  if (!equal_tc)
    {
      return;
    }

  ACE_Message_Block *mb = 0;
  TAO::Any_Impl *impl = value.impl ();

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

      mb = unk->_tao_get_cdr ().steal_contents ();
    }
  else
    {
      TAO_OutputCDR out;
      impl->marshal_value (out);
      TAO_InputCDR in (out);
      mb = in.steal_contents ();
    }
  ACE_Auto_Ptr<ACE_Message_Block> safe (mb);

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

  switch (kind)
  {
    // The data for these types will be aligned to an 8-byte
    // boundary, while the rd_ptr may not.
    case CORBA::tk_double:
    case CORBA::tk_ulonglong:
    case CORBA::tk_longlong:
    case CORBA::tk_longdouble:
      mb->rd_ptr (ACE_ptr_align_binary (mb->rd_ptr (),
                                        ACE_CDR::MAX_ALIGNMENT));
      break;
    default:
      break;
  }

  mb->crunch ();
  this->repo_->config ()->set_binary_value (this->section_key_,
                                            "value",
                                            mb->base (),
                                            mb->length ());
}
Example #4
0
//-----------------------------------------------------------------------------
void
Supplier::populateHeader(const CORBA::Any &any)
{
    if (any.type()->kind()!=CORBA::tk_sequence)
	{
	setEventType(any.type()->name());
	}
    else
	{
	std::string etName= acsnc::SEQUENCE_EVENT_TYPE_PREFIX; //_SequenceOf_
	CORBA::Any a;
	a._tao_set_typecode(any.type()->content_type());
	etName+=a.type()->name();
	setEventType(etName.c_str());
	}
    populateHeader(event_m);
    event_m.filterable_data[0].value = any;
}
Example #5
0
void
TAO_DynAny_i::init (const CORBA::Any& any)
{
  this->type_ = any.type ();
  this->check_typecode (this->type_.in ());

  this->init_common ();

  this->any_ = any;
}
Example #6
0
//----------------------------------------------------------------------
CORBA::TCKind
AnyAide::getRealType(const CORBA::Any& any)
{
    //have to create an _var type because this is actually a CORBA object
    CORBA::TypeCode_var tc;
    //get the type from the any
    tc = any.type();

    //return the kind...simple enough.
    return tc->kind();
}
Example #7
0
CORBA::Boolean
CDBPropertySet::get_properties (const CosPropertyService::PropertyNames & property_names,
				CosPropertyService::Properties_out nproperties)
{
  ACS_TRACE("baci::CDBPropertySet::get_properties");

  // Allocate memory for the out parameter.
  ACE_NEW_RETURN (nproperties,
                  CosPropertyService::Properties,
                  0);

  // Validate the length.
  CORBA::ULong n = property_names.length ();
  if (n == 0)
      {
      return 0;
      }

  // Set the length for the out parameter.
  nproperties->length (n);

  // Get values for all the names.

  CORBA::Any_ptr any_p = 0;
  CORBA::Boolean retVal = true;

  for (CORBA::ULong i = 0UL; i < n; i++)
    {
      any_p = get_property_value(property_names[i]);
      ACE_CHECK_RETURN (0);

      if (any_p != 0)
        {
          // Property is found.
          nproperties [i].property_name = property_names [i];
          nproperties [i].property_value = *any_p;
        }
      else
        {
          // Invalid name. Ret value is False.
          retVal = false;

          // Assign void type to this name in the out parameter.
          nproperties [i].property_name = property_names [i];

          // Make an any value with tk_void type.
	  CORBA::Any voidany;
	  voidany.type(CORBA::_tc_void);
          nproperties [i].property_value = voidany; 
//           CORBA::Any(CORBA::_tc_void);
        }
    }
  return retVal;
}
Example #8
0
 void
 Best_Effort::post_connect (const Deployment::DeploymentPlan &plan,
   uint32_t connection,
   const CORBA::Any &exception)
 {
   if (exception.type()->kind () != CORBA::TCKind::tk_null)
     {
       DANCEX11_LOG_ERROR ("Best_Effort::post_connect - " <<
                           "Received exception while establishing connection " <<
                           "<" << plan.connection ()[connection].name () << ">:<" <<
                           DAnCE::Utility::stringify_exception_from_any (exception) << ">");
     }
 }
Example #9
0
static ostream &
operator<< (ostream & os, const CORBA::Exception & e)
{
    CORBA::Any tmp;
    tmp <<= e;
    CORBA::TypeCode_var tc = tmp.type ();
    const char * p = tc->name ();
    if (*p != '\0')
        os << p;
    else
        os << tc->id ();
    return os;
}
Example #10
0
 void
 Best_Effort::post_passivate (const Deployment::DeploymentPlan & plan,
   uint32_t index,
   const CORBA::Any & exception)
 {
   if (exception.type()->kind () != CORBA::TCKind::tk_null)
     {
       DANCEX11_LOG_ERROR ("Best_Effort::post_passivate - " <<
                           "Received exception while passivating instance " <<
                           "<" << plan.instance ()[index].name () << ">:<" <<
                           DAnCE::Utility::stringify_exception_from_any (exception) << ">");
     }
 }
// compareAnyToZero function compares the any type input to zero
// returns POSITIVE if the first argument is bigger
// returns NEGATIVE is the second argument is bigger
// and ZERO if they are equal
Service_impl::AnyComparisonType Service_impl::compareAnyToZero (CORBA::Any& first)
{
    CORBA::TypeCode_var tc1 = first.type ();

    switch (tc1->kind ()) {
    case CORBA::tk_ulong: {
        CORBA::ULong frst;
        first >>= frst;

        if (frst > 0) {
            return POSITIVE;
        } else if (frst == 0) {
            return ZERO;
        } else {
            return NEGATIVE;
        }
    }

    case CORBA::tk_long: {
        CORBA::Long frst;
        first >>= frst;

        if (frst > 0) {
            return POSITIVE;
        } else if (frst == 0) {
            return ZERO;
        } else {
            return NEGATIVE;
        }
    }

    case CORBA::tk_short: {
        CORBA::Short frst;
        first >>= frst;

        if (frst > 0) {
            return POSITIVE;
        } else if (frst == 0) {
            return ZERO;
        } else {
            return NEGATIVE;
        }
    }

    default:
        return UNKNOWN;
    }

    return UNKNOWN;
}
Example #12
0
 void
 Standard_Error::post_connect (const ::Deployment::DeploymentPlan &plan,
                                        ::CORBA::ULong connection,
                                        const ::CORBA::Any &exception)
 {
   if (exception.type() != ::CORBA::_tc_null)
     {
       DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                    (LM_ERROR, DLINFO
                     ACE_TEXT ("Standard_Error::post_connect - ")
                     ACE_TEXT ("Propagating exception from connection <%C>\n"),
                     plan.connection[connection].name.in ()));
       DAnCE::Utility::throw_exception_from_any (exception);
     }
 }
Example #13
0
 void
 Standard_Error::post_passivate (const ::Deployment::DeploymentPlan & plan,
                                 ::CORBA::ULong index,
                                 const ::CORBA::Any & exception)
 {
   if (exception.type() != ::CORBA::_tc_null)
     {
       DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                    (LM_ERROR, DLINFO
                     ACE_TEXT ("Standard_Error::post_passivate - ")
                     ACE_TEXT ("Propagating exception from passivation of instance <%C>\n"),
                     plan.instance[index].name.in ()));
       DAnCE::Utility::throw_exception_from_any (exception);
     }
 }
//-----------------------------------------------------------------------------//
std::string CCorbaErrorHelper::ToString(const CORBA::SystemException& err)
{
	std::string errDescription;
	TCHAR buf[50];
	memset(buf, 0, sizeof(TCHAR) * 50);
	
	CORBA::Any tmp;
	tmp <<= err;
	CORBA::TypeCode_var tc = tmp.type();

	errDescription = std::string(tc->name()) + _T(" Description: ") + err.NP_minorString();
	errDescription += _T(" Minor code: ");
	errDescription += _ltoa_s(err.minor(), buf, 50, 10);

	return errDescription;
}
Example #15
0
// Store the exception value.
void
CORBA::ServerRequest::set_exception (const CORBA::Any &value)
{
  CORBA::TypeCode_var tc = value.type ();

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

  // set_exception() can be called at any time, but the Any arg MUST
  // contain an exception.
  if (kind != CORBA::tk_except)
    {
      throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 21, CORBA::COMPLETED_MAYBE);
    }

  ACE_NEW_THROW_EX (this->exception_,
                    CORBA::Any (value),
                    CORBA::NO_MEMORY ());

  this->orb_server_request_.reply_status (GIOP::USER_EXCEPTION);
}
Example #16
0
void TIDorb::core::ContextImpl::set_one_value(const char* prop_name, const CORBA::Any& value)
{
  if(!prop_name)
    throw CORBA::BAD_PARAM(0,CORBA::COMPLETED_NO);

  CORBA::TypeCode_var type = value.type();
  
  if (type->kind() != CORBA::tk_string)
    throw CORBA::BAD_PARAM(0,CORBA::COMPLETED_NO); // "Value must have a string TypeCode."

  {
    TIDThr::Synchronized sync(*this);	
          
    if (!m_values)
     m_orb->create_list(1, m_values);
  }
  
  // new value
  
  m_values->add_value(prop_name, value, 0);
}
Example #17
0
void
TAO_DynUnion_i::init (const CORBA::Any& any)
{
  CORBA::TypeCode_var tc = any.type ();

  CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());

  if (kind != CORBA::tk_union)
    {
      throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
    }

  // Initialize the typecode holder.
  this->type_ = tc;

  this->init_common ();

  // Set the from_factory arg to TRUE, so any problems will throw
  // InconsistentTypeCode.
  this->set_from_any (any);
}
Example #18
0
void
TAO_DynAny_i::from_any (const CORBA::Any &any)
{
  if (this->destroyed_)
    {
      throw ::CORBA::OBJECT_NOT_EXIST ();
    }

  CORBA::TypeCode_var any_tc = any.type ();

  if (!this->type_->equivalent (any_tc.in ()))
    {
      throw DynamicAny::DynAny::TypeMismatch ();
    }

// @@@ (JP) Spec also says we should check for illegal Any
// value here, and throw InvalidValue if we find one.
// Something like a null string will be caught in the constructor.

  this->any_ = any;
}
Example #19
0
void
TAO_DynEnum_i::init (const CORBA::Any &any)
{
  CORBA::TypeCode_var tc = any.type ();
  CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());

  if (kind != CORBA::tk_enum)
    {
      throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
    }

  this->type_ = tc;

  TAO::Any_Impl *impl = any.impl ();

  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 (this->value_);
    }
  else
    {
      TAO_OutputCDR out;
      impl->marshal_value (out);
      TAO_InputCDR in (out);
      in.read_ulong (this->value_);
    }

  this->init_common ();
}
Example #20
0
//----------------------------------------------------------------------
std::string
AnyAide::getId(const CORBA::Any& any)
{
    CORBA::TCKind kind = getRealType(any);
    
    //great - the identifier is already provided
    if ((kind==CORBA::tk_objref) ||
	(kind==CORBA::tk_struct) ||
	(kind==CORBA::tk_union)  ||
	(kind==CORBA::tk_enum)   ||
	(kind==CORBA::tk_except))
	{
	//have to create an _var type because this is actually a CORBA object
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();
	return std::string(tc->id());
	}
    else if(kind==CORBA::tk_null)
	{
	return nullType_m;
	}
    else if(kind==CORBA::tk_string)
	{
	return stringType_m;
	}
    else if(kind==CORBA::tk_double)
	{
	return doubleType_m;
	}
    else if(kind==CORBA::tk_long)
	{
	return longType_m;
	}
    else if(kind==CORBA::tk_ulong)
	{
	return uLongType_m;
	}
    else if(kind==CORBA::tk_longlong)
	{
	return longLongType_m;
	}
    else if(kind==CORBA::tk_ulonglong)
	{
	return uLongLongType_m;
	}
    else if(kind==CORBA::tk_float)
	{
	return floatType_m;
	}
    //aliases can be ...
    else if(kind==CORBA::tk_alias)
	{
	//first get a hold of the IFR id
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();

	return std::string(tc->id());
	}
    // after TAO 1.5.2 we have to handel seqence separatly
    else if (kind==CORBA::tk_sequence)
	{
//!!! here we play dirty !!!
// this solution does not work with seq of seq
// we can change it but first we have to change it on the places where seqences are used !!
	CORBA::TypeCode_var tc;
	//get the type from the any
	tc = any.type();
	//create another any with type of content type (long/double ..)
	CORBA::Any a;
	a._tao_set_typecode(tc->content_type());
	// get recursivly the ID of contained type
	std::string c = getId(a);
	return std::string("IDL:alma/ACS/" + c + "Seq:1.0"); // very dirty but should be OK 
	}
    
    //bad case
    else
	{
	UnsupportedType except;
	except.type = unknownType_m;
	throw except;
	}
}
Example #21
0
void
CDBPropertySet::get_all_properties (CORBA::ULong how_many,
				    CosPropertyService::Properties_out nproperties,
				    CosPropertyService::PropertiesIterator_out rest)
{
  ACS_TRACE("baci::CDBPropertySet::get_all_properties");

  // Allocate memory for the out parameter.
  ACE_NEW (nproperties,
           CosPropertyService::Properties);

  // check if characteristic model is registered
  CORBA::String_var objId = getObjectId();
  CharacteristicModelImplMap::iterator iter = modelMap.find(objId.in());
  if (iter == modelMap.end())
      throw CORBA::NO_RESOURCES();

   DAONode * node = iter->second->getDAONode();
  if (!node)
      throw CORBA::NO_RESOURCES();

  CDB::stringSeq_var properties;
  try
      {
      properties = node->get_string_seq("");
      }
  catch (...)
      {
      throw CORBA::NO_RESOURCES();
      }
  
  // Validate the length.
  CORBA::ULong numOfProperties = properties->length();

  if (numOfProperties == 0)
      {
      // Nothing to do.
      return;
      }

  // Set the length for the nproperties if how_many > 0.
  CORBA::ULong sequenceLength = 0UL;

  if (how_many > 0)
    {
      if (how_many >= numOfProperties)
	  {
	  sequenceLength = numOfProperties;
	  }
      else
	  {
	  sequenceLength = how_many;
	  }
      nproperties->length(sequenceLength);
    }

  // Prepare an iterator and iterate through the PropertySet. Retrive
  // the values.

  CORBA::Any anyval;
  CORBA::ULong ni = 0UL;
  for (; ni < sequenceLength;
       ni++)
      {
      nproperties[ni].property_name = CORBA::string_dup (properties[ni].in());

      try
	  {
	  CORBA::String_var strVal = node->get_string(properties[ni].in());
	  anyval <<= strVal.in();
	  nproperties[ni].property_value = anyval;
	  }
      catch (...)
	  {
	  CORBA::Any voidany;
	  voidany.type(CORBA::_tc_void);
	  nproperties[ni].property_value = voidany; //CORBA::Any(CORBA::_tc_void);
	  }
      }

  // If there are more properties, put them in the <PropertiesIterator>.
  // Make a new <TAO_PropertySet> and use that to create an Properties
  // iterator.  put that in a iterator and assign that to the out
  // paramerter.

  if (numOfProperties > how_many)
      {
      TAO_PropertySet *propSet_p=0;
      
      ACE_NEW (propSet_p, TAO_PropertySet);
      
      for (CORBA::ULong i = how_many;
           i < numOfProperties;
           i++, ni++)
	  {

	  try
	      {
	      CORBA::String_var strVal = node->get_string(properties[ni].in());
	      anyval <<= strVal.in();
	      propSet_p->define_property(properties[ni].in(), anyval);
	      }
	  catch (...)
	      {
	      CORBA::Any voidany;
	      voidany.type(CORBA::_tc_void);
	      propSet_p->define_property(properties[ni].in(), voidany /*CORBA::Any(CORBA::_tc_void)*/);
	      }
	  
	  }

      // Make the iterator out of the new TAO_Propset.
      TAO_PropertiesIterator *iterator_p = 0;
      ACE_NEW (iterator_p,
               TAO_PropertiesIterator (*propSet_p));

      // Init the out parameter.

      // Get the interface ptr.
      CosPropertyService::PropertiesIterator_ptr iterator2_p =
        iterator_p->_this ();
      

      // POA stuff todo here, since we have <destroy> method in the
      // <NamesIterator> interface.
      // Give ownership of this servant to the POA.
      iterator_p->_remove_ref ();
      

      // Init the out parameter.
      rest = iterator2_p;
    }
}
Example #22
0
void ReplicaController::
listener ()
{
  try
  {
    for (char buffer[1024];;)
    {
      size_t n = group_->recv (buffer, sizeof (buffer));

      ACE_HEX_DUMP ((LM_DEBUG, buffer, n));

      TAO_InputCDR cdr (buffer, n);

      CORBA::OctetSeq object_id;
      PortableInterceptor::AdapterName adapter_name;
      CORBA::String_var client_id;
      CORBA::Long retention_id;
      CORBA::OctetSeq reply;
      CORBA::Any state;

      cdr >> object_id;
      cdr >> adapter_name;
      cdr >> client_id.out ();
      cdr >> retention_id;
      cdr >> reply;
      cdr >> state;

      if (!cdr.good_bit ())
      {
        ACE_DEBUG ((LM_DEBUG, "CDR failed\n"));
        //@@ what to do?
      }

      ACE_DEBUG ((LM_DEBUG,
                  "Received log for %s with rid %i\n",
                  client_id.in (),
                  retention_id));


      RecordId rid (client_id.in (), retention_id);

      CORBA::OctetSeq_var tmp (new CORBA::OctetSeq (reply));
      log_.insert (rid, tmp);

      // Update state.
      CORBA::TypeCode_var tc = state.type ();

      if (tc->kind () != CORBA::tk_null)
      {
        PortableServer::POA_var poa = resolve_poa (adapter_name);

        PortableServer::ServantBase_var servant =
          poa->id_to_servant (object_id);

        Checkpointable* target =
          dynamic_cast<Checkpointable*> (servant.in ());

        if (target) target->set_state (state);
      }
    }
  }
  catch (ACE_TMCast::Group::Failed const&)
  {
    ACE_DEBUG ((LM_DEBUG,
                "Group failure. Perhaps, I am alone in the group.\n"));
  }
  catch (ACE_TMCast::Group::InsufficienSpace const&)
  {
    ACE_DEBUG ((LM_DEBUG, "Group::InsufficienSpace\n"));
  }

  orb_->shutdown (0);
}
Example #23
0
void
CDBPropertySet::get_all_property_names (CORBA::ULong how_many,
					CosPropertyService::PropertyNames_out property_names,
					CosPropertyService::PropertyNamesIterator_out rest)
{
  ACS_TRACE("baci::CDBPropertySet::get_all_property_names");

  // Allocating storage is a must.
  ACE_NEW (property_names,
           CosPropertyService::PropertyNames);

  // check if characteristic model is registered
  CORBA::String_var objId = getObjectId();
  CharacteristicModelImplMap::iterator iter = modelMap.find(objId.in());
  if (iter == modelMap.end())
      throw CORBA::NO_RESOURCES();

   DAONode * node = iter->second->getDAONode();
  if (!node)
      throw CORBA::NO_RESOURCES();

  CDB::stringSeq_var properties;
  try
      {
      properties = node->get_string_seq("");
      }
  catch (...)
      {
      throw CORBA::NO_RESOURCES();
      }
  
  // Validate the length.
  CORBA::ULong numOfProperties = properties->length();

  if (numOfProperties == 0)
      {
      // Nothing to do.
      return;
      }
  
  // Set the length of the property_names appropriately.
  CORBA::ULong sequenceLength = 0UL;

  if (how_many > 0)
      {
      if (how_many >= numOfProperties)
	  {
	  sequenceLength = numOfProperties;
	  }
      else
	  {
        sequenceLength = how_many;
	  }
      property_names->length (sequenceLength);
    }

  // Iterate thru names and put them in the property_names.

  CORBA::ULong ni = 0UL;
  for (; ni < sequenceLength;
       ni++)
      {
      property_names [ni] = CORBA::string_dup (properties[ni].in());
      }
  
  // If there are some more properties, put them in the
  // iterator. How?? Make a new PropertySet and use that to create
  // propertyNames Iterator.

  if (numOfProperties > how_many)
    {
      TAO_PropertySet *propertySet_p=0;

      ACE_NEW (propertySet_p, TAO_PropertySet);

      CORBA::Any anyval;
      anyval.type(CORBA::_tc_void);
      for (CORBA::ULong i = how_many;
           i < numOfProperties;
           i++, ni++)
	  {
	  propertySet_p->define_property(properties[ni].in(), anyval);
	  }

      // Make the NamesIterator out of this TAO_PropertySet.
      TAO_PropertyNamesIterator *namesIterator_p=0;
      ACE_NEW (namesIterator_p, TAO_PropertyNamesIterator (*propertySet_p));

      // Init the out parameter.

      // Get the Interface ptr.
      CosPropertyService::PropertyNamesIterator_ptr iterator_p =
        namesIterator_p->_this ();
      

      // POA stuff todo here, since we have <destroy> method in the
      // <NamesIterator> interface.
      // Give ownership of this servant to the POA.
      namesIterator_p->_remove_ref ();
      

      // Init the out parameter.
      rest = iterator_p;
    }
}
Example #24
0
void
TAO_DynSequence_i::from_any (const CORBA::Any & any)
{
  if (this->destroyed_)
    {
      throw ::CORBA::OBJECT_NOT_EXIST ();
    }

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

  if (equivalent)
    {
      // Get the CDR stream of the Any, if there isn't one, make one.
      TAO::Any_Impl *impl = any.impl ();
      TAO_OutputCDR out;
      TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0));

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

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

          cdr = unk->_tao_get_cdr ();
        }
      else
        {
          impl->marshal_value (out);
          TAO_InputCDR tmp_in (out);
          cdr = tmp_in;
        }


      CORBA::ULong arg_length;

      // If the any is a sequence, first 4 bytes of cdr hold the
      // length.
      cdr.read_ulong (arg_length);

      // If the array grows, we must do it now.
      if (arg_length > this->component_count_)
        {
          this->da_members_.size (arg_length);
        }

      CORBA::TypeCode_var field_tc =
        this->get_element_type ();

      for (CORBA::ULong i = 0; i < arg_length; ++i)
        {
          CORBA::Any field_any;
          TAO_InputCDR unk_in (cdr);
          TAO::Unknown_IDL_Type *field_unk = 0;
          ACE_NEW (field_unk,
                   TAO::Unknown_IDL_Type (field_tc.in (),
                                          unk_in));
          field_any.replace (field_unk);

          if (i < this->component_count_)
            {
              this->da_members_[i]->destroy ();
            }

          this->da_members_[i] =
            TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> (
              field_any._tao_get_typecode (),
              field_any,
              this->allow_truncation_ );

          // Move to the next field in the CDR stream.
          (void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr);
        }

      // Destroy any dangling members.
      for (CORBA::ULong j = arg_length; j < this->component_count_; ++j)
        {
          this->da_members_[j]->destroy ();
        }

      // If the array shrinks, we must wait until now to do it.
      if (arg_length < this->component_count_)
        {
          this->da_members_.size (arg_length);
        }

      // Now we can update component_count_.
      this->component_count_ = arg_length;

      this->current_position_ = arg_length ? 0 : -1;
    }
  else
    {
      throw DynamicAny::DynAny::TypeMismatch ();
    }
}
Example #25
0
void
TAO_DynSequence_i::init (const CORBA::Any& any)
{
  CORBA::TypeCode_var tc = any.type ();

  CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());

  if (kind != CORBA::tk_sequence)
    {
      throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
    }

  this->type_ = tc;

  // Get the CDR stream of the Any, if there isn't one, make one.
  TAO::Any_Impl *impl = any.impl ();
  CORBA::ULong length;
  TAO_OutputCDR out;
  TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0));

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

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

      cdr = unk->_tao_get_cdr ();
    }
  else
    {
      impl->marshal_value (out);
      TAO_InputCDR tmp_in (out);
      cdr = tmp_in;
    }

  // If the any is a sequence, first 4 bytes of cdr hold the
  // length.
  cdr.read_ulong (length);

  // Resize the array.
  this->da_members_.size (length);

  this->init_common ();

  // Get the type of the sequence elments.
  CORBA::TypeCode_var field_tc =
    this->get_element_type ();

  for (CORBA::ULong i = 0; i < length; ++i)
    {
      CORBA::Any field_any;
      TAO_InputCDR unk_in (cdr);
      TAO::Unknown_IDL_Type *field_unk = 0;
      ACE_NEW (field_unk,
               TAO::Unknown_IDL_Type (field_tc.in (), unk_in));
      field_any.replace (field_unk);

      // This recursive step will call the correct constructor
      // based on the type of field_any.
      this->da_members_[i] =
        TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> (
          field_any._tao_get_typecode (),
          field_any,
          this->allow_truncation_ );

      // Move to the next field in the CDR stream.
      (void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr);
    }
}
Example #26
0
void
TAO_DynArray_i::from_any (const CORBA::Any& any)
{
  if (this->destroyed_)
    {
      throw ::CORBA::OBJECT_NOT_EXIST ();
    }

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

  if (equivalent)
    {
      // Get the CDR stream of the Any,if there isn't one, make one.
      TAO::Any_Impl *impl = any.impl ();
      TAO_OutputCDR out;
      TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0));

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

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

          cdr = unk->_tao_get_cdr ();
        }
      else
        {
          impl->marshal_value (out);
          TAO_InputCDR tmp_in (out);
          cdr = tmp_in;
        }

      CORBA::ULong length = static_cast<CORBA::ULong> (this->da_members_.size ());
      CORBA::ULong arg_length = this->get_tc_length (tc.in ());

      if (length != arg_length)
        {
          throw DynamicAny::DynAny::TypeMismatch ();
        }

      CORBA::TypeCode_var field_tc = this->get_element_type ();

      for (CORBA::ULong i = 0; i < arg_length; ++i)
        {
          CORBA::Any field_any;
          TAO_InputCDR unk_in (cdr);
          TAO::Unknown_IDL_Type *field_unk = 0;
          ACE_NEW (field_unk,
                   TAO::Unknown_IDL_Type (field_tc.in (), unk_in));
          field_any.replace (field_unk);

          this->da_members_[i]->destroy ();

          this->da_members_[i] =
            TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> (
              field_any._tao_get_typecode (),
              field_any,
              this->allow_truncation_ );

          // Move to the next field in the CDR stream.
          (void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr);
        }

      this->current_position_ = arg_length ? 0 : -1;
    }
  else
    {
      throw DynamicAny::DynAny::TypeMismatch ();
    }
}