/**
  * This default implementation sets up a PropertyBag which is passed
  * to decomposeTypeImpl(). It is advised to implement that function and
  * to leave this function as-is, unless you don't want to return a
  * PropertyBag, but another data type.
  */
 virtual base::DataSourceBase::shared_ptr decomposeType(base::DataSourceBase::shared_ptr source) const
 {
     // Extract typed values
     typename internal::DataSource<UserType>::shared_ptr ds = boost::dynamic_pointer_cast< internal::DataSource<UserType> >( source );
     if ( !ds )
         return base::DataSourceBase::shared_ptr(); // happens in the case of 'unknown type'
     Property<PropertyBag> targetbag_p("targetbag");
     if (decomposeTypeImpl( ds->rvalue(), targetbag_p.value() ))
         return targetbag_p.getDataSource();
     return base::DataSourceBase::shared_ptr();
 }
          /**
           * Update a transportable object for a \a protocol which contains the value of \a source.
           */
          virtual bool updateAny( base::DataSourceBase::shared_ptr source, CORBA::Any& any) const
          {
              typename internal::ReferenceDataSource<T>::shared_ptr d_ref = boost::dynamic_pointer_cast< internal::ReferenceDataSource<T> >( source );
              if ( d_ref )
                  return AnyConversion<PropertyType>::updateAny( d_ref->set(), any);

              typename internal::DataSource<T>::shared_ptr d = boost::dynamic_pointer_cast< internal::DataSource<T> >( source );
              if ( d )
                  return AnyConversion<PropertyType>::updateAny( d->get(), any);

              return false;
          }
Exemple #3
0
 void write(base::DataSourceBase::shared_ptr source)
 {
     typename internal::AssignableDataSource<T>::shared_ptr ds =
         boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >(source);
     if (ds)
         write(ds->rvalue());
     else
     {
         typename internal::DataSource<T>::shared_ptr ds =
             boost::dynamic_pointer_cast< internal::DataSource<T> >(source);
         if (ds)
             write(ds->get());
         else
             log(Error) << "trying to write from an incompatible data source" << endlog();
     }
 }
Exemple #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;
 }
Exemple #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();
 }
Exemple #6
0
            virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item,
                                                             base::DataSourceBase::shared_ptr id) const {
                typename internal::AssignableDataSource<T>::shared_ptr data = boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( item );
                if ( !data ) {
                    if ( !item->isAssignable() )
                        log(Error) << "Can't return reference to members of type "<< this->getTypeName() <<" since given object is not assignable." <<endlog();
                    else
                        log(Error) << "Consistency error: TypeInfo of type "<< this->getTypeName() <<" can't handle types of type "<< item->getType() <<endlog();
                    return base::DataSourceBase::shared_ptr();
                }

                // discover if user gave us a part name or index:
                typename internal::DataSource<int>::shared_ptr id_indx = internal::DataSource<int>::narrow( id.get() );
                typename internal::DataSource<string>::shared_ptr id_name = internal::DataSource<string>::narrow( id.get() );
                if ( id_name ) {
                    if ( id_name->get() == "size" ) {
                        try {
                            return internal::newFunctorDataSource(&get_size<T>, internal::GenerateDataSource()(item.get()) );
                        } catch(...) {}
                    }
                    if ( id_name->get() == "capacity" ) {
                        try {
                            return internal::newFunctorDataSource(&get_capacity<T>, internal::GenerateDataSource()(item.get()) );
                        } catch(...) {}
                    }
                }

                if ( id_indx ) {
                    try {
                        return internal::newFunctorDataSource(&get_container_item<T>, internal::GenerateDataSource()(item.get(), id_indx.get() ) );
                    } catch(...) {}
                }
                if (id_name) {
                    log(Error) << "MatrixTypeInfo: No such part : " << id_name->get() << endlog();
                }
                if (id_indx) {
                    log(Error) << "MatrixTypeInfo: Invalid index : " << id_indx->get() <<":"<< id_indx->getTypeName() << endlog();
                }
                return base::DataSourceBase::shared_ptr();
            }