• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ datasourcebase::shared_ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中datasourcebase::shared_ptr的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr类的具体用法?C++ shared_ptr怎么用?C++ shared_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: addDisplaySource

    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;
    }
开发者ID:ptroja,项目名称:orocos-ocl,代码行数:29,代码来源:DisplayImageComponent.cpp


示例2: string_dup

char * RTT_corba_CConfigurationInterface_i::getPropertyTypeName (
    const char * name)
{
    DataSourceBase::shared_ptr ds = getPropertyDataSource( name );
    if (ds)
        return CORBA::string_dup( ds->getTypeName().c_str() );
    return CORBA::string_dup( "na" );
}
开发者ID:FynnGamadeyo,项目名称:rtt,代码行数:8,代码来源:ConfigurationInterfaceI.cpp


示例3: configureHook

    bool ImageDisplayComponent::configureHook(){
        Logger::In in("ImageDisplayComponent");

        // Load config file
        if ( this->marshalling()->readProperties( this->getName() + ".cpf" ) == false)
            return false;

        log(Info) << "Loading Ports to display from file." <<endlog();
        PropertyDemarshaller dem( config.get() );
        PropertyBag bag;
        if (dem.deserialize( bag ) == false ) {
            log(Error) << "Reading file "<< config.get() << " failed."<<endlog();
            return false;
        }

        bool ok = true;
        PropertyBag::const_iterator it = bag.getProperties().begin();
        while ( it != bag.getProperties().end() ){
            Property<std::string>* compName = dynamic_cast<Property<std::string>* >( *it );
            if ( !compName )
                log(Error) << "Expected Property \""
                           << (*it)->getName() <<"\" to be of type string."<< endlog();
            else if ( compName->getName() == "ImagePort" ) {
                string cname = compName->value().substr(0, compName->value().find("."));
                string pname = compName->value().substr( compName->value().find(".")+1, string::npos);
                ok &= this->addDisplayPort(cname, pname);
            }
            else {
                log(Error) << "Expected \"Component\", \"Port\" or \"Data\", got "
                           << compName->getName() << endlog();
                ok = false;
            }
            ++it;
        }
        deleteProperties( bag );

        // Create window for every dataport
        for(Reports::iterator it = root.begin(); it != root.end(); ++it ) {
            // Update the dataport
            (it->get<2>())->execute();
            // Get the base dataport
            DataSourceBase::shared_ptr source = it->get<3>();
            // Convert to Dataport<IplImage>
            DataSource<IplImage>::shared_ptr clone = AdaptDataSource<IplImage>()( source.get() );
            IplImage localImage = clone->get();
            string dataportName = it->get<0>();
            cvNamedWindow(dataportName.data(),CV_WINDOW_AUTOSIZE);
            cvShowImage(dataportName.data(),&localImage);
        }

        // Enter main loop of the window, and update the window if needed
        int key;
        key = cvWaitKey(3);
        // Magic number 3


        return ok;
    }
开发者ID:ptroja,项目名称:orocos-ocl,代码行数:58,代码来源:DisplayImageComponent.cpp


示例4: compose

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;
}
开发者ID:hanson315,项目名称:rtt,代码行数:9,代码来源:PropertyBase.cpp


示例5: Any

::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 );
}
开发者ID:eacousineau,项目名称:rtt,代码行数:11,代码来源:ConfigurationInterfaceI.cpp


示例6: 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


示例7: propertyFromString

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


示例8: getPropertyDataSource

::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 );
}
开发者ID:FynnGamadeyo,项目名称:rtt,代码行数:14,代码来源:ConfigurationInterfaceI.cpp


示例9: updateFromAny

 /**
  * Update \a target with the contents of \a blob which is an object of a \a protocol.
  */
 virtual bool updateFromAny(const CORBA::Any* blob, DataSourceBase::shared_ptr target) const
 {
     if (warn) {
         Logger::In in("CorbaFallBackProtocol");
         log(Error) << "Could not update type '"<<target->getTypeName()<<"' with received data : data type not known to CORBA Transport." <<Logger::endl;
     }
     return false;
 }
开发者ID:orocos-toolchain,项目名称:rtt,代码行数:11,代码来源:CorbaLib.cpp


示例10: updateHook

    void ImageDisplayComponent::updateHook()
    {
        // For every dataport
        for(Reports::iterator it = root.begin(); it != root.end(); ++it ) {
            // Update the dataport
            (it->get<2>())->execute();
            // Get the base dataport
            DataSourceBase::shared_ptr source = it->get<3>();
            // Convert to Dataport<IplImage>
            DataSource<IplImage>::shared_ptr clone = AdaptDataSource<IplImage>()( source.get() );
            IplImage localImage = clone->get();
            string dataportName = it->get<0>();
            cvShowImage(dataportName.data(),&localImage);
        }

        // Enter main loop of the window, and update the window if needed
        int key;
        key = cvWaitKey(3);
        // Magic number 3
    }
开发者ID:ptroja,项目名称:orocos-ocl,代码行数:20,代码来源:DisplayImageComponent.cpp


示例11: seenexpression

    void ConditionParser::seenexpression()
    {
        // get the datasource parsed by the ExpressionParser..
        DataSourceBase::shared_ptr mcurdata =
            expressionparser.getResult();
        expressionparser.dropResult();

        // The reference count is stored in the DataSource itself !
        // so the ref cnt information is not lost in this cast
        ds_bool =
            dynamic_cast<DataSource<bool>*>( mcurdata.get() );
        if ( ds_bool )
            {
                mcurdata = 0;
            }
        else
            {
                // we only want boolean expressions..
                throw parse_exception_semantic_error(
                                                     "Attempt to use a non-boolean value as a condition." );
            }
    }
开发者ID:jsreng,项目名称:orocos-rtt,代码行数:22,代码来源:ConditionParser.cpp


示例12: CreateMethod

 corba::CMethod_ptr ExpressionServer::CreateMethod( DataSourceBase::shared_ptr expr, MethodC* orig, PortableServer::POA_ptr p ) {
     // try to retrieve:
     corba::CMethod_ptr result = MServers[ expr ];
     if ( !CORBA::is_nil(result) )
         return corba::CMethod::_duplicate(result);
     // create new:
     if ( CORBA::is_nil(p) )
         p = ApplicationServer::rootPOA.in();
     Logger::log() <<Logger::Debug<< "Created 'Any' CMethod server for type "<< expr->getType()<<Logger::endl;
     Orocos_AnyMethod_i* newexpr = new Orocos_AnyMethod_i( *orig, expr, p );
     MServers[expr] = newexpr->activate_this();
     EServants[expr] = newexpr;
     EServers[expr] = corba::CExpression::_narrow(MServers[expr]);
     return corba::CMethod::_duplicate( MServers[expr] );
 }
开发者ID:jsreng,项目名称:orocos-rtt,代码行数:15,代码来源:ExpressionServer.cpp


示例13: CreateAssignableExpression

 corba::CExpression_ptr ExpressionServer::CreateAssignableExpression( DataSourceBase::shared_ptr expr, PortableServer::POA_ptr p ){
     // try to retrieve:
     corba::CAssignableExpression_ptr result = AServers[ expr ];
     if ( !CORBA::is_nil(result) )
         return corba::CExpression::_duplicate(result);
     // create new:
     if ( CORBA::is_nil(p) )
         p = ApplicationServer::rootPOA.in();
     Logger::log() <<Logger::Debug<< "Created 'Any' Assignable CExpression server for type "<< expr->getType()<<Logger::endl;
     Orocos_AnyAssignableExpression_i* newexpr = new Orocos_AnyAssignableExpression_i( expr, p );
     AServers[expr] = newexpr->activate_this();
     EServants[expr] = newexpr;
     EServers[expr] = corba::CExpression::_narrow(AServers[expr]);
     corba::CExpression_var ret = corba::CExpression::_duplicate( EServers[expr] );
     return ret._retn();
 }
开发者ID:jsreng,项目名称:orocos-rtt,代码行数:16,代码来源:ExpressionServer.cpp


示例14: execute

    int StatementProcessor::execute(const std::string& comm)
    {
        Logger::In in("StatementProcessor");
        TaskContext* taskcontext = d->tc;

        // Minor hack : also check if it was an attribute of current TC, for example,
        // if both the object and attribute with that name exist. the if
        // statement after this one would return and not give the expr parser
        // time to evaluate 'comm'.
        if ( taskcontext->provides()->getValue( comm ) ) {
                d->printResult( taskcontext->provides()->getValue( comm )->getDataSource().get(), true );
                return 0;
        }

        Parser _parser;

        Logger::log() <<Logger::Debug << "Trying ValueChange...";
        try {
            // Check if it was a method or datasource :
            DataSourceBase::shared_ptr ds = _parser.parseValueChange( comm, taskcontext );
            // methods and DS'es are processed immediately.
            if ( ds.get() != 0 ) {
                Logger::log() << "ok" << Logger::endl;
                d->printResult( ds.get(), false );
                return 0; // done here
            } else
                Logger::log() <<Logger::Debug << "no"<<Logger::endl;
        } catch ( fatal_semantic_parse_exception& pe ) { // incorr args, ...
            // way to fatal,  must be reported immediately
            Logger::log() << Logger::Debug << "fatal_semantic_parse_exception: ";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( syntactic_parse_exception& pe ) { // wrong content after = sign etc..
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "syntactic_parse_exception: ";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( parse_exception_parser_fail &pe )
            {
                // ignore, try next parser
                Logger::log() << Logger::Debug << "Ignoring ValueChange exception :"<<Logger::nl;
                Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        } catch ( parse_exception& pe ) {
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        }
        Logger::log() << Logger::Debug << "Trying Expression..."<<Logger::nl;
        try {
            // Check if it was a method or datasource :
            DataSourceBase::shared_ptr ds = _parser.parseExpression( comm, taskcontext );
            // methods and DS'es are processed immediately.
            if ( ds.get() != 0 ) {
                d->printResult( ds.get(), true );
                return 0; // done here
            } else
                Logger::log() << Logger::Error << "returned zero !"<<Logger::nl;
        } catch ( syntactic_parse_exception& pe ) { // missing brace etc
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "syntactic_parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( fatal_semantic_parse_exception& pe ) { // incorr args, ...
            // way to fatal,  must be reported immediately
            Logger::log() << Logger::Error << "fatal_semantic_parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( parse_exception_parser_fail &pe ) {
                // ignore, try next parser
                Logger::log() << Logger::Debug << "Ignoring Expression exception :"<<Logger::nl;
                Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        } catch ( parse_exception& pe ) {
            // ignore, try next parser
            Logger::log() << Logger::Debug << "Ignoring Expression parse_exception :"<<Logger::nl;
            Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        }
        return -1;
    }
开发者ID:FynnGamadeyo,项目名称:rtt,代码行数:79,代码来源:StatementProcessor.cpp


示例15: doPrint

        void doPrint( DataSourceBase* ds, bool recurse) {
            // this is needed for ds's that rely on initialision.
            // e.g. eval true once or time measurements.
            // becomes only really handy for 'watches' (todo).
            ds->reset();
            /**
             * If this list of types gets to long, we can still add a virtual
             * printOut( std::ostream& ) = 0 to DataSourceBase.
             */
            // this method can print some primitive DataSource<>'s.
            DataSource<bool>* dsb = DataSource<bool>::narrow(ds);
            if (dsb) {
                Logger::log() << dsb->get();
                return;
            }
            DataSource<int>* dsi = DataSource<int>::narrow(ds);
            if (dsi) {
                Logger::log() << dsi->get() ;
                return;
            }
#if 0
            // does not work yet with CORBA layer.
            DataSource<long>* dsl = DataSource<long>::narrow(ds);
            if (dsl) {
                Logger::log() << dsl->get() ;
                return;
            }
#endif
            DataSource<unsigned int>* dsui = DataSource<unsigned int>::narrow(ds);
            if (dsui) {
                Logger::log() << dsui->get() ;
                return;
            }
            DataSource<std::string>* dss = DataSource<std::string>::narrow(ds);
            if (dss) {
                Logger::log() <<'"'<< dss->get() << '"' ;
                return;
            }
#if 0
            DataSource<std::vector<double> >* dsvval = DataSource< std::vector<double> >::narrow(ds);
            if (dsvval) {
                Logger::log()  << dsvval->get() ;
                return;
            }
            DataSource< Double6D >* ds6d = DataSource<Double6D>::narrow(ds);
            if (ds6d) {
                Logger::log()  << ds6d->get() ;
                return;
            }
#endif
            DataSource<double>* dsd = DataSource<double>::narrow(ds);
            if (dsd) {
                Logger::log() << dsd->get() ;
                return;
            }
            DataSource<char>* dsc = DataSource<char>::narrow(ds);
            if (dsc) {
                Logger::log() <<'\''<< dsc->get()<<'\'' ;
                return;
            }

            DataSource<PropertyBag>* dspbag = DataSource<PropertyBag>::narrow(ds);
            if (dspbag) {
                PropertyBag bag( dspbag->get() );
                if (!recurse) {
                    int siz = bag.getProperties().size();
                    Logger::log()  << siz <<" Properties";
                } else {
                    if ( ! bag.empty() ) {
                        Logger::log()  <<Logger::nl;
                        for( PropertyBag::iterator it= bag.getProperties().begin(); it!=bag.getProperties().end(); ++it) {
                            Logger::log()  <<(*it)->getType()<<" "<< (*it)->getName();
                            DataSourceBase::shared_ptr propds = (*it)->getDataSource();
                            this->printResult( propds.get(), false );
                            Logger::log()  <<" ("<<(*it)->getDescription()<<')' << Logger::nl;
                        }
                    } else {
                        Logger::log()  <<"(empty PropertyBag)";
                    }
                }
                return;
            }

            // Leave void  as last since any DS is convertible to void !
            DataSource<void>* dsvd = DataSource<void>::narrow(ds);
            if (dsvd) {
                dsvd->get();
                Logger::log() << "(void)" ;
                return;
            }

            if (ds) {
                ds->evaluate();
                Logger::log() << "( result type '"+ds->getType()+"' not known to TaskBrowser )" ;
            }

        }
开发者ID:FynnGamadeyo,项目名称:rtt,代码行数:97,代码来源:StatementProcessor.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ datastructures::HashIndex类代码示例发布时间:2022-05-31
下一篇:
C++ dataobjects::Workspace2D_sptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap