コード例 #1
0
    bool ImageDisplayComponent::addDisplaySource(std::string tag, std::string type, DataSourceBase::shared_ptr orig)
    {

        // creates a copy of the data and an update command to
        // update the copy from the original.
        //
        // Added IplImage type
        Logger::In in("ImageDisplayComponent");

        // Check if the type is IplImage, if this fail
        if(orig->getTypeName()!="IplImage"){
            log(Error) << "Could not display '"<< tag <<"': This is not a IplImage type, it the Vision tookkit loaded?" << endlog();
            return false;
        }
        DataSourceBase::shared_ptr clone = orig->getTypeInfo()->buildValue();
        if ( !clone ) {
            log(Error) << "Could not display '"<< tag <<"' : unknown type." << endlog();
            return false;
        }
        try {
            boost::shared_ptr<CommandInterface> comm( clone->updateCommand( orig.get() ) );
            assert( comm );
            root.push_back( boost::make_tuple( tag, orig, comm, clone, type ) );
        } catch ( bad_assignment& ba ) {
            log(Error) << "Could not display '"<< tag <<"' : failed to create Command." << endlog();
            return false;
        }
        return true;
    }
コード例 #2
0
ファイル: PropertyBase.cpp プロジェクト: hanson315/rtt
bool PropertyBase::compose( const PropertyBag& source)
{
    DataSourceBase::shared_ptr dsb = getDataSource();
    ConstReferenceDataSource<PropertyBag> rds(source);
    rds.ref();
    if (dsb)
        return dsb->getTypeInfo()->composeType( &rds, dsb);
    return false;
}
コード例 #3
0
::CORBA::Any * RTT_corba_CConfigurationInterface_i::getAttribute (
    const char * name)
{
    if ( !mar || !mar->hasAttribute( string(name) ) )
        return new CORBA::Any();
    DataSourceBase::shared_ptr ds = mar->getValue( string(name) )->getDataSource();
    const TypeInfo* ti = ds->getTypeInfo();
    CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
    assert( ctt );
    return ctt->createAny( ds );
}
コード例 #4
0
::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();
}
コード例 #5
0
CORBA::Boolean RTT_corba_CConfigurationInterface_i::propertyFromString (
    const char* name, const char* value
  )
{
    DataSourceBase::shared_ptr ds = getPropertyDataSource( name );
    if (!ds)
        return false;
    if ( ds->getTypeInfo()->fromString( value, ds ) ) {
        RTT::log(RTT::Error) << "corba::CConfigurationInterface: Could not assign string to "<< ds->getType() <<"." <<RTT::endlog();
        return false;
    }
    return true;
}
コード例 #6
0
::CORBA::Boolean RTT_corba_CConfigurationInterface_i::setProperty (
    const char * name,
    const ::CORBA::Any & value)
{
    if (mar)
        mbag = mar->properties(); // leave this here to get latest propertybag.
    DataSourceBase::shared_ptr ds = getPropertyDataSource(name);
    if ( !ds )
        return 0;
    const TypeInfo* ti = ds->getTypeInfo();
    CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
    assert( ctt );
    return ctt->updateFromAny( &value, ds );
}
コード例 #7
0
::CORBA::Any * RTT_corba_CConfigurationInterface_i::getProperty (
    const char * name)
{
    if (mar)
        mbag = mar->properties(); // leave this here to get latest propertybag.
    if ( mbag == 0 )
        return new CORBA::Any();
    DataSourceBase::shared_ptr ds = getPropertyDataSource(name);
    if ( !ds ) {
        log(Error) <<"CConfigurationInterface: no such property: " << name << ". Returning empty CORBA::Any."<<endlog();
        return new CORBA::Any();
    }
    const TypeInfo* ti = ds->getTypeInfo();
    CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
    assert( ctt );
    return ctt->createAny( ds );
}