Hi,
i'm implementing scripting support for std::vector
i already have two types of contructors and the index operator working:
templateList(size)
templateList(size,elem)
list[i]
giving me the following results for a stringList and a boolList:
(type 'ls' for context info) :stringList(3)
Got :stringList(3)
= [ , , ]
(type 'ls' for context info) :stringList(3,"test")
Got :stringList(3,"test")
= [ test ,test ,test ]
(type 'ls' for context info) :stringList(3,"test")[2]
Got :stringList(3,"test")[2]
= test
(type 'ls' for context info) :boolList(3)
Got :boolList(3)
= [ 0 ,0 ,0 ]
(type 'ls' for context info) :boolList(3,true)
Got :boolList(3,true)
= [ 1 ,1 ,1 ]
(type 'ls' for context info) :boolList(3,true)[2]
Got :boolList(3,true)[2]
= true
but i cannot get the constructor
templatList = [elem1,elem2,elem3] to work,
i checked the code for the RTT type array and adapted it. But i cannot
get it to compile, this is the code:
template
struct StdVectorBuilder
: public TypeBuilder
{
virtual DataSourceBase::shared_ptr build(const
std::vector
if (args.size() == 0 )
return DataSourceBase::shared_ptr();
NArityDataSource
new NArityDataSource
for(unsigned int i=0; i != args.size(); ++i) {
DataSource
args[i] );
if (dsd)
vds->add( dsd );
else
return DataSourceBase::shared_ptr();
}
return vds;
}
};
and the compile error:
/home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp: In member
function 'virtual boost::intrusive_ptr
RTT::StdVectorBuilder
std::vector
std::allocator
/home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp:198: error:
expected `;' before 'vds'
/home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp:200:
error: expected `;' before 'dsd'
i think there is something wrong with this line 198:
NArityDataSource
NArityDataSource
but i have no idea what is wrong. Can anyone help me out?
Ruben
scripting support std::vector<T>
On Monday 11 February 2008 10:08:25 Ruben Smits wrote:,
> Hi,
>
> i'm implementing scripting support for std::vector
>
> i already have two types of contructors and the index operator working:
>
> templateList(size)
> templateList(size,elem)
> list[i]
Be sure to talk new syntax through on the mailinglist before you go to far
with your implementation... Are you registering 'stringList' below as a type
name ?
>
> giving me the following results for a stringList and a boolList:
>
> (type 'ls' for context info) :stringList(3)
> Got :stringList(3)
> = [ , , ]
[...]
> and the compile error:::build(const, > >&) const': >::shared_ptr vds = new >();
>
> /home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp: In member
> function 'virtual boost::intrusive_ptr
> RTT::StdVectorBuilder
> std::vector
> std::allocator
> /home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp:198: error:
> expected `;' before 'vds'
> /home/rsmits/orocos/ocl-pma/ocl/VectorTemplateComposition.hpp:200:
> error: expected `;' before 'dsd'
>
>
> i think there is something wrong with this line 198:
> NArityDataSource
> NArityDataSource
>
> but i have no idea what is wrong. Can anyone help me out?
Since T is a template argument, the compiler does not know yet
what ::shared_ptr is: is it a variable or a type ? By default, the compiler
assumes it is a variable. In order to say that shared_ptr is a type, use:
typename NArityDataSource >::shared_ptr vds = new >();
NArityDataSource
Peter
scripting support std::vector<T>
On Monday February 11 2008 10:42:52 Peter Soetens wrote:,
> On Monday 11 February 2008 10:08:25 Ruben Smits wrote:
> > Hi,
> >
> > i'm implementing scripting support for std::vector
> >
> > i already have two types of contructors and the index operator working:
> >
> > templateList(size)
> > templateList(size,elem)
> > list[i]
>
> Be sure to talk new syntax through on the mailinglist before you go to far
> with your implementation... Are you registering 'stringList' below as a
> type name ?
The implementation is complete for as far as i know, std::vector).
can now be used in scripting the same way as array (a
std::vector
The needed types are now registered asList and have three kinds ofList(size), List(size,elem),
List(elem1,elem2,...,elemN) and a index operator List[i].
constructors:
I tested all of it for a stringList and a boolList, if there are other
suggestions for the registered names, please let me know. All the code
is committed in the ocl-pma branch. Should i open a bug/project for
the patch or just send it to the mailinglist?
[...] >::shared_ptr vds = new >(); >::shared_ptr vds = >();
> >
> > i think there is something wrong with this line 198:
> > NArityDataSource
> > NArityDataSource
> >
> > but i have no idea what is wrong. Can anyone help me out?
>
> Since T is a template argument, the compiler does not know yet
> what ::shared_ptr is: is it a variable or a type ? By default, the compiler
> assumes it is a variable. In order to say that shared_ptr is a type, use:
>
> typename NArityDataSource
> new NArityDataSource
Thanks, it works like a sharm.
Ruben
scripting support std::vector<T>
On Monday 11 February 2008 13:03:48 Ruben Smits wrote:).List and have three kinds ofList(size), List(size,elem),List(elem1,elem2,...,elemN) and a index operator List[i].
> On Monday February 11 2008 10:42:52 Peter Soetens wrote:
> >
> > Be sure to talk new syntax through on the mailinglist before you go to
> > far with your implementation... Are you registering 'stringList' below as
> > a type name ?
>
> The implementation is complete for as far as i know, std::vector
> can now be used in scripting the same way as array (a
> std::vector
>
> The needed types are now registered as
> constructors:
>
>
> I tested all of it for a stringList and a boolList, if there are other
> suggestions for the registered names, please let me know. All the code
> is committed in the ocl-pma branch. Should i open a bug/project for
> the patch or just send it to the mailinglist?
>
I suggest you open a bug report. You can submit the attachment at the same
page where you open the bug.
My only remark is that the naming doesn't feel 'consistent': we then have
array, boolList and stringList. Maybe 'bools' and 'strings' would be better ?
Peter
PS: Please don't add me in CC, I'm really subscribed to this list ! Use 'reply
to list' ( key 'l' in kmail/kontact, possibly working in other mail clients
as well).
[Bug 513] New: [Project] Add scripting support for std::vector<T
For more infomation about this bug, visit
Summary: [Project] Add scripting support for std::vector
Product: OCL
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: project
Priority: P2
Component: Other
AssignedTo: orocos-dev [..] ...
ReportedBy: ruben [dot] smits [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0
The patch contains two files:
VectorTemplateComposition.hpp: contains all templated code
ocltoolkit.cpp: contains the specific addition of the constructors and
operators for a specific type
Some remarks: The typename of a std::vector is "list" and always the sameList as typename. Maybe it
for all kinds of T. The composition and decomposition works but all
PropertyBags get the same name ("list"). In contrast with the typenames in the
scripting support which all have (for now)
is desirable to have the same names for the properties and the scripting-types.
But i have not yet found a way how to do this.
The scripting support is automatically loaded if liborocos-ocl-common-
is linked with your application.
In the ocl-pma branch i added a dependency of liborocos-taskbrowser to
liborocos-ocl-common to make the scripting support available when using the
deployer executable. I do not know if this is desirable, but I think it is a
nice solution until the deployer can load RTT-plugins.
Ruben
[Bug 513] [Project] Add scripting support for std::vector<T>
https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=513
Ruben Smits <ruben [dot] smits [..] ...> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution| |DUPLICATE
Status|ASSIGNED |RESOLVED
--- Comment #6 from Ruben Smits <ruben [dot] smits [..] ...> 2009-08-20 08:30:56 ---
Apparently the same proposal.
Ruben
*** This bug has been marked as a duplicate of bug 640 ***
[Bug 513] [Project] Add scripting support for std::vector<T>
For more infomation about this bug, visit
Ruben Smits <ruben [dot] smits [..] ...> changed:
What |Removed |Added
--------------------------------------------------------------------------
Target Milestone|--- |1.4.2
--- Comment #5 from Ruben Smits <ruben [dot] smits [..] ...> 2008-06-04 09:56:06 ---
Can i commit this to trunk/ocl, or should i add the header
VectorTemplateComposition.hpp to rtt and only commit the rest on ocl?
the names for the types are: T-name+s -> doubles, bools, strings, etc.
Ruben
[Bug 513] [Project] Add scripting support for std::vector<T>
For more infomation about this bug, visit
--- Comment #4 from Ruben Smits <ruben [dot] smits [..] ...> 2008-02-29 11:18:59 --- scripting support for T=bool,string,int
(In reply to comment #3)
> (In reply to comment #2)
> > Created an attachment (id=237)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=237) [details] [details]
> > Add vector
> >
>
> This patch is against files which were not attached yet to this bug report.
I think the files already exist in the source
> A question remains if this is for OCL or RTT... from a new user's point of
> view, it is not clear why these types are in OCL and the other are in RTT.
> What's the object size of this additional code ?
>
For me it is the same. I would suggest that the header is added to RTT. As long
as no support for a type is added this adds no object size, but the user can
easily add his own type using a header from RTT instead of OCL.
I looked at the object size of liborocos-ocl-common compiled with buildtype
OCL(=RTT) and came to the following object sized:
Adding no support: 17K
Only for bools: 377K
Only for strings: 406K
Only for doubles: 395K
Only for ints: 335K
All previous: 1.3M
So i guess we should only add support for doubles in RTT(which replaces the
current array), and leave the rest to the user or OCL
Ruben
[Bug 513] [Project] Add scripting support for std::vector<T>
For more infomation about this bug, visit
Peter Soetens
<peter [dot] soetens [..] ...> changed:
What |Removed |Added
--------------------------------------------------------------------------
CC| |peter [dot] soetens [..] ...
--- Comment #3 from Peter Soetens scripting support for T=bool,string,int
<peter [dot] soetens [..] ...> 2008-02-16 09:11:07 ---
(In reply to comment #2)
> Created an attachment (id=237)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=237) [details]
> Add vector
>
This patch is against files which were not attached yet to this bug report.
A question remains if this is for OCL or RTT... from a new user's point of
view, it is not clear why these types are in OCL and the other are in RTT.
What's the object size of this additional code ?
[Bug 513] [Project] Add scripting support for std::vector<T>
On Saturday February 16 2008 09:11:07 Peter Soetens wrote: scripting support for T=bool,string,int
> For more infomation about this bug, visit
>
>
> Peter Soetens
<peter [dot] soetens [..] ...> changed:
>
> What |Removed |Added
> --------------------------------------------------------------------------
> CC| |peter [dot] soetens [..] ...
>
>
>
> --- Comment #3 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-02-16
> 09:11:07 --- (In reply to comment #2)
>
> > Created an attachment (id=237)
>
> --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=237) [details]
>
> > Add vector
>
> This patch is against files which were not attached yet to this bug report.
>
> A question remains if this is for OCL or RTT... from a new user's point of
> view, it is not clear why these types are in OCL and the other are in RTT.
> What's the object size of this additional code ?
>
Ik ben zeker voorstander om die code in RTT toe te voegen ipv in OCL, want dan
kan ik die ook makkelijker in de kdltoolkit gebruiken. Liever vroeg dan laat
dus.
Enig idee hoe ik die object size kan bepalen?
> --
> Configure bugmail:
> https://www.fmtc.be/bugzilla/orocos/userprefs.cgi?tab=email ------- You are
> receiving this mail because: -------
> You are on the CC list for the bug.
[Bug 513] [Project] Add scripting support for std::vector<T>
For more infomation about this bug, visit
Ruben Smits <ruben [dot] smits [..] ...> changed:
What |Removed |Added
--------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|orocos- |ruben [dot] smits [..] ...
|dev [..] ... |
--- Comment #2 from Ruben Smits <ruben [dot] smits [..] ...> 2008-02-15 17:25:38 --- scripting support for T=bool,string,int
Created an attachment (id=237)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=237)
Add vector
[Bug 513] [Project] Add scripting support for std::vector<T>
For more infomation about this bug, visit
--- Comment #1 from Ruben Smits <ruben [dot] smits [..] ...> 2008-02-14 12:21:23 ---
(In reply to comment #0)
[...]
> Some remarks: The typename of a std::vector
To avoid confusion, i mean:
the typename of a Property >
>is "list" and always the same
> for all kinds of T.
Ruben