Orocos Real-Time Toolkit  2.6.0
PrimitiveSequenceTypeInfo.hpp
00001 #ifndef ORO_PRIMITIVE_SEQUENCE_TYPE_INFO_HPP
00002 #define ORO_PRIMITIVE_SEQUENCE_TYPE_INFO_HPP
00003 
00004 #include "PrimitiveTypeInfo.hpp"
00005 #include "SequenceTypeInfoBase.hpp"
00006 #include "MemberFactory.hpp"
00007 
00008 namespace RTT
00009 {
00010     namespace types
00011     {
00018         template<class T, bool has_ostream=false>
00019         class PrimitiveSequenceTypeInfo
00020             : public PrimitiveTypeInfo<T,has_ostream>,
00021               public SequenceTypeInfoBase<T>,
00022               public MemberFactory,
00023               public CompositionFactory
00024         {
00025         public:
00026             PrimitiveSequenceTypeInfo(std::string name)
00027                 : PrimitiveTypeInfo<T,has_ostream>(name), SequenceTypeInfoBase<T>()
00028             {}
00029 
00030         bool installTypeInfoObject(TypeInfo* ti) {
00031             // aquire a shared reference to the this object
00032             boost::shared_ptr< PrimitiveSequenceTypeInfo<T,has_ostream> > mthis = boost::dynamic_pointer_cast<PrimitiveSequenceTypeInfo<T,has_ostream> >( this->getSharedPtr() );
00033             assert(mthis);
00034             // Allow base to install first
00035             PrimitiveTypeInfo<T,has_ostream>::installTypeInfoObject(ti);
00036             SequenceTypeInfoBase<T>::installTypeInfoObject(ti);
00037             
00038             // Install the factories for primitive types
00039             ti->setMemberFactory( mthis );
00040             ti->setCompositionFactory( mthis );
00041 
00042             // Don't delete us, we're memory-managed.
00043             return false;
00044         }
00045 
00046             using PrimitiveTypeInfo<T,has_ostream>::buildVariable;
00047             base::AttributeBase* buildVariable(std::string name,int size) const
00048             {
00049                 return SequenceTypeInfoBase<T>::buildVariable(name,size);
00050             }
00051 
00052             virtual bool composeType( base::DataSourceBase::shared_ptr dssource, base::DataSourceBase::shared_ptr dsresult) const
00053             {
00054                 return SequenceTypeInfoBase<T>::composeType(dssource, dsresult);
00055             }
00056 
00057             virtual bool resize(base::DataSourceBase::shared_ptr arg, int size) const
00058             {
00059                 return SequenceTypeInfoBase<T>::resize(arg,size);
00060             }
00061             virtual base::DataSourceBase::shared_ptr decomposeType(base::DataSourceBase::shared_ptr source) const
00062             {
00063                 return SequenceTypeInfoBase<T>::decomposeType(source);
00064             }
00065             virtual std::vector<std::string> getMemberNames() const {
00066                 return SequenceTypeInfoBase<T>::getMemberNames();
00067             }
00068 
00069             virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string& name) const {
00070                 return SequenceTypeInfoBase<T>::getMember(item,name);
00071             }
00072 
00073             virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item,
00074                                                              base::DataSourceBase::shared_ptr id) const {
00075                 return SequenceTypeInfoBase<T>::getMember(item, id);
00076             }
00077         };
00078     }
00079 }
00080 
00081 #endif