From 118db7d47d7899cc391bf29409b93fd3e4acdef1 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel <guilhem.saurel@gmail.com> Date: Wed, 1 Aug 2018 13:12:27 +0200 Subject: [PATCH] remove shell ref https://github.com/stack-of-tasks/sot-core/issues/58 --- CMakeLists.txt | 4 - ChangeLog | 2 + doc/CMakeLists.txt | 25 -- doc/additionalDoc/dgshell_doc.h | 14 -- doc/additionalDoc/package.h | 58 +---- doc/additionalDoc/shellfunctions_doc.h | 45 ---- doc/additionalDoc/tracer-real-timedoc.h | 3 +- doc/additionalDoc/tracerdoc.h | 3 +- doc/dg-shell-plugin.pod.in | 27 --- doc/dg-shell.pod.in | 64 ------ doc/figures/use-case.svg | 1 - include/CMakeLists.txt | 10 +- include/dynamic-graph/debug.h | 3 +- include/dynamic-graph/entity.h | 10 +- include/dynamic-graph/factory.h | 12 +- include/dynamic-graph/fwd.hh | 4 - include/dynamic-graph/pool.h | 13 -- include/dynamic-graph/tracer-real-time.h | 4 - include/dynamic-graph/tracer.h | 5 +- share/CMakeLists.txt | 1 - share/dynamic-graph/script/shell.dg | 23 -- share/dynamic-graph/script/tracer.dg | 1 - src/command/value.cpp | 1 + src/dgraph/entity.cpp | 50 ---- src/dgraph/factory.cpp | 41 +--- src/dgraph/pool.cpp | 42 ---- src/plugins/shell-functions.cpp | 73 ------ src/plugins/shell-procedure.cpp | 277 ----------------------- src/traces/tracer-real-time.cpp | 37 --- src/traces/tracer.cpp | 69 ------ tests/custom-entity.cpp | 14 -- tests/entity.cpp | 93 -------- tests/interpreter-tracer.cpp | 1 - tests/interpreter.cpp | 223 ------------------ tests/interpreter.h | 34 --- 35 files changed, 21 insertions(+), 1266 deletions(-) delete mode 100644 doc/CMakeLists.txt delete mode 100644 doc/additionalDoc/dgshell_doc.h delete mode 100644 doc/additionalDoc/shellfunctions_doc.h delete mode 100644 doc/dg-shell-plugin.pod.in delete mode 100644 doc/dg-shell.pod.in delete mode 100644 doc/figures/use-case.svg delete mode 100644 share/dynamic-graph/script/shell.dg delete mode 100644 src/plugins/shell-functions.cpp delete mode 100644 src/plugins/shell-procedure.cpp delete mode 100644 tests/interpreter.cpp delete mode 100644 tests/interpreter.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b4cbf66..422b387 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,6 @@ GENERATE_CONFIGURATION_HEADER( GENERATE_CONFIGURATION_HEADER( ${HEADER_DIR} config-tracer-real-time.hh DG_TRACERREALTIME tracer_real_time_EXPORTS) -GENERATE_CONFIGURATION_HEADER( - ${HEADER_DIR} - config-shell-procedure.hh DG_SHELLPROCEDURE shell_procedure_EXPORTS) GENERATE_CONFIGURATION_HEADER( ${HEADER_DIR} config-contiifstream.hh DG_CONTIIFSTREAM contiifstream_EXPORTS) @@ -65,7 +62,6 @@ SEARCH_FOR_EIGEN() ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(include) -ADD_SUBDIRECTORY(doc) ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(share) diff --git a/ChangeLog b/ChangeLog index 155b576..a6ccfff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ CHANGELOG [Current] +* remove shell + [v3.0.0] * Replace jrl-mal with eigen * Add ostream and isteram operators for Eigen Classes diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt deleted file mode 100644 index 24a7094..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2010, Olivier Stasse, JRL, CNRS/AIST -# -# This file is part of dynamic-graph. -# dynamic-graph is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# dynamic-graph is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Lesser Public License for more details. You should have -# received a copy of the GNU Lesser General Public License along with -# dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -INCLUDE(../cmake/man.cmake) - -IF(UNIX) - # Add `man' target. - ADD_CUSTOM_TARGET(man DEPENDS dg-shell.1.gz dg-shell-plugin.1.gz) - - # Man page generation. - MANPAGE(dg-shell) - MANPAGE(dg-shell-plugin) -ENDIF(UNIX) diff --git a/doc/additionalDoc/dgshell_doc.h b/doc/additionalDoc/dgshell_doc.h deleted file mode 100644 index 433fd08..0000000 --- a/doc/additionalDoc/dgshell_doc.h +++ /dev/null @@ -1,14 +0,0 @@ -/** -\ingroup gshellfunctions -\page dgshell_doc dg-shell executable -The dynamic-graph shell program "dg-shell" allows access to the dynamic-graph library's -Interpreter class, which can execute commands and scripts from the command line. -It can be found in the installation prefix's bin/ directory. - -There is also a linux shell script available, dg-shell-plugin, that creates a -and loads a default script whose goal is to load useful plugins at startup -(shell-functions and shell-procedure). - -For an example of shell commands and scripts, see \ref scriptingabout. - -**/ diff --git a/doc/additionalDoc/package.h b/doc/additionalDoc/package.h index 7f8d145..15355dd 100644 --- a/doc/additionalDoc/package.h +++ b/doc/additionalDoc/package.h @@ -38,7 +38,7 @@ for a given problem. It is the basis for the stack of tasks operation. <p>To give a more concrete example, the real-time control used by the Gepetto group for the humanoid robot HRP-2 is detailled.</p> <p> -Real-time control system are usually driven by a cyclic computational node which +Real-time control system are usually driven by a cyclic computational node which needs to send a control reference value to each motors of a robot. To compute this control reference values, sensor values need to be provided. In the Stack-Of-Tasks special entities called Device are used to @@ -52,13 +52,13 @@ This control vector is the result of a computation solving a control problem. The entity in charge of solving this control problem is called "Solver" in the previous figure. In the SoT framework it is often cast as an optimization problem. -This optimization problem is build using a control "Task" (not to be confused with the +This optimization problem is build using a control "Task" (not to be confused with the general word task). A control "Task" regulates the difference with a "Feature" computed on the current robot state and a "Desired Feature". For instance when walking, the regulated -feature is the robot's Center-Of-Mass (CoM) position. The "Feature" is computed using a +feature is the robot's Center-Of-Mass (CoM) position. The "Feature" is computed using a library using the robot model and the sensor value. The entity making this computation is "Dyn". A walking pattern generator using foot-steps position given in advance generates the desired -value for the CoM. +value for the CoM. Note that the "Dyn" entity uses the sensor provided by the entity "Robot". </p> <p> @@ -90,7 +90,7 @@ See \ref scriptingabout \subsection entity_definition General definition Despite the fact that it looks very similar to a ROS node or a CORBA/OpenRTM server, an entity is simply a C++ object. -The main idea is that this entity is providing mostly a data-driven functionnality working at very high rate (\f$ 200 Hz\f$ or \f$ 1 kHz \f$) +The main idea is that this entity is providing mostly a data-driven functionnality working at very high rate (\f$ 200 Hz\f$ or \f$ 1 kHz \f$) and should have a minimal computational time foot-print. For this signals (or ports to use a more classical terminology) are providing a time dependency between data. @@ -101,7 +101,7 @@ but in general the external data is based upon the sensor values provided by a " For this reason the signal evaluations are realized through the cascade of dependencies and start from the evaluation of an input signal of a periodic node (in general the device). This is realized inside a \b real-time thread. -To add flexibility to a node, it is possible to add command with arguments to modify the internal behavior of the entity +To add flexibility to a node, it is possible to add command with arguments to modify the internal behavior of the entity or get information from the entity. As a command is in general asynchronous and rare with respect to the data-flow scheme for the signals the command is in general executed in a \b none-real-time thread. @@ -123,8 +123,6 @@ the entities' names in the scripts; loading this file with the plugin loader wil enable creation of this entity through the factory. \li \ref tracerdoc \li \ref tracerrealtimedoc -\li ShellProcedure -\li \ref shellfunctions_doc \subsection specific_semantics Specific semantics with entities @@ -152,10 +150,10 @@ The class \ref dynamicgraph::FactoryStorage is a singleton which register the en \subsection pool Pool The class \ref dynamicgraph::PoolStorage keeps track of the entities instanciated with the factory. The entities are the graph nodes. Signals are constructed during the class instanciation, they do not live independently -from the entities. Signals are the directed edges of the graph. -The pool can write a file representing the graph of entities. +from the entities. Signals are the directed edges of the graph. +The pool can write a file representing the graph of entities. -\subsection scriptingabout Building the graph +\subsection scriptingabout Building the graph This package provides a scripting language allows entities to define their own commands, and provides a basic framework to build dynamically the computational graph. @@ -175,16 +173,6 @@ register them in the Pool, where they can be listed, accessed, and acted upon (see PoolStorage documentation). Basic commands defined by entities include signal connection graph file generation, help and name print, and signals. -Finally, a shell (command-line) interface is made available thanks to the -Interpreter class (see the file test_shell.cpp for an example). Objects deriving from -Entity can expose their own commands by overriding the Entity's default -commandLine() method. It is possible to load a plugin to register custom -shell commands; see shell-functions and shell-procedure for an example. - -Some basic shell functions, and support for procedures, are also included. -For a complete list of those, load the plugin shell-functions.so and type 'help' -at the command line. - The singletons made available by including the corresponding headers in this module are: \li dynamicgraph::FactoryStorage @@ -193,13 +181,6 @@ module are: For an example of a program creating entities in C++, see the unit test test_pool.cpp (in your package source directory/unitTesting). -\subsection use_scripts Through scripts -The program \ref dgshell_doc can be used to have scripting access to the dynamic-graph -library, where you can execute scripts and commands, load plugins, create entities and connect signals. - -Here is a typical use case for programmers: -\image html figures/use-case.png - \subsection Tutorial A tutorial is available <a href="http://stack-of-tasks.github.io/dynamic-graph-tutorial/">here</a> \section references References @@ -217,25 +198,6 @@ IEEE Trans. on Robotics, 23(1):60-72, February 2007 \namespace dynamicgraph This is the namespace where every object and class of this library is located. -\defgroup gshellfunctions Notes about the scripting language -@{ -A couple of functions are built-in in the interpreter and provides low-level features such as file sourcing or -plug-in loading.\n -These functions are:\n -\code plug <obj1.sig1> <obj2.sig2> \endcode plugs the signal sig1 of obj1 to the signal sig2 of obj2. sig1 and sig2 -have to be of the same type. sig1 has to be an output signal and sig2 an input signal. -\code new <class> <object> \endcode instantiates an object object of class class. object has to be a free identifier and -class an existing entity. -\code destroy <object> \endcode deletes an instance previously created. -\code run <script.txt> \endcode sources (i.e. read and interpret) an external file. -\code loadPlugin <file.so> <directory> \endcode loads a plugin called file.so and located in the directory directory. -\code unloadPlugin <path/file.so> \endcode unloads a plugin. -\code help \endcode lists available functions. -\code set <obj.signal> <value> \endcode defines an input signal to a specific, constant, value. -\code get <obj.signal> <value> \endcode prints out a signal value. -\code compute <obj.sig> <time> \endcode computes an output signal and sets the associated time to time. -@} - \defgroup dgraph Core classes and objects @{ @@ -258,8 +220,6 @@ Signals can be grouped together using dynamicgraph::SignalArray. Signals implement a caching mechanism by storing the last computation time tick. -Some signals can be plugged ("plug" script command) into one another or set through shell commands. - For more information, please see the individual signal pages. \b Samples diff --git a/doc/additionalDoc/shellfunctions_doc.h b/doc/additionalDoc/shellfunctions_doc.h deleted file mode 100644 index 67a985e..0000000 --- a/doc/additionalDoc/shellfunctions_doc.h +++ /dev/null @@ -1,45 +0,0 @@ -/** -\ingroup gshellfunctions -\page shellfunctions_doc ShellFunctions -\note Note: this documentation covers specific aspects of the in-house -scripting language currently used by the dynamic-graph script. Unless -otherwise specified, it is only relevant for programmers using this -particular language. At the time of writing, there is talk of -replacing the language with python, so check if this information is still -relevant before reading. - -\section description Description -The \b ShellFunctions plugin file adds common shell functions to the -dynamic-graph shell. -\section commands Commands -The supplementary \b commands provided (you can also type 'help' at the -dynamic-graph shell command line to see them and a brief description): -\code - LoadPlugins - Try - DisplayPlugins - DisplayFactory - Commentary - Unplug - ClearPlugin - SignalTime - SynchroSignal - Echo - Copy - Freeze - Squeeze - EnableTrace - SetPrompt - Sleep - Beep - FlagSet - CompletionList -\endcode - -\section addi Additional information -See doxygen documentation for the class ShellFunctions - -\section generates Generated plugin file -shell-functions.dll or shell-functions.so. - -**/ diff --git a/doc/additionalDoc/tracer-real-timedoc.h b/doc/additionalDoc/tracer-real-timedoc.h index 5cebd66..0f45826 100644 --- a/doc/additionalDoc/tracer-real-timedoc.h +++ b/doc/additionalDoc/tracer-real-timedoc.h @@ -5,8 +5,7 @@ The \b TracerRealTime entity monitors a set of signals with real-time constraint function is very similar to the Tracer, except that all traces are recorded to a memory buffer, which can be emptied at any time. \section commands Commands -The \b commands that this entity exposes are (you can also type [entity name].help at the -dynamic-graph shell command line to see this list): +The \b commands that this entity exposes are: \code empty (discards all buffers) buffersize (sets buffer size for recording) diff --git a/doc/additionalDoc/tracerdoc.h b/doc/additionalDoc/tracerdoc.h index ca408e7..4df3c3c 100644 --- a/doc/additionalDoc/tracerdoc.h +++ b/doc/additionalDoc/tracerdoc.h @@ -6,8 +6,7 @@ the tracked signal values are recorded and traced to a file. The behavior of the function can be changed, from printing to a file immediately after recording, to printing out only when asked explicitly. \section commands Commands -The \b commands that this entity exposes are (you can also type [entity name].help at the -dynamic-graph shell command line to see this list): +The \b commands that this entity exposes are: \code open, close (a file); add (a signal) diff --git a/doc/dg-shell-plugin.pod.in b/doc/dg-shell-plugin.pod.in deleted file mode 100644 index d11280b..0000000 --- a/doc/dg-shell-plugin.pod.in +++ /dev/null @@ -1,27 +0,0 @@ -=head1 NAME - -dg-shell-plugin - Stack of tasks shell with all plug-ins loaded - - -=head1 SYNOPSIS - -dg-shell-plugin - - -=head1 DESCRIPTION - -Start the stack of tasks with all core plug-ins loaded. - -=head1 AUTHORS - -This software has been developed at CNRS/AIST and LAAS-CNRS laboratories. - -See <@CMAKE_INSTALL_PREFIX@/share/doc/libdg-middleware-dev/AUTHORS> to -see the list of all contributors. - - -=head1 SEE ALSO - - dg-shell(1) - -See also <@PROJECT_URL@> for additional resources. diff --git a/doc/dg-shell.pod.in b/doc/dg-shell.pod.in deleted file mode 100644 index 0654bbe..0000000 --- a/doc/dg-shell.pod.in +++ /dev/null @@ -1,64 +0,0 @@ -=head1 NAME - -dg-shell - Stack of tasks shell - - -=head1 SYNOPSIS - -dg-shell [--input <file>|-i <file>|--noninteractive|-n|--prologue|-prologue <file>|-h|--help] - - -=head1 DESCRIPTION - -Start the stack of tasks and provides to the user an interactive shell -to control the data-flow. - -By default, the shell first evaluates the prologue file -($HOME/.dg-shellrc by default). Additional input files passed as -arguments to evaluate multiple files. - - -=head1 OPTIONS - -B<-i> I<file>, B<--input> I<file> - evaluate the file at start-up - -B<-n>, B<--noninteractive> - enable the non-interactive mode - -B<-p> I<file>, B<--prologue> I<file> - override the default prologue file (i.e. $HOME/.dg-shellrc) - -B<-h>, B<--help> - produce help message - - -=head1 EXAMPLES - -No options is required to launch a shell: - - dg-shell - - -To evaluate "example.dg" only: - - dg-shell -i example.dg -n - -To evaluate "example1.dg", "example2.dg" and provide a shell to the user: - - dg-shell -i example1.dg -i example2.dg - - -=head1 AUTHORS - -This software has been developed at CNRS/AIST and LAAS-CNRS laboratories. - -See <@CMAKE_INSTALL_PREFIX@/share/doc/libdg-middleware-dev/AUTHORS> to -see the list of all contributors. - - -=head1 SEE ALSO - - dg-shell-plugin(1) - -See also <@PROJECT_URL@> for additional resources. diff --git a/doc/figures/use-case.svg b/doc/figures/use-case.svg deleted file mode 100644 index cafbf10..0000000 --- a/doc/figures/use-case.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="721" height="735"><defs></defs><rect stroke="#000000" stroke-width="0" fill="#ffffff" x="0" y="0" width="720" height="734"/><g transform='translate(21.0,40.0)'><line x1='0.0' y1='0.0' x2='601.0' y2='0.0' stroke-dasharray='23, 0' stroke='#333333' stroke-width='1' /><g transform='translate(290.5,0.0)'></g></g><g transform='translate(26.5,-9.5) rotate(0 175.0 33.5)'><g transform='translate(0.0,41.5)'><text x='2' style='text-anchor: start' y='-3.0'><tspan xml:space='preserve' font-size='18' font-family='Arial' fill='#000000' >Typical plugin loading and usage process</tspan></text></g></g><g transform='translate(56.0,55.5) rotate(0 70.0 37.5)'><g transform='translate(0.0,0.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='21.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,21.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='20.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,41.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='34.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,15.5)'><text x='70.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' text-decoration='underline' >:PluginLoader</tspan></text></g><g ></g><g ></g></g><g transform='translate(91.26515179773804,214.89454904672732) rotate(0 37.734848202261965 30.10545095327268)'><rect x='0.0' y='4.493350888548161' width='67.65211829090791' height='55.41799429209398' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><polygon points='0.0,4.493350888548161 7.516902032323101,0.0 75.16902032323101,0.0 67.65211829090791,4.493350888548161 ' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><polygon points='75.16902032323101,0.0 75.16902032323101,55.41799429209398 67.65211829090791,59.911345180642144 67.65211829090791,4.493350888548161 ' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><g transform='translate(0.0,35.10545095327268)'><text x='37.734848202261965' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-style='italic' >plugin.so</tspan></text></g></g><g transform='translate(361.0,245.5) rotate(0 70.0 37.5)'><g transform='translate(0.0,0.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='21.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,21.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='20.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,41.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='34.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,15.5)'><text x='70.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' text-decoration='underline' >factory:Factory</tspan></text></g><g ></g><g ></g></g><g transform='translate(361.0,395.5) rotate(0 70.0 37.5)'><g transform='translate(0.0,0.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='21.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,21.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='20.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,41.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='34.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,15.5)'><text x='70.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' text-decoration='underline' >pool:Pool</tspan></text></g><g ></g><g ></g></g><g transform='translate(361.0,542.0) rotate(0 70.0 45.0)'><g transform='translate(0.0,0.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='36.0' stroke="#000000" stroke-width="2.0" fill="#ffffff"/></g><g transform='translate(0.0,36.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='34.0' stroke="#000000" stroke-width="2.0" fill="#ffffff"/></g><g transform='translate(0.0,70.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='20.0' stroke="#000000" stroke-width="2.0" fill="#ffffff"/></g><g transform='translate(0.0,15.0)'><text x='70.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' text-decoration='underline' >myEntityInstance</tspan></text><text x='70.0' style='text-anchor: middle' y='14.2'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' text-decoration='underline' >:Entity</tspan></text></g><g transform='translate(0.0,54.0)'><text x='2' style='text-anchor: start' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >+</tspan><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >commandLine(input</tspan></text><text x='2' style='text-anchor: start' y='14.2'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >stream, output stream)</tspan></text></g><g ></g></g><g transform='translate(130.0,214.0)'><line x1='-0.017762440882695196' y1='-0.49968439608805953' x2='-3.0' y2='-84.39454904672732' stroke-dasharray='23, 0' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(267.9641458400894)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(-1.5031560391194043,-37.19727452336366)'><rect fill='#ffffff' x='-20.5' y='-9.0' width='41.0' height='15'/><text x='0.0' style='text-anchor: middle' y='2.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >loads</tspan></text></g></g><g transform='translate(360.0,128.5) rotate(0 70.0 37.5)'><g transform='translate(0.0,0.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='21.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,21.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='20.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,41.0)'><rect x='0.0' y='0.0' width='139.4422310756972' height='34.0' stroke="#000000" stroke-width="2.0" fill="#ffcc33"/></g><g transform='translate(0.0,15.5)'><text x='70.0' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' font-weight='bold' >Shell:Interpreter</tspan></text></g><g ></g><g ></g></g><g transform='translate(536.2421099913893,64.97396996134887) rotate(0 29.75789000861068 48.026030038651136)'><circle cx='29.56081788934836' cy='9.566938254711381' r='9.85360596311612' fill='#FFFFFF' stroke="#000000" stroke-width="1.0"/><line x1='29.56081788934836' y1='19.133876509422763' x2='29.56081788934836' y2='57.40162952826829' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='29.56081788934836' y1='57.40162952826829' x2='19.70721192623224' y2='95.66938254711381' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='29.56081788934836' y1='57.40162952826829' x2='39.41442385246448' y2='95.66938254711381' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='29.56081788934836' y1='57.40162952826829' x2='39.41442385246448' y2='95.66938254711381' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='0.0' y1='28.700814764134144' x2='59.12163577869672' y2='28.700814764134144' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><g transform='translate(0.0,114.05206007730227)'><text x='29.75789000861068' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >user</tspan></text></g></g><g transform='translate(431.0,321.0)'><line x1='0.006666074153073843' y1='0.4999555614806037' x2='1.0' y2='75.0' stroke-dasharray='23, 0' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(89.23610153907002)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(0.49955561480603716,42.5)'><rect fill='#ffffff' x='-53.0' y='-9.0' width='106.0' height='15'/><text x='0.0' style='text-anchor: middle' y='2.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >calls newEntity()</tspan></text></g></g><g transform='translate(501.0,580.0)'><path d='M1.0,0.0 L94.75789000861073,0.0 Q104.75789000861073,0.0 104.75789000861073,-10.0 L104.75789000861073,-457.0 Q104.75789000861073,-467.0 94.75789000861073,-467.0 L93.75789000861073,-467.0 ' stroke-dasharray='23, 0' fill='none' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(0.0)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(104.75789000861073,-166.62105499569464)'><rect fill='#ffffff' x='-98.5' y='-17.0' width='197.0' height='15'/><text x='0.0' style='text-anchor: middle' y='-6.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >requests new instance creation</tspan></text><rect fill='#ffffff' x='-98.5' y='1.1999999999999993' width='197.0' height='15'/><text x='0.0' style='text-anchor: middle' y='12.2'><tspan font-size='13px' font-family='Arial' fill='#000000' >(either through code or the shell)</tspan></text></g></g><g transform='translate(196.0,93.0)'><line x1='0.49913841090379535' y1='0.029340190190827932' x2='340.24210999138927' y2='20.0' stroke-dasharray='23, 0' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(3.364070655892468)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(160.13828677761873,10.0)'><rect fill='#ffffff' x='-98.5' y='-17.0' width='197.0' height='15'/><text x='0.0' style='text-anchor: middle' y='-6.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >requests plugin load</tspan></text><rect fill='#ffffff' x='-98.5' y='1.1999999999999993' width='197.0' height='15'/><text x='0.0' style='text-anchor: middle' y='12.2'><tspan font-size='13px' font-family='Arial' fill='#000000' >(either through code or the shell)</tspan></text></g></g><g transform='translate(167.0,245.0)'><path d='M0.0,0.0 Q96.5,0.0 96.5,-39.5 Q96.5,-79.0 189.0,-78.98193899898531 ' stroke-dasharray='23, 0' fill='none' stroke='#000000' stroke-width='1' /><g transform='translate(193.0,-79.0) rotate(539.0)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(102.0,-37.5)'><rect fill='#ffffff' x='-90.0' y='-9.0' width='180.0' height='15'/><text x='0.0' style='text-anchor: middle' y='2.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >(auto-)registers functions with</tspan></text></g></g><g transform='translate(361.0,283.0)'><path d='M-4.0,-0.008528940762130819 Q-97.13257589886902,0.0 -97.13257589886902,-19.0 Q-97.13257589886902,-38.0 -194.26515179773804,-38.0 ' stroke-dasharray='23, 0' fill='none' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(180.0)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(-92.0,-16.5)'><rect fill='#ffffff' x='-85.0' y='-9.0' width='170.0' height='15'/><text x='0.0' style='text-anchor: middle' y='2.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >(auto-)registers entities with</tspan></text></g></g><g transform='translate(431.0,471.0)'><line x1='0.0' y1='0.5' x2='0.0' y2='64.0' stroke-dasharray='23, 0' stroke='#000000' stroke-width='1' /><g transform='translate(0.0,0.0) rotate(90.0)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(0.0,37.0)'><rect fill='#ffffff' x='-74.0' y='-9.0' width='148.0' height='15'/><text x='0.0' style='text-anchor: middle' y='2.0'><tspan font-size='13px' font-family='Arial' fill='#000000' >(auto-)registers entity to</tspan></text></g></g><g transform='translate(361.0,587.0)'><line x1='0.0' y1='0.0' x2='-131.5' y2='-6.123233995736766E-17' stroke-dasharray='23, 0' stroke='#000000' stroke-width='1' /><g transform='translate(-132.0,0.0) rotate(360.0)'><polygon points='2.0,0 8.0,-3.0 8.0,3.0' fill='#000000' stroke='#000000' stroke-width='1.0' /></g><g transform='translate(-76.0,0.0)'></g></g><g transform='translate(81.5,555.0) rotate(0 72.5 40.0)'><polygon points='0.0,0.0 124.203187250996,0.0 144.42231075697208,18.543046357615896 144.42231075697208,79.47019867549669 0.0,79.47019867549669 ' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='124.203187250996' y1='0.0' x2='124.203187250996' y2='18.543046357615896' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><line x1='124.203187250996' y1='18.543046357615896' x2='144.42231075697208' y2='18.543046357615896' stroke="#000000" stroke-width="1.0" fill="#ffffff"/><g transform='translate(0.0,21.0)'><text x='72.5' style='text-anchor: middle' y='-2.0'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >Can respond to</tspan></text><text x='72.5' style='text-anchor: middle' y='14.2'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >commands e.g. (in the</tspan></text><text x='72.5' style='text-anchor: middle' y='30.4'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >shell) myEntity.help,</tspan></text><text x='72.5' style='text-anchor: middle' y='46.599999999999994'><tspan xml:space='preserve' font-size='13' font-family='Arial' fill='#000000' >etc.</tspan></text></g></g></svg> \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index ec6d20b..85df52f 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -13,16 +13,8 @@ # received a copy of the GNU Lesser General Public License along with # dynamic-graph. If not, see <http://www.gnu.org/licenses/>. -# Add default import directories. -# It is used by the import directive of the sot shell to locate -# scripts and plug-ins. -SET( - DG_IMPORT_DEFAULT_PATHS - "${CMAKE_INSTALL_PREFIX}/share/dynamic-graph/script:${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}" - ) - CONFIGURE_FILE( - ${PROJECT_NAME}/import-default-paths.h.cmake + ${PROJECT_NAME}/import-default-paths.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h DESTINATION include/${PROJECT_NAME} diff --git a/include/dynamic-graph/debug.h b/include/dynamic-graph/debug.h index cef0eed..9c28ea5 100644 --- a/include/dynamic-graph/debug.h +++ b/include/dynamic-graph/debug.h @@ -81,8 +81,9 @@ namespace dynamicgraph inline void trace (const int level=-1) { - if (level <= traceLevel) + if (level <= traceLevel) { outputbuffer << tmpbuffer.str (); tmpbuffer.str(""); + } } inline void traceTemplate (const int level, const char* format, ...) diff --git a/include/dynamic-graph/entity.h b/include/dynamic-graph/entity.h index 0b866a6..c36ab5d 100644 --- a/include/dynamic-graph/entity.h +++ b/include/dynamic-graph/entity.h @@ -64,11 +64,7 @@ namespace dynamicgraph /// /// These signals link the entities together to form a complete /// computation graph. To declare a new entity, please see the - /// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h. A - /// command-line interface provided by the entity can be used by a - /// sot shell to call methods from entities and display the result - /// of their execution. Classes that derive from Entity can - /// customize the command-line by overriding commandLine (). + /// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h. class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable { public: @@ -93,10 +89,6 @@ namespace dynamicgraph virtual void display (std::ostream& os) const; - virtual void commandLine (const std::string& cmdLine, - std::istringstream& cmdArgs, - std::ostream& os); - virtual SignalBase<int>* test () { return 0; diff --git a/include/dynamic-graph/factory.h b/include/dynamic-graph/factory.h index c85b16a..292f9d9 100644 --- a/include/dynamic-graph/factory.h +++ b/include/dynamic-graph/factory.h @@ -169,16 +169,6 @@ namespace dynamicgraph /// \param list Available entities will be appended to list. void listEntities (std::vector <std::string>& list) const; - /// \brief Define FactoryStorage commands. - /// - /// Define two equivalent commands: - /// - list - /// - listEntities - /// listing the available entities. - void commandLine (const std::string& cmdLine, - std::istringstream& cmdArgs, - std::ostream& os); - private: /// \brief Constructor the factory. @@ -197,7 +187,7 @@ namespace dynamicgraph /// \brief The entity map storing information about how to /// instantiate an Entity. EntityMap entityMap; - + /// \pointer to the unique object of the class static FactoryStorage* instance_; }; diff --git a/include/dynamic-graph/fwd.hh b/include/dynamic-graph/fwd.hh index bc94f54..6a3f558 100644 --- a/include/dynamic-graph/fwd.hh +++ b/include/dynamic-graph/fwd.hh @@ -34,7 +34,6 @@ namespace dynamicgraph class OutStringStream; class PluginLoader; class PoolStorage; - class ShellFunctionRegisterer; class SignalCaster; class SignalCastRegisterer; @@ -73,7 +72,4 @@ namespace dynamicgraph } // end of namespace dynamicgraph. -class ShellFunctions; -class ShellProcedure; - #endif //! DYNAMIC_GRAPH_FWD_HH diff --git a/include/dynamic-graph/pool.h b/include/dynamic-graph/pool.h index be10f18..feaeb09 100644 --- a/include/dynamic-graph/pool.h +++ b/include/dynamic-graph/pool.h @@ -107,19 +107,6 @@ namespace dynamicgraph /// \param sigpath stream containing a string of the form "entity.signal" SignalBase<int>& getSignal( std::istringstream& sigpath ); - /*! \brief This method looks for the object named objectName, - and ask to provide the function functionName with the arguments cmdArg. - If the method of the object displays some information this will - be done on os. - - The commands specific to the \b PoolStorage singleton are: - \li \b list : List all the entities registered in the pool - */ - void commandLine (const std::string& objectName, - const std::string& functionName, - std::istringstream& cmdArg, - std::ostream& os); - /*! \brief This method write a graph description on the file named FileName. */ void writeGraph (const std::string& aFileName); diff --git a/include/dynamic-graph/tracer-real-time.h b/include/dynamic-graph/tracer-real-time.h index a2cd195..3db261b 100644 --- a/include/dynamic-graph/tracer-real-time.h +++ b/include/dynamic-graph/tracer-real-time.h @@ -65,10 +65,6 @@ namespace dynamicgraph DG_TRACERREALTIME_DLLAPI friend std::ostream& operator<< (std::ostream& os, const TracerRealTime& t); - virtual void commandLine (const std::string& cmdLine, - std::istringstream& cmdArgs, - std::ostream& os); - protected: virtual void openFile (const SignalBase<int>& sig, const std::string& filename); diff --git a/include/dynamic-graph/tracer.h b/include/dynamic-graph/tracer.h index 409036b..386f4b2 100644 --- a/include/dynamic-graph/tracer.h +++ b/include/dynamic-graph/tracer.h @@ -106,11 +106,8 @@ namespace dynamicgraph /* --- PARAMS --- */ void display( std::ostream& os ) const; - virtual void commandLine( const std::string& cmdLine - ,std::istringstream& cmdArgs - ,std::ostream& os ); - }; + }; } // end of namespace dynamicgraph diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 262458b..829dba0 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -16,7 +16,6 @@ # Install dynamic-graph scripts. INSTALL(FILES - dynamic-graph/script/shell.dg dynamic-graph/script/tracer.dg DESTINATION share/dynamic-graph/script diff --git a/share/dynamic-graph/script/shell.dg b/share/dynamic-graph/script/shell.dg deleted file mode 100644 index 7e10606..0000000 --- a/share/dynamic-graph/script/shell.dg +++ /dev/null @@ -1,23 +0,0 @@ -import "shell-functions" -# DO NOT MOVE THIS LINE: comments are not implemented before. - -# Copyright 2010, Thomas Moulard, JRL, CNRS/AIST. -# . -# This file is part of dynamic-graph. -# dynamic-graph is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# . -# dynamic-graph is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Lesser Public License for more details. You should have -# received a copy of the GNU Lesser General Public License along with -# dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -# This script provides basic shell tools. -# This file should ALWAYS be imported as it provides core features -# such as comments. - -import "shell-procedure" diff --git a/share/dynamic-graph/script/tracer.dg b/share/dynamic-graph/script/tracer.dg index f675315..702d2ae 100644 --- a/share/dynamic-graph/script/tracer.dg +++ b/share/dynamic-graph/script/tracer.dg @@ -1,4 +1,3 @@ -import "shell.dg" # Copyright 2010, Thomas Moulard, JRL, CNRS/AIST. # . # This file is part of dynamic-graph. diff --git a/src/command/value.cpp b/src/command/value.cpp index 4ff3123..5d87c66 100644 --- a/src/command/value.cpp +++ b/src/command/value.cpp @@ -158,6 +158,7 @@ namespace dynamicgraph { switch(value.type()) { case Value::NONE: copy = NULL; + break; case Value::BOOL: copy = new bool(value.boolValue()); break; diff --git a/src/dgraph/entity.cpp b/src/dgraph/entity.cpp index adae4b6..d8db618 100644 --- a/src/dgraph/entity.cpp +++ b/src/dgraph/entity.cpp @@ -235,56 +235,6 @@ getCommandList () const return Entity_COMMAND_LIST; } -void Entity:: -commandLine( const std::string& cmdLine,std::istringstream& cmdArgs,std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os << "Entity : " << std::endl - << " - print\t\t\tWhat d'you think?"<<endl - << " - signals\t\t\tDisplay the signals list."<<endl - << " - signalDep <signame> \tDisplay the dependency graph for signal signame."<<endl; - } - else if( cmdLine == "print") - { - os << *this << std::endl; - } - else if( cmdLine == "signals") - { displaySignalList(os); } - else if( cmdLine == "signalDep") - { - string sig; cmdArgs>>sig; - cmdArgs >> ws; int depth=-1; - if( cmdArgs.good () ) { cmdArgs >> depth; } - getSignal(sig) .displayDependencies( os,depth ); os<<endl; - } - else - { - try{ - SignalBase<int> & sig = getSignal( cmdLine ); - - int time; cmdArgs>>ws; - if( cmdArgs.good () ) - {cmdArgs >> time;} else {time=0;} - sig.recompute( time ); - - os << cmdLine << " = "; sig.get( os ); - } catch( ExceptionFactory& e ) { - switch( e.getCode () ) - { - case ExceptionFactory::UNREFERED_SIGNAL: - DG_THROW ExceptionFactory( ExceptionFactory::UNREFERED_FUNCTION, - "The requested function/signal :","<%s> is " - "not registered.",cmdLine.c_str () ); - break; - default: - throw; - } - } catch( ... ) { throw; } - } - -} - /// Add a command to Entity void Entity:: addCommand(const std::string& inName, Command* command) diff --git a/src/dgraph/factory.cpp b/src/dgraph/factory.cpp index 77e7e0b..f9c63e5 100644 --- a/src/dgraph/factory.cpp +++ b/src/dgraph/factory.cpp @@ -31,7 +31,7 @@ namespace dynamicgraph } return instance_; } - + void FactoryStorage::destroy() { delete instance_; @@ -144,45 +144,6 @@ namespace dynamicgraph outList.push_back(entity.first); } - void - FactoryStorage::commandLine(const std::string& cmdLine, - std::istringstream& cmdArgs, - std::ostream& os) - { - if (cmdLine == "help") - { - os << "factory "; - - std::string cmd2; - cmdArgs >> cmd2; - - if (!cmdArgs.good ()) - os - << " <arg>\t\t\t\taccess to the factory (help <arg> for more detail)" - << std::endl; - else if (cmd2 == "list") - os << "list\t\t:List all available entities." << std::endl; - else if (cmd2 == "listEntities") - os <<"listEntities\t:List available entities." << std::endl; - } - else if (cmdLine == "list") - commandLine("listEntities",cmdArgs,os); - else if (cmdLine == "listEntities") - { - os <<" List of available entities:" << std::endl; - - typedef std::pair<std::string, EntityConstructor_ptr> iter_t; - BOOST_FOREACH (const iter_t& entity, entityMap) - os << " - " << entity.first << std::endl; - } - return; - } - - - - - - EntityRegisterer::EntityRegisterer (const std::string& entityClassName, FactoryStorage::EntityConstructor_ptr maker) : entityName (entityClassName) diff --git a/src/dgraph/pool.cpp b/src/dgraph/pool.cpp index 00bc4b0..8b4c94a 100644 --- a/src/dgraph/pool.cpp +++ b/src/dgraph/pool.cpp @@ -249,48 +249,6 @@ writeCompletionList(std::ostream& os) } - -void PoolStorage:: -commandLine( const std::string& objectName,const std::string& functionName, - std::istringstream& cmdArg, std::ostream& os ) -{ - dgDEBUG(15) << "Object <" << objectName<< "> function <" - <<functionName<<">"<<std::endl; - - if( objectName=="pool" ) - { - if( functionName=="help" ) - { - os <<"Pool: " << std::endl - <<" - list" << std::endl - << " - writegraph FileName" << std::endl; - } - else if( functionName=="list" ) - { - for( Entities::iterator iter=entityMap.begin (); - iter!=entityMap.end (); ++iter) - { - Entity* ent = iter->second; - os << ent->getName () - <<" (" << ent->getClassName () << ")" << std::endl; - } - - } - else if (functionName=="writegraph") - { - std::string aFileName; - cmdArg >> aFileName; - writeGraph(aFileName); - } - - } - else - { - Entity& ent = getEntity(objectName); - ent.commandLine(functionName,cmdArg,os); - } -} - static bool objectNameParser( std::istringstream& cmdparse, std::string& objName, diff --git a/src/plugins/shell-functions.cpp b/src/plugins/shell-functions.cpp deleted file mode 100644 index 49b1870..0000000 --- a/src/plugins/shell-functions.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, -// JRL, CNRS/AIST. -// -// This file is part of dynamic-graph. -// dynamic-graph is free software: you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// dynamic-graph is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Lesser Public License for more details. You should have -// received a copy of the GNU Lesser General Public License along with -// dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -#include <dynamic-graph/interpreter.h> -#include <dynamic-graph/functions.h> -#include <dynamic-graph/plugin-loader.h> -#include <dynamic-graph/factory.h> -#include <dynamic-graph/debug.h> -#include <dynamic-graph/entity.h> -#include <dynamic-graph/signal.h> -#include <dynamic-graph/exception-signal.h> - -#ifdef WIN32 -#include <Windows.h> -#endif - -#include <fstream> -using namespace std; -using namespace dynamicgraph; - -extern "C" { - ShellFunctionRegisterer regFun1 - ( "try",boost::bind(ShellFunctions::cmdTry,_1,_2,_3) ); - ShellFunctionRegisterer regFun2 - ( "loadPlugins",boost::bind(ShellFunctions::cmdLoadPlugins,_1,_2,_3) ); - ShellFunctionRegisterer regFun3 - ( "displayPlugins",boost::bind(ShellFunctions::cmdDisplayPlugins,_1,_2,_3) ); - ShellFunctionRegisterer regFun4 - ( "factory",boost::bind(ShellFunctions::cmdDisplayFactory,_1,_2,_3) ); - ShellFunctionRegisterer regFun5 - ( "#",boost::bind(ShellFunctions::cmdCommentary,_1,_2,_3) ); - ShellFunctionRegisterer regFun7 - ( "unplug",boost::bind(ShellFunctions::cmdUnplug,_1,_2,_3) ); - ShellFunctionRegisterer regFun8 - ( "clearPlugin",boost::bind(ShellFunctions::cmdClearPlugin,_1,_2,_3) ); - ShellFunctionRegisterer regFun9 - ( "signalTime",boost::bind(ShellFunctions::cmdSignalTime,_1,_2,_3) ); - ShellFunctionRegisterer regFun10 - ( "synchro",boost::bind(ShellFunctions::cmdSynchroSignal,_1,_2,_3) ); - ShellFunctionRegisterer regFun11 - ( "echo",boost::bind(ShellFunctions::cmdEcho,_1,_2,_3) ); - ShellFunctionRegisterer regFun12 - ( "copy",boost::bind(ShellFunctions::cmdCopy,_1,_2,_3) ); - ShellFunctionRegisterer regFun13 - ( "freeze",boost::bind(ShellFunctions::cmdFreeze,_1,_2,_3) ); - ShellFunctionRegisterer regFun13b - ( "squeeze",boost::bind(ShellFunctions::cmdSqueeze,_1,_2,_3) ); - ShellFunctionRegisterer regFun14 - ( "debugtrace",boost::bind(ShellFunctions::cmdEnableTrace,_1,_2,_3) ); - ShellFunctionRegisterer regFun15 - ( "prompt",boost::bind(ShellFunctions::cmdSetPrompt,_1,_2,_3) ); - ShellFunctionRegisterer regFun16 - ( "sleep",boost::bind(ShellFunctions::cmdSleep,_1,_2,_3) ); - ShellFunctionRegisterer regFun17 - ( "beep",boost::bind(ShellFunctions::cmdBeep,_1,_2,_3) ); - ShellFunctionRegisterer regFun19 - ( "completion",boost::bind(ShellFunctions::cmdCompletionList,_1,_2,_3) ); - -} - diff --git a/src/plugins/shell-procedure.cpp b/src/plugins/shell-procedure.cpp deleted file mode 100644 index 772583c..0000000 --- a/src/plugins/shell-procedure.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright 2010, - * François Bleibel, - * Olivier Stasse, - * - * CNRS/AIST - * - * This file is part of dynamic-graph. - * dynamic-graph is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * dynamic-graph is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. You should - * have received a copy of the GNU Lesser General Public License along - * with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <dynamic-graph/shell-procedure.h> -#include <dynamic-graph/plugin-loader.h> -#include <dynamic-graph/factory.h> -#include <dynamic-graph/debug.h> -#include <dynamic-graph/entity.h> - -#include <fstream> -using namespace std; -using namespace dynamicgraph; - -void ShellProcedure:: -cmdStartProcedure( const std::string& cmdLine,std::istringstream& args,std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os << " - proc <name>" - << "\t\t\t\tProcedure header." <<endl; - return; - } - - args>>procName; - dgDEBUG(5)<<"Proc <" <<procName<<">"<<endl; - - currentProc.clear (); - args >> ws; - while( args.good () ) - { - std::string next; - args>>next>>ws; - currentProc.params.push_back(next); - } -} - -void ShellProcedure:: -cmdContinueProcedure( const std::string& cmdLine,std::istringstream& args,std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os << " - -> cmd args..." - << "\t\t\t\tProcedure body." <<endl; - return; - } - - std::string cmd2; - args>>ws>>cmd2; - dgDEBUG(5)<<"Proc <" <<procName<<">: "<<cmd2<<endl; - - Instruction ins; ins.cmd=cmd2; - args >> ws; - while( args.good () ) - { - std::string next; - int param = -1; - args >> next >> ws; - for (unsigned int i = 0; i < currentProc.params.size (); ++i) - { - if (next == currentProc.params[i]) - { - param = (int) i; - break; - } - } - ins.args.push_back (next); - ins.params.push_back (param); - } - - currentProc.instructions.push_back( ins ); -} - -void ShellProcedure:: -cmdEndProcedure( const std::string& cmdLine,std::istringstream&, std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os << " - endproc..." - << "\t\t\t\tProcedure end." <<endl; - return; - } - - dgDEBUG(5)<<"Proc <" <<procName<<">: endproc"<<endl; - procedureList[ procName ] = currentProc; - currentProc.clear (); - - if( g_shell.deregisterFunction( procName )) - { os<< "Redefining proc <"<<procName<<">: procedure already defined. " - << "Overwrite it."<<endl; } - ShellFunctionRegisterer registration - ( procName.c_str (),boost::bind(&ShellProcedure::cmdProcedure, - this,procName,_1,_2,_3) ); - -} - -void ShellProcedure:: -cmdProcedure( const std::string& procname, - const std::string& cmdLine,std::istringstream& args,std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os<<" - "<<procname<<"\t\t\t\t\tUser-defined procedure"<<endl; - args >> ws; - if( args.good () ) - { - std::string argname; - const std::streamoff gc = args.tellg (); - args >> argname; - args.seekg(gc); args.clear (); - if( procname==argname ) - { - /* if cmdline = "Help <procname>", then display - * the proc instruction. */ - ProcedureList::iterator pair = procedureList.find( argname ); - if( pair==procedureList.end () ) - { - DG_THROW ExceptionFactory( ExceptionFactory::UNREFERED_FUNCTION, - "Undefined procedure", - ": procedure <%s> not defined.", - argname.c_str () ); - } - - Procedure & proc = pair->second; - unsigned int cmdnum=1; - for( std::list<Instruction>::iterator ins=proc.instructions.begin (); - ins!=proc.instructions.end (); ++ins ) - { - os<<"\t#" <<cmdnum++<<" "<<ins->cmd; // <<" "<<ins->args <<endl; - for( unsigned int i=0;i<ins->args.size ();++i ) - { os << " " << ins->args[i]; } - os << endl; - } - - } - } - return; - } - - - dgDEBUG(15) << " Calling procedure <" <<cmdLine<<"> " <<endl; - ProcedureList::iterator pair = procedureList.find( cmdLine ); - if( pair==procedureList.end () ) - { - DG_THROW ExceptionFactory( ExceptionFactory::UNREFERED_FUNCTION, - "Undefined procedure", - ": procedure <%s> not defined.",cmdLine.c_str () ); - } - - /* You need a copy here, in case the proc is removed from the - * list by itself: - * % proc next - * % -> proc next - * % -> -> echo TOTO - * % -> endproc - * % endproc - */ - Procedure proc = pair->second; - - std::vector< std::string > paramValue; - for( unsigned int i=0;i<proc.params.size ();++i ) - { - args>>ws; - if( args.good () ) - { - std::string next; args>>next>>ws; - paramValue.push_back( next ); - dgDEBUG(25) << "Args : <" << next << ">"<<endl; - } - else { paramValue.push_back(""); } - } - - istringstream iss; ostringstream oss; - for( std::list<Instruction>::iterator ins=proc.instructions.begin (); - ins!=proc.instructions.end (); ++ins ) - { - dgDEBUG(15) << "Proc <" << cmdLine << "> : " << ins->cmd << endl; - oss.clear (); oss.str(""); - for( unsigned int i=0;i<ins->params.size ();++i ) - { - int paramArg = ins->params[i]; - if( paramArg==-1 ) oss << ins->args[i] << " "; - else oss << paramValue[(size_t) paramArg] << " "; - } - - dgDEBUG(15) << " Args = " << oss.str () << endl; - iss.str(oss.str ()); iss.clear (); - g_shell.cmd(ins->cmd,iss,os); - } -} - -void ShellProcedure:: -cmdFor( const std::string& cmdLine,std::istringstream& args,std::ostream& os ) -{ - if( cmdLine == "help" ) - { - os << " - for 1 5 instruction "<<endl; - return; - } - - std::string cmd2,idx; - int istart,iend; - - { - stringstream oss; - - args >> cmd2; oss.str( cmd2 ); - const unsigned int SIZE = 32; char b1[SIZE],b2[SIZE],b3[SIZE]; - oss.getline( b1,SIZE,'=' ); - oss.getline( b2,SIZE,':' ); - oss.getline( b3,SIZE ); - dgDEBUG(15) << b1 << "/" << b2 << "/" << b3 << endl; - - idx = b1; istart = atoi(b2); iend = atoi(b3); - args >> cmd2; - - dgDEBUG(15) << "FOR <" << idx << "> = " << istart << " TO " << iend - << " DO " << cmd2 <<endl; - } - - string argsstr; - { - const unsigned int SIZE = 1024; char buffer[SIZE]; - args.getline( buffer,SIZE ); - argsstr = buffer; - } - for( int i=istart;i<=iend;++i ) - { - istringstream iss; stringstream oss; - - std::string insp; - istringstream issargs( argsstr ); - while( issargs.good () ) - { - issargs >> insp; - if( insp == idx ) { oss << i << " "; } else { oss<<insp<< " "; } - } - iss.str( oss.str () ); - g_shell.cmd(cmd2,iss,os); - } -} - -ShellProcedure sotShellProceduror; - -extern "C" { - ShellFunctionRegisterer regFun1 - ( "proc",boost::bind(&ShellProcedure::cmdStartProcedure, - &sotShellProceduror,_1,_2,_3) ); - - ShellFunctionRegisterer regFun2 - ( "->",boost::bind(&ShellProcedure::cmdContinueProcedure, - &sotShellProceduror,_1,_2,_3) ); - ShellFunctionRegisterer regFun3 - ( "endproc",boost::bind(&ShellProcedure::cmdEndProcedure, - &sotShellProceduror,_1,_2,_3) ); - - ShellFunctionRegisterer regFun4 - ( "for",boost::bind(&ShellProcedure::cmdFor, - _1,_2,_3) ); -} - diff --git a/src/traces/tracer-real-time.cpp b/src/traces/tracer-real-time.cpp index 3074b49..0142606 100644 --- a/src/traces/tracer-real-time.cpp +++ b/src/traces/tracer-real-time.cpp @@ -365,40 +365,3 @@ std::ostream& operator<< ( std::ostream& os,const TracerRealTime& t ) t.display(os); return os; } - - -void TracerRealTime:: -commandLine( const std::string& cmdLine - ,std::istringstream& cmdArgs - ,std::ostream& os ) -{ - if( cmdLine=="help" ) - { - os << "TracerRealTime: "<<endl - << " - empty: trash the buffers." <<endl - << " - bufferSize [<size>]: get/set the buffer size." <<endl; - - Tracer::commandLine( cmdLine,cmdArgs,os ); - } - else if( cmdLine=="empty" ) - { - emptyBuffers (); - } - else if( cmdLine=="bufferSize" ) - { - cmdArgs>>ws; - if( cmdArgs.good () ) - { - int s; cmdArgs>>s; - setBufferSize( s ); - } - else os << getBufferSize () << endl; - } - - - else - Tracer::commandLine( cmdLine,cmdArgs,os ); - - - -} diff --git a/src/traces/tracer.cpp b/src/traces/tracer.cpp index 3cc3b66..a041713 100644 --- a/src/traces/tracer.cpp +++ b/src/traces/tracer.cpp @@ -300,72 +300,3 @@ std::ostream& operator<< ( std::ostream& os,const Tracer& t ) t.display(os); return os; } - - -void Tracer:: -commandLine( const std::string& cmdLine - ,std::istringstream& cmdArgs - ,std::ostream& os ) -{ - if( cmdLine=="help" ) - { - os << "Tracer: "<<endl - << " - add <obj.signal> [<filename>=<signal>] "<<endl - << " - clear"<<endl - << " - open [<root> [<file> [<suffix>=.dat]]]"<<endl - << " - close "<<endl - << " - record "<<endl - << " - trace "<<endl - << " - start/stop" << endl; - // << " - parasite <obj.signal> "<<endl; - - Entity::commandLine( cmdLine,cmdArgs,os ); - } - else if( cmdLine=="add" ) - { - SignalBase<int> &sig = PoolStorage::getInstance()->getSignal(cmdArgs); - string r; cmdArgs>>ws>>r; - addSignalToTrace(sig,r); - dgDEBUG(14)<<"Add <" <<sig.getName ()<<"> with nick \""<<r<<"\""<<endl; - } - else if( cmdLine=="clear" ) - { closeFiles (); toTraceSignals.clear (); } - else if( cmdLine=="open" ) - { - string n,r="",s=".dat"; - cmdArgs>>ws>>r; - if( cmdArgs.good () ) - { - cmdArgs>>ws>>n; - if( cmdArgs.good () ) - { - cmdArgs>>ws>>s; - } - } - - dgDEBUGF( 15,"Close files."); - closeFiles (); - dgDEBUGF( 15,"Open files \"%s\" \"%s\" \"%s\".", - r.c_str (),n.c_str (),s.c_str ()); - openFiles(r,n,s); - } - else if( cmdLine=="close" ) { closeFiles (); } - else if( cmdLine=="trace" ) { trace (); } - else if( cmdLine=="record" ) - { - record (); - } - else if( cmdLine == "start" ) { play=true; } - else if( cmdLine == "stop" ) { play=false; } - else if( cmdLine == "timeStart" ) - { - cmdArgs >> std::ws; if(! cmdArgs.good () ) - { os << "timeStart = " << timeStart << std::endl; } - else { cmdArgs >> timeStart; } - } - else //sotTaskAbstract:: - Entity::commandLine( cmdLine,cmdArgs,os ); - - - -} diff --git a/tests/custom-entity.cpp b/tests/custom-entity.cpp index ffc8ea5..31b523a 100644 --- a/tests/custom-entity.cpp +++ b/tests/custom-entity.cpp @@ -49,20 +49,6 @@ struct CustomEntity : public dynamicgraph::Entity os << "custom entity"; } - virtual void commandLine (const std::string& cmdLine, - std::istringstream& cmdArgs, - std::ostream& os) - { - if (cmdLine == "help") - { - os << "This is a custom help." << std::endl; - Entity::commandLine (cmdLine, cmdArgs, os); - } - else if (cmdLine == "nothing") - ; - else - Entity::commandLine (cmdLine, cmdArgs, os); - } }; DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity"); diff --git a/tests/entity.cpp b/tests/entity.cpp index 19d398e..eb15d63 100644 --- a/tests/entity.cpp +++ b/tests/entity.cpp @@ -120,99 +120,6 @@ BOOST_AUTO_TEST_CASE (getCommandList) BOOST_CHECK_EQUAL (entity.getCommandList (), "print\nsignals\nsignalDep"); } -BOOST_AUTO_TEST_CASE (commandLine_help) -{ - dynamicgraph::Entity& entity = - dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity"); - - output_test_stream output; - - std::istringstream args; - - entity.commandLine("help", args, output); - BOOST_CHECK - (output.is_equal - ( - "Entity : \n" - " - print\t\t\tWhat d'you think?\n" - " - signals\t\t\tDisplay the signals list.\n" - " - signalDep <signame> \tDisplay the dependency graph for signal signame.\n" - )); -} - -BOOST_AUTO_TEST_CASE (commandLine_print) -{ - dynamicgraph::Entity& entity = - dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity"); - - output_test_stream output; - - std::istringstream args; - - entity.commandLine("print", args, output); - BOOST_CHECK (output.is_equal ("CustomEntity: my-entity\n")); -} - -BOOST_AUTO_TEST_CASE (commandLine_signals) -{ - dynamicgraph::Entity& entity = - dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity"); - - output_test_stream output; - - std::istringstream args; - - entity.commandLine("signals", args, output); - BOOST_CHECK (output.is_equal ("--- <my-entity> signal list: \n")); -} - -// FIXME: is it what we should expect? -BOOST_AUTO_TEST_CASE (commandLine_signalDep) -{ - dynamicgraph::Entity& entity = - dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity"); - - output_test_stream output; - - std::istringstream args; - - try - { - entity.commandLine("signalDep", args, output); - BOOST_ERROR ("Should never happen."); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::UNREFERED_SIGNAL); - } - - BOOST_CHECK (output.is_empty ()); -} - -BOOST_AUTO_TEST_CASE (commandLine_unknown) -{ - dynamicgraph::Entity& entity = - dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity"); - - output_test_stream output; - - std::istringstream args; - - try - { - entity.commandLine("unknown", args, output); - BOOST_ERROR ("Should never happen."); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::UNREFERED_FUNCTION); - } - - BOOST_CHECK (output.is_empty ()); -} - BOOST_AUTO_TEST_CASE (writeGraph) { dynamicgraph::Entity& entity = diff --git a/tests/interpreter-tracer.cpp b/tests/interpreter-tracer.cpp index c672b0a..d314fbe 100644 --- a/tests/interpreter-tracer.cpp +++ b/tests/interpreter-tracer.cpp @@ -31,7 +31,6 @@ using boost::test_tools::output_test_stream; BOOST_AUTO_TEST_CASE (cmd_tracer) { dynamicgraph::PluginLoader pl; - dynamicgraph::Interpreter shell (&pl); // Push paths. { diff --git a/tests/interpreter.cpp b/tests/interpreter.cpp deleted file mode 100644 index f05e1ec..0000000 --- a/tests/interpreter.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2010 Thomas Moulard. -// -// This file is part of dynamic-graph. -// dynamic-graph is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// dynamic-graph is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// You should have received a copy of the GNU Lesser General Public License -// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -#include <sstream> -#include <dynamic-graph/exception-factory.h> -#include <dynamic-graph/interpreter.h> -#include <dynamic-graph/plugin-loader.h> - -#define BOOST_TEST_MODULE interpreter - -#include <boost/test/unit_test.hpp> -#include <boost/test/output_test_stream.hpp> - -#include "interpreter.h" - -using boost::test_tools::output_test_stream; - -// This unit test checks the dynamic-graph interpreter -// and its related mechanisms. -// -// It may be split in several tests in the future if this -// becomes too big. - -// Simple test to check the shell default constructor. -BOOST_AUTO_TEST_CASE (constructor) -{ - dynamicgraph::Interpreter shell; -} - - -// Check that an empty command is valid. -BOOST_AUTO_TEST_CASE (cmd_empty) -{ - dynamicgraph::Interpreter shell; - RUN_COMMAND_NOARG (""); - BOOST_CHECK (output.is_empty ()); -} - - -// Check that a non existing command returns -// the appropriate error. -BOOST_AUTO_TEST_CASE (cmd_notexist) -{ - dynamicgraph::Interpreter shell; - try - { - RUN_COMMAND_NOARG ("I DO NOT EXIST"); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::UNREFERED_FUNCTION); - } -} - - -// Check that the "help" command works. -BOOST_AUTO_TEST_CASE (cmd_help) -{ - dynamicgraph::Interpreter shell; - - RUN_COMMAND_NOARG ("help"); - - BOOST_CHECK - (output.is_equal - ( - "Help\n" - " - compute <obj.sig> <time> Recompute <sig> at time <time> \n" - " - destroy <object> Destroy an object.\n" - " - get <obj.signal> <value> Get the signal to the constant value.\n" - " - import <script.txt> Import the script.\n" - " Behaves like run but searches for files in default script directories.\n" - " - loadPlugin <file.so> <directory> Load the plugin from the specified directory.\n" - " - new <class> <object> Create a new entity.\n" - " - plug <obj1.sig1> <obj2.sig2> Plug sig1 (producer) on sig2 (consumer).\n" - " - popImportPaths <path> Drop path from default directories.\n" - " - pushImportPaths <path> Add path to default directories.\n" - " - run <script.txt> Run the script.\n" - " - set <obj.signal> <value> Set the signal to the constant value.\n" - " - unloadPlugin <path/file.so> Unload the plugin.\n" - )); -} - - -// Check that an empty file can be parsed successfully. -BOOST_AUTO_TEST_CASE (cmd_run_emptyfile) -{ - dynamicgraph::Interpreter shell; - RUN_COMMAND ("run", TESTS_DATADIR "/empty.dg"); - BOOST_CHECK (output.is_empty ()); -} - -// Check that trying to run a non existing file returns an appropriate -// error. -BOOST_AUTO_TEST_CASE (cmd_run_notexist) -{ - dynamicgraph::Interpreter shell; - - try - { - RUN_COMMAND ("run", "idonotexist"); - BOOST_ERROR ("Should never happen"); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::READ_FILE); - } -} - -// Check that import a non existing file returns an appropriate error. -BOOST_AUTO_TEST_CASE (cmd_import_notexist) -{ - dynamicgraph::Interpreter shell; - try - { - RUN_COMMAND ("import", "idonotexist"); - BOOST_ERROR ("Should never happen"); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::READ_FILE); - } -} - -// Check that import/pushImportPaths/popImportPaths works. -BOOST_AUTO_TEST_CASE (cmd_import_push) -{ - dynamicgraph::Interpreter shell; - - // Push path. - { - RUN_COMMAND ("pushImportPaths", TESTS_DATADIR); - BOOST_CHECK (output.is_empty ()); - } - - // Import empty file. - { - RUN_COMMAND ("import", "empty.dg"); - BOOST_CHECK (output.is_empty ()); - } - - // Pop path. - { - RUN_COMMAND_NOARG ("popImportPaths"); - BOOST_CHECK (output.is_empty ()); - } - - // Import empty file again: this will fail - // as empty.dg is *NOT* in a standard location. - { - output_test_stream output; - std::stringstream ss; - ss << "empty.dg"; - std::istringstream args (ss.str ()); - - // Make sure this trigger an error. - BOOST_CHECK_THROW (shell.cmd ("import", args, output), - dynamicgraph::ExceptionFactory); - } - -} - -// Check that plug-in loading/unloading is working. -BOOST_AUTO_TEST_CASE (cmd_loadPlugin) -{ - dynamicgraph::PluginLoader pl; - dynamicgraph::Interpreter shell (&pl); - - { - RUN_COMMAND ("loadPlugin", "shell-functions" TESTS_DYNLIBSUFFIX " " TESTS_PLUGINDIR); - BOOST_CHECK (output.is_empty ()); - } - { - RUN_COMMAND ("loadPlugin", "shell-procedure" TESTS_DYNLIBSUFFIX " " TESTS_PLUGINDIR); - BOOST_CHECK (output.is_empty ()); - } - - { - RUN_COMMAND ("unloadPlugin", TESTS_PLUGINDIR "/shell-procedure" TESTS_DYNLIBSUFFIX); - BOOST_CHECK (output.is_empty ()); - } - - { - RUN_COMMAND ("unloadPlugin", TESTS_PLUGINDIR "/shell-functions" TESTS_DYNLIBSUFFIX); - BOOST_CHECK (output.is_empty ()); - } - - try - { - RUN_COMMAND ("loadPlugin", "idonotexist ."); - BOOST_ERROR ("Should never happen"); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::DYNAMIC_LOADING); - } - - try - { - RUN_COMMAND ("unloadPlugin", "idonotexist"); - BOOST_ERROR ("Should never happen"); - } - catch (const dynamicgraph::ExceptionFactory& exception) - { - BOOST_CHECK_EQUAL (exception.getCode (), - dynamicgraph::ExceptionFactory::OBJECT_CONFLICT); - } -} diff --git a/tests/interpreter.h b/tests/interpreter.h deleted file mode 100644 index cd15619..0000000 --- a/tests/interpreter.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2010 Thomas Moulard. -// -// This file is part of dynamic-graph. -// dynamic-graph is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// dynamic-graph is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// You should have received a copy of the GNU Lesser General Public License -// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -#ifndef DYNAMIC_GRAPH_TESTS_INTERPRETER_H -# define DYNAMIC_GRAPH_TESTS_INTERPRETER_H - -# define RUN_COMMAND(CMD, ARGS) \ - output_test_stream output; \ - std::stringstream ss; \ - std::string cmd = CMD; \ - ss << ARGS; \ - std::istringstream args (ss.str ()); \ - shell.cmd (cmd, args, output) - -# define RUN_COMMAND_NOARG(CMD) \ - output_test_stream output; \ - std::stringstream ss; \ - std::string cmd = CMD; \ - std::istringstream args (ss.str ()); \ - shell.cmd (cmd, args, output) - -#endif //! DYNAMIC_GRAPH_TESTS_INTERPRETER_H -- GitLab