providing RTT or OCL with type vector<ANYTYPE>

Hi,

Ruben and I extended the OCL vectorTemplateComposition (patch and original file
attached) such that support for the type vector<ANYTYPE> is provided. Anytype
can be a really anything. We thoroughly tested for double, int, bool, string,
and some home created types like ColumnVector, Matrix, ....

You can create your own vector<Type> as follows:

RTT::TypeInfoRepository::Instance()->addType( new
StdVectorTemplateTypeInfo<ColumnVector,true>("ColumnVectors") );
RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>addConstructor(newConstructor(stdvector_ctor<ColumnVector>() ) );
RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>addConstructor(newConstructor(stdvector_ctor2<ColumnVector>() ) );
RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>addConstructor(new StdVectorBuilder<ColumnVector>() );

where you replace ColumnVector with you own type.

We believe this can be usefull contribution for a lot of users. I even believe
it should be added to RTT in stead of OCL.

Tinne

AttachmentSize
vectorTemplateComposition.patch9.81 KB
VectorTemplateComposition.hpp12.15 KB

providing RTT or OCL with type vector<ANYTYPE>

On Friday 20 March 2009 14:37:47 Tinne De Laet wrote:
> Hi,
>
> Ruben and I extended the OCL vectorTemplateComposition (patch and original
> file attached) such that support for the type vector<ANYTYPE> is provided.
> Anytype can be a really anything. We thoroughly tested for double, int,
> bool, string, and some home created types like ColumnVector, Matrix, ....
>
> You can create your own vector<Type> as follows:
>
> RTT::TypeInfoRepository::Instance()->addType( new
> StdVectorTemplateTypeInfo<ColumnVector,true>("ColumnVectors") );
> RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>
> >addConstructor(newConstructor(stdvector_ctor<ColumnVector>() ) );
>
> RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>
> >addConstructor(newConstructor(stdvector_ctor2<ColumnVector>() ) );
>
> RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
>
> >addConstructor(new StdVectorBuilder<ColumnVector>() );
>
> where you replace ColumnVector with you own type.
>
> We believe this can be usefull contribution for a lot of users. I even
> believe it should be added to RTT in stead of OCL.

I agree. I have a remark about the property names you use: "Element n"
You use a space in the property name, which I would strongly discourage,
since spaces are not allowed in identifiers in scripting languages.

Peter

providing RTT or OCL with type vector<ANYTYPE>

On Tuesday 24 March 2009 13:29:36 Peter Soetens wrote:
> On Friday 20 March 2009 14:37:47 Tinne De Laet wrote:
> > Hi,
> >
> > Ruben and I extended the OCL vectorTemplateComposition (patch and
> > original file attached) such that support for the type vector<ANYTYPE> is
> > provided. Anytype can be a really anything. We thoroughly tested for
> > double, int, bool, string, and some home created types like ColumnVector,
> > Matrix, ....
> >
> > You can create your own vector<Type> as follows:
> >
> > RTT::TypeInfoRepository::Instance()->addType( new
> > StdVectorTemplateTypeInfo<ColumnVector,true>("ColumnVectors") );
> >
> > RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
> >
> > >addConstructor(newConstructor(stdvector_ctor<ColumnVector>() ) );
> >
> >
> > RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
> >
> > >addConstructor(newConstructor(stdvector_ctor2<ColumnVector>() ) );
> >
> >
> > RTT::TypeInfoRepository::Instance()->type("ColumnVectors")-
> >
> > >addConstructor(new StdVectorBuilder<ColumnVector>() );
> >
> > where you replace ColumnVector with you own type.
> >
> > We believe this can be usefull contribution for a lot of users. I even
> > believe it should be added to RTT in stead of OCL.
>
> I agree. I have a remark about the property names you use: "Element n"
> You use a space in the property name, which I would strongly discourage,
> since spaces are not allowed in identifiers in scripting languages.
Ok, I agree. I removed the space and changed the name to "Elementn"

I'll open a bug report for the proposed enhancement.

Tinne