예제 #1
0
 virtual bool updateAny( base::DataSourceBase::shared_ptr source, CORBA::Any& any) const
 {
     if (warn) {
         Logger::In in("CorbaFallBackProtocol");
         log(Error) << "Could not send data of type '"<< source->getTypeName()<<"' : data type not known to CORBA Transport." <<Logger::endl;
     }
     source->evaluate();
     return false;
 }
        virtual bool composeType( base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr result) const {
            const internal::DataSource<PropertyBag>* pb = dynamic_cast< const internal::DataSource<PropertyBag>* > (source.get() );
            if ( !pb )
                return false;
            typename internal::AssignableDataSource<UserType>::shared_ptr ads = boost::dynamic_pointer_cast< internal::AssignableDataSource<UserType> >( result );
            if ( !ads )
                return false;

            // last fall-back: use user supplied function:
            if ( composeTypeImpl( pb->rvalue(), ads->set() ) )
                ads->updated();
            else {
                Logger::log() <<Logger::Debug<<"Failed to compose from "<< source->getTypeName() <<Logger::endl;
                return false;
            }
            Logger::log() <<Logger::Debug<<"Successfuly composed type from "<< source->getTypeName() <<Logger::endl;
            return true;
        }
예제 #3
0
 virtual base::DataSourceBase::shared_ptr convert(base::DataSourceBase::shared_ptr arg) const {
     if ( boost::function_traits<S>::arity != 1) {
         return base::DataSourceBase::shared_ptr();
     } else {
         // The compiler should optimise this out...
         // these checks are necessary because produce(args) calls convert, which could lead to endless loops.
         // detect same type converion.
         if ( arg->getTypeInfo() == internal::DataSourceTypeInfo<result_type>::getTypeInfo() ) {
             return arg;
         }
         // detect invalid type conversion.
         if ( arg->getTypeInfo() != internal::DataSourceTypeInfo<arg1_type>::getTypeInfo() ) {
             return base::DataSourceBase::shared_ptr();
         }
         // from now on, it should always succeed.
         std::vector<base::DataSourceBase::shared_ptr> args;
         args.push_back(arg);
         base::DataSourceBase::shared_ptr ret = this->build(args);
         assert( ret );
         if (!automatic)
             log(Warning) << "Conversion from " << arg->getTypeName() << " to " << ret->getTypeName() <<endlog();
         return ret;
     }
 }
예제 #4
0
 virtual bool getMember(internal::Reference* ref, base::DataSourceBase::shared_ptr item, const std::string& name) const {
     typename internal::AssignableDataSource<T>::shared_ptr adata = boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( item );
     // Use a copy in case our parent is not assignable:
     if ( !adata ) {
         // is it non-assignable ?
         typename internal::DataSource<T>::shared_ptr data = boost::dynamic_pointer_cast< internal::DataSource<T> >( item );
         if ( data ) {
             // create a copy -> this is the only place & case where we allocate -> how to fix ?
             adata = new internal::ValueDataSource<T>( data->get() );
         }
     }
     if (adata) {
         type_discovery in( adata );
         return in.referenceMember( ref, adata->set(), name );
     }
     log(Error) << "Wrong call to type info function " + this->getTypeName() << "'s getMember() can not process "<< item->getTypeName() <<endlog();
     return false;
 }
예제 #5
0
 virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string& name) const {
     typename internal::AssignableDataSource<T>::shared_ptr adata = boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( item );
     // Use a copy in case our parent is not assignable:
     if ( !adata ) {
         // is it non-assignable ?
         typename internal::DataSource<T>::shared_ptr data = boost::dynamic_pointer_cast< internal::DataSource<T> >( item );
         if ( data ) {
             // create a copy
             adata = new internal::ValueDataSource<T>( data->get() );
         }
     }
     if (adata) {
         type_discovery in( adata );
         return in.discoverMember( adata->set(), name );
     }
     log(Error) << "Wrong call to type info function " + this->getTypeName() << "'s getMember() can not process "<< item->getTypeName() <<endlog();
     return base::DataSourceBase::shared_ptr();
 }