|
29 | 29 | #include <boost/bind.hpp>
|
30 | 30 | #include <sstream>
|
31 | 31 | #include <dynamic-graph/factory.h>
|
| 32 | +#include <dynamic-graph/all-commands.h> |
32 | 33 |
|
33 | 34 | using namespace dynamicgraph;
|
34 | 35 | using namespace dynamicgraph::sot;
|
@@ -57,6 +58,8 @@ sotReader::sotReader( const std::string n )
|
57 | 58 | signalRegistration( selectionSIN<<vectorSOUT<<matrixSOUT );
|
58 | 59 | selectionSIN = true;
|
59 | 60 | vectorSOUT.setNeedUpdateFromAllChildren(true);
|
| 61 | + |
| 62 | + initCommands(); |
60 | 63 | }
|
61 | 64 |
|
62 | 65 | /* --------------------------------------------------------------------- */
|
@@ -177,42 +180,26 @@ std::ostream& operator<< ( std::ostream& os,const sotReader& t )
|
177 | 180 | return os;
|
178 | 181 | }
|
179 | 182 |
|
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() |
184 | 185 | {
|
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 | +} |
217 | 200 |
|
| 201 | +void sotReader::resize(const int & nbRow, const int & nbCol) |
| 202 | +{ |
| 203 | + nbRows = nbRow; |
| 204 | + nbCols = nbCol; |
218 | 205 | }
|
0 commit comments