Skip to content

Commit d81f902

Browse files
author
Francois Keith
committed
Update Reader: add the python interface, remove the old one.
1 parent b3fd990 commit d81f902

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

include/sot/core/reader.hh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ class SOTREADER_EXPORT sotReader
9696

9797
ml::Vector& getNextData( ml::Vector& res, const unsigned int time );
9898
ml::Matrix& getNextMatrix( ml::Matrix& res, const unsigned int time );
99+
void resize(const int & nbRow, const int & nbCol);
99100

100101
public:
101102
/* --- PARAMS --- */
102103
void display( std::ostream& os ) const;
103-
virtual void commandLine( const std::string& cmdLine
104-
,std::istringstream& cmdArgs
105-
,std::ostream& os );
104+
virtual void initCommands();
106105
};
107106

108107

src/traces/reader.cpp

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <boost/bind.hpp>
3030
#include <sstream>
3131
#include <dynamic-graph/factory.h>
32+
#include <dynamic-graph/all-commands.h>
3233

3334
using namespace dynamicgraph;
3435
using namespace dynamicgraph::sot;
@@ -57,6 +58,8 @@ sotReader::sotReader( const std::string n )
5758
signalRegistration( selectionSIN<<vectorSOUT<<matrixSOUT );
5859
selectionSIN = true;
5960
vectorSOUT.setNeedUpdateFromAllChildren(true);
61+
62+
initCommands();
6063
}
6164

6265
/* --------------------------------------------------------------------- */
@@ -177,42 +180,26 @@ std::ostream& operator<< ( std::ostream& os,const sotReader& t )
177180
return os;
178181
}
179182

180-
void sotReader::
181-
commandLine( const std::string& cmdLine
182-
,std::istringstream& cmdArgs
183-
,std::ostream& os )
183+
/* --- Command line interface ------------------------------------------------------ */
184+
void sotReader::initCommands()
184185
{
185-
if( cmdLine=="help" )
186-
{
187-
os << "Reader: "<<endl
188-
<< " - load" << endl;
189-
190-
Entity::commandLine( cmdLine,cmdArgs,os );
191-
}
192-
else if( cmdLine=="load" )
193-
{
194-
string filename;
195-
cmdArgs>>ws>>filename;
196-
load(filename);
197-
}
198-
else if( cmdLine=="rewind" )
199-
{
200-
cmdArgs>>ws;
201-
rewind( );
202-
}
203-
else if( cmdLine=="clear" )
204-
{
205-
cmdArgs>>ws;
206-
clear( );
207-
}
208-
else if( cmdLine=="resize" )
209-
{
210-
cmdArgs >>ws;
211-
if( cmdArgs.good() ) { cmdArgs >> nbRows >>nbCols; }
212-
else { os << "Matrix size = " << nbRows << " x " <<nbCols <<std::endl; }
213-
}
214-
else { Entity::commandLine( cmdLine,cmdArgs,os ); }
215-
216-
186+
namespace dc = ::dynamicgraph::command;
187+
addCommand("clear",
188+
dc::makeCommandVoid0(*this,&sotReader::clear,
189+
"Clear the data loaded"));
190+
addCommand("rewind",
191+
dc::makeCommandVoid0(*this,&sotReader::rewind,
192+
"Reset the iterator to the beginning of the data set"));
193+
addCommand("load",
194+
dc::makeCommandVoid1(*this,&sotReader::load,
195+
"load file"));
196+
addCommand("resize",
197+
dc::makeCommandVoid2(*this,&sotReader::resize,
198+
" "));
199+
}
217200

201+
void sotReader::resize(const int & nbRow, const int & nbCol)
202+
{
203+
nbRows = nbRow;
204+
nbCols = nbCol;
218205
}

0 commit comments

Comments
 (0)