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


C++ CorbaTypeTransporter::updateAny方法代码示例

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


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

示例1: wrong_number_of_args_exception

base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produceCollect(const std::vector<base::DataSourceBase::shared_ptr>& args, internal::DataSource<bool>::shared_ptr blocking) const {
    unsigned int expected = mfact->getCollectArity(method.c_str());
    if (args.size() !=  expected + 1) {
        throw wrong_number_of_args_exception( expected + 1, args.size() );
    }
    // isolate and check CSendHandle
    std::vector<base::DataSourceBase::shared_ptr> cargs( ++args.begin(), args.end() );
    DataSource<CSendHandle_var>::shared_ptr ds = DataSource<CSendHandle_var>::narrow( args.begin()->get() );
    if (!ds) {
        throw wrong_types_of_args_exception(0,"CSendHandle_var",(*args.begin())->getTypeName() );
    }
    // check if args matches what CSendHandle expects.
    try {
        corba::CAnyArguments_var nargs = new corba::CAnyArguments();
        nargs->length( cargs.size() );
        for (size_t i=0; i < cargs.size(); ++i ) {
            const types::TypeInfo* ti = cargs[i]->getTypeInfo();
            CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
            assert( ctt );
            DataSourceBase::shared_ptr tryout = ti->buildValue();
            ctt->updateAny(tryout, nargs[i]);
        }
        ds->get()->checkArguments( nargs.in() );
    } catch ( CWrongNumbArgException& wna) {
        throw wrong_number_of_args_exception(wna.wanted, wna.received);
    } catch ( CWrongTypeArgException& wta) {
        throw wrong_types_of_args_exception(wta.whicharg,wta.expected.in(), wta.received.in());
    }
    // All went well, produce collect DataSource:
    return new CorbaOperationCallerCollect( ds->get().in(),cargs, blocking);
}
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:31,代码来源:CorbaOperationCallerFactory.cpp

示例2: wrong_types_of_args_exception

base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produceSend(const std::vector<base::DataSourceBase::shared_ptr>& args, ExecutionEngine* caller) const {
    corba::CAnyArguments_var nargs = new corba::CAnyArguments();
    nargs->length( args.size() );
    for (size_t i=0; i < args.size(); ++i ) {
        const types::TypeInfo* ti = args[i]->getTypeInfo();
        CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
        if (!ctt)
		throw wrong_types_of_args_exception(i+1,"type known to CORBA transport", ti->getTypeName());
        DataSourceBase::shared_ptr tryout = ti->buildValue();
        ctt->updateAny(tryout, nargs[i]);
    }
    try {
        // will throw if wrong args.
        mfact->checkOperation(method.c_str(), nargs.inout() );
        // Will return a CSendHandle_var:
        DataSource<CSendHandle_var>::shared_ptr result = new ValueDataSource<CSendHandle_var>();
        return new ActionAliasDataSource<CSendHandle_var>(new CorbaOperationCallerCall(mfact.in(),method,args,caller, 0, result, false), result.get() );
    } catch ( corba::CNoSuchNameException& nsn ) {
        throw  name_not_found_exception( nsn.name.in() );
    } catch ( corba::CWrongNumbArgException& wa ) {
        throw  wrong_number_of_args_exception( wa.wanted, wa.received );
    } catch ( corba::CWrongTypeArgException& wta ) {
        throw  wrong_types_of_args_exception( wta.whicharg, wta.expected.in(), wta.received.in() );
    }
    return 0; // not reached.
}
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:26,代码来源:CorbaOperationCallerFactory.cpp

示例3: sourcevector_to_anysequence

/**
 * Helper function to convert a vector of data sources to a sequence of anys.
 * @param sources
 * @param anys
 * @return
 */
bool sourcevector_to_anysequence( vector<DataSourceBase::shared_ptr> const& sources, CAnyArguments & anys ) {
    bool valid = true;
    anys.length( sources.size() );
    for(unsigned int i = 0; i != sources.size(); ++i) {
        const TypeInfo* ti = sources[i]->getTypeInfo();
        CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*> ( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
        ctt->updateAny(sources[i], anys[i]);
    }
    return valid;
}
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:16,代码来源:OperationInterfaceI.cpp

示例4: readArguments

 void readArguments() {
     // We need to delay reading the arguments upto this point such that the args contain
     // the latest values.
     nargs = new corba::CAnyArguments();
     nargs->length( margs.size() );
     for (size_t i=0; i < margs.size(); ++i ) {
         const types::TypeInfo* ti = margs[i]->getTypeInfo();
         CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
         assert( ctt );
         ctt->updateAny(margs[i], nargs[i]);
     }
 }
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:12,代码来源:CorbaOperationCallerFactory.cpp

示例5: orig

::CORBA::Any * RTT_corba_COperationInterface_i::callOperation (
    const char * operation,
    ::RTT::corba::CAnyArguments & args)
{
    if ( mfact->hasMember( string( operation ) ) == false || mfact->isSynchronous(string(operation)) )
        throw ::RTT::corba::CNoSuchNameException( operation );
    // convert Corba args to C++ args.
    try {
        OperationCallerC orig(mfact->getPart(operation), operation, 0);
        vector<DataSourceBase::shared_ptr> results;
        for (size_t i =0; i != args.length(); ++i) {
            const TypeInfo* ti = mfact->getPart(operation)->getArgumentType( i + 1);
            CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*> ( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
            // we need to store the results for returning them to caller (args is inout!) after the call()
            results.push_back( ctt->createDataSource( &args[i] ) );
            orig.arg( results[i] );
        }
        if ( orig.ready() ) {
            DataSourceBase::shared_ptr ds = orig.getCallDataSource();
            CORBA::Any* retany;

            // Try to get the return result :
            const TypeInfo* ti = ds->getTypeInfo();
            CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*> ( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
            if ( !ctt ) {
                log(Warning) << "Could not return results of call to " << operation << ": unknown return type by CORBA transport."<<endlog();
                ds->evaluate(); // equivalent to orig.call()
                retany = new CORBA::Any();
            } else {
                retany =  ctt->createAny( ds ); // call evaluate internally
            }

            // Return results into args:
            for (size_t i =0; i != args.length(); ++i) {
                const TypeInfo* ti = mfact->getPart(operation)->getArgumentType( i + 1);
                CorbaTypeTransporter* ctta = dynamic_cast<CorbaTypeTransporter*> ( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
                ctta->updateAny(results[i], args[i]);
            }
            return retany;
        } else {
            orig.check(); // will throw
        }
    } catch (no_asynchronous_operation_exception& ) {
        throw ::RTT::corba::CNoSuchNameException( operation );
    } catch ( name_not_found_exception& ) {
        throw ::RTT::corba::CNoSuchNameException( operation );
    } catch ( wrong_number_of_args_exception& wna ) {
        throw ::RTT::corba::CWrongNumbArgException( wna.wanted, wna.received );
    } catch (wrong_types_of_args_exception& wta ) {
        throw ::RTT::corba::CWrongTypeArgException( wta.whicharg, wta.expected_.c_str(), wta.received_.c_str() );
    }
    return new ::CORBA::Any();
}
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:53,代码来源:OperationInterfaceI.cpp


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