当前位置: 首页>>代码示例>>C++>>正文


C++ Any::type方法代码示例

本文整理汇总了C++中corba::Any::type方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::type方法的具体用法?C++ Any::type怎么用?C++ Any::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corba::Any的用法示例。


在下文中一共展示了Any::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compareAnys

// 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;
}
开发者ID:VenturaSolutionsInc,项目名称:framework-core,代码行数:59,代码来源:Service_impl.cpp

示例2: ToString

//-----------------------------------------------------------------------------//
std::string CCorbaErrorHelper::ToString(const CORBA::Exception& err)
{
	CORBA::Any tmp;
	tmp <<= err;
	CORBA::TypeCode_var tc = tmp.type();
	return std::string(tc->name());
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:8,代码来源:CorbaErrorHelper.cpp

示例3: in

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 ());
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:58,代码来源:ConstantDef_i.cpp

示例4: populateHeader

//-----------------------------------------------------------------------------
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;
}
开发者ID:jbarriosc,项目名称:ACS,代码行数:19,代码来源:acsncSupplierImpl.cpp

示例5:

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;
}
开发者ID:milan-mpathix,项目名称:ATCD,代码行数:10,代码来源:DynAny_i.cpp

示例6:

//----------------------------------------------------------------------
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();
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:12,代码来源:acsutilAnyAide.cpp

示例7:

 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) << ">");
     }
 }
开发者ID:RemedyIT,项目名称:dancex11,代码行数:13,代码来源:best_effort.cpp

示例8:

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;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:13,代码来源:server.cpp

示例9: compareAnyToZero

// 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;
}
开发者ID:VenturaSolutionsInc,项目名称:framework-core,代码行数:54,代码来源:Service_impl.cpp

示例10:

 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);
     }
 }
开发者ID:Yijtx,项目名称:ACE,代码行数:15,代码来源:Standard_Error.cpp

示例11:

// 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);
}
开发者ID:asdlei00,项目名称:ACE,代码行数:21,代码来源:Server_Request.cpp

示例12: BAD_PARAM

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);
}
开发者ID:AlvaroVega,项目名称:TIDorbC,代码行数:21,代码来源:ContextImpl.C

示例13:

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);
}
开发者ID:CCJY,项目名称:ATCD,代码行数:21,代码来源:DynUnion_i.cpp

示例14: INTERNAL

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 ();
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:38,代码来源:DynEnum_i.cpp

示例15: string

//----------------------------------------------------------------------
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;
	}
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:86,代码来源:acsutilAnyAide.cpp


注:本文中的corba::Any::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。