diff --git a/include/dynamic-graph/#shell-procedure.h# b/include/dynamic-graph/#shell-procedure.h# new file mode 100644 index 0000000000000000000000000000000000000000..3f80f0109a1da2b456545a95623c4b99183830ca --- /dev/null +++ b/include/dynamic-graph/#shell-procedure.h# @@ -0,0 +1,97 @@ +// -*- mode: c++ -*- +// 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/>. + +#ifndef DYNAMIC_GRAPH_SHELL_PROCEDURE_H +# define DYNAMIC_GRAPH_SHELL_PROCEDURE_H +# incxlude <string> +# include <map> +# include <sstream> +# include <list> +# include <vector> + +# include <dynamic-graph/exception-factory.h> +# include <dynamic-graph/interpreter.h> +# include <dynamic-graph/config-shell-procedure.hh> + +/// \ingroup dgraph +/// +/// \brief This plugin exposes shell commands relative to the script +/// language constructs such as procedures and for loops. +/// +/// For more information, load the plugin and type help in a shell. +class DG_SHELLPROCEDURE_DLLAPI ShellProcedure +{ + public: + /// \brief Symbolizes a function call in the dynamic-graph language. + struct Instruction + { + /// \brief Command name. + std::string cmd; + /// \brief Arguments lists. + std::vector<std::string> args; + + std::vector<int> params; + }; + + /// \brief Symbolizes a procedure in the dynamic-graph language. + struct Procedure + { + /// \brief Store the procedure body. + std::list<Instruction> instructions; + /// \brief Store the procedure arguments. + std::vector<std::string> params; + + /// \brief Reset the procedure. + void clear () + { + instructions.clear (); + params.clear (); + } + }; + + /// \brief Map procedure name to their body. + typedef std::map<std::string, Procedure> ProcedureList; + + public: + std::string procName; + ProcedureList procedureList; + Procedure currentProc; + + public: + void cmdStartProcedure (const std::string& cmd, + std::istringstream& args, + std::ostream& os); + + void cmdContinueProcedure (const std::string& cmd, + std::istringstream& args, + std::ostream& os); + + void cmdEndProcedure (const std::string& cmd, + std::istringstream& args, + std::ostream& os); + + void cmdProcedure (const std::string& procname, + const std::string& cmd, + std::istringstream& args, + std::ostream& os); + + static void cmdFor (const std::string& cmd, + std::istringstream& args, + std::ostream& os); +}; + +#endif //! DYNAMIC_GRAPH_SHELL_PROCEDURE_H diff --git a/include/dynamic-graph/.#shell-procedure.h b/include/dynamic-graph/.#shell-procedure.h new file mode 120000 index 0000000000000000000000000000000000000000..0287ba36e7a1769d634cd17e7ab431d83a0b052d --- /dev/null +++ b/include/dynamic-graph/.#shell-procedure.h @@ -0,0 +1 @@ +thomas@cleo.16209:1293725997 \ No newline at end of file diff --git a/include/dynamic-graph/debug.h b/include/dynamic-graph/debug.h index e55a25087c1eeb6ef18b31caba844141145fdee3..cef0eed9edac5586a463ddb0a85271b940bb4cfe 100644 --- a/include/dynamic-graph/debug.h +++ b/include/dynamic-graph/debug.h @@ -46,67 +46,73 @@ namespace dynamicgraph { - class DYNAMIC_GRAPH_DLLAPI DebugTrace + /// \ingroup debug + /// + /// \brief Logging class. + /// + /// This class should never be used directly, please use the + /// debugging macro instead. + class DYNAMIC_GRAPH_DLLAPI DebugTrace + { + public: + static const int SIZE = 512; + + std::stringstream tmpbuffer; + std::ostream& outputbuffer; + char charbuffer[SIZE+1]; + int traceLevel; + int traceLevelTemplate; + + DebugTrace (std::ostream& os) + : outputbuffer (os) + {} + + inline void trace (const int level, const char* format, ...) { - public: - static const int SIZE = 512; - - std::stringstream tmpbuffer; - std::ostream& outputbuffer; - char charbuffer[SIZE+1]; - int traceLevel; - int traceLevelTemplate; - - DebugTrace (std::ostream& os) - : outputbuffer (os) - {} - - inline void trace (const int level, const char* format, ...) - { - if (level <= traceLevel) - DG_COMMON_TRACES; tmpbuffer.str(""); - } - - inline void trace (const char* format, ...) - { - DG_COMMON_TRACES; - tmpbuffer.str(""); - } - - inline void trace (const int level=-1) - { - if (level <= traceLevel) - outputbuffer << tmpbuffer.str (); tmpbuffer.str(""); - } - - inline void traceTemplate (const int level, const char* format, ...) - { - if (level <= traceLevelTemplate) - DG_COMMON_TRACES; - tmpbuffer.str(""); - } - - inline void traceTemplate (const char* format, ...) - { + if (level <= traceLevel) + DG_COMMON_TRACES; tmpbuffer.str(""); + } + + inline void trace (const char* format, ...) + { + DG_COMMON_TRACES; + tmpbuffer.str(""); + } + + inline void trace (const int level=-1) + { + if (level <= traceLevel) + outputbuffer << tmpbuffer.str (); tmpbuffer.str(""); + } + + inline void traceTemplate (const int level, const char* format, ...) + { + if (level <= traceLevelTemplate) DG_COMMON_TRACES; - tmpbuffer.str(""); - } - - inline DebugTrace& pre (const std::ostream&) - { - return *this; - } - - inline DebugTrace& pre (const std::ostream&, int level) - { - traceLevel = level; - return *this; - } - - static const char* DEBUG_FILENAME_DEFAULT; - static void openFile (const char* filename = DEBUG_FILENAME_DEFAULT); - static void closeFile( const char* filename = DEBUG_FILENAME_DEFAULT); - }; + tmpbuffer.str(""); + } + + inline void traceTemplate (const char* format, ...) + { + DG_COMMON_TRACES; + tmpbuffer.str(""); + } + + inline DebugTrace& pre (const std::ostream&) + { + return *this; + } + + inline DebugTrace& pre (const std::ostream&, int level) + { + traceLevel = level; + return *this; + } + + static const char* DEBUG_FILENAME_DEFAULT; + static void openFile (const char* filename = DEBUG_FILENAME_DEFAULT); + static void closeFile( const char* filename = DEBUG_FILENAME_DEFAULT); + }; DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgDEBUGFLOW; DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgERRORFLOW; diff --git a/include/dynamic-graph/entity.h b/include/dynamic-graph/entity.h index 5f8cfa5400469cf512d561a686c8de2e6b59779d..921bcad60b17795b92f75ec64b3925f75e0e399d 100644 --- a/include/dynamic-graph/entity.h +++ b/include/dynamic-graph/entity.h @@ -32,18 +32,18 @@ namespace dynamicgraph { - /*! \ingroup dgraph - \brief This class represents an entity, i.e. a generic - computational unit that provides input and output signals. - - 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 g_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 (). - */ + /// \ingroup dgraph + /// + /// \brief This class represents an entity, i.e. a generic + /// computational unit that provides input and output signals. + /// + /// 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 g_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 (). class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable { public: diff --git a/include/dynamic-graph/exception-abstract.h b/include/dynamic-graph/exception-abstract.h index 64036b4044ce7e811c6c04e71621710a74773890..155f6b8e073a43a190a2ddd16a15176e9714377b 100644 --- a/include/dynamic-graph/exception-abstract.h +++ b/include/dynamic-graph/exception-abstract.h @@ -44,9 +44,15 @@ namespace dynamicgraph { + /// \ingroup error + /// + /// \brief Abstract root class for all dynamic-graph exceptions. class DYNAMIC_GRAPH_DLLAPI ExceptionAbstract : public std::exception { public: + /// \ingroup error + /// + /// \brief Class owned by exceptions to store error locations. class Param { public: @@ -73,7 +79,13 @@ namespace dynamicgraph bool set; }; - + /// \brief Categories error code. + /// + /// Each value matches categories used by a subclass of + /// ExceptionAbstract. + /// + /// This is the programmer responsibility to make sure there is + /// enough room between two categories error code. enum ExceptionEnum { ABSTRACT = 0, @@ -94,16 +106,16 @@ namespace dynamicgraph return EXCEPTION_NAME; } - /** Access to the error code. */ + /// \brief Access to the error code. int getCode () const; - /** Reference access to the error message (can be empty). */ + /// \brief Reference access to the error message (can be empty). const std::string& getStringMessage () const; - /** Access to the pointer on the array of \e char related to the - * error string. - * Cannot be \e NULL. - */ + /// \brief Access to the pointer on the array of \e char related + /// to the error string. + /// + /// Cannot be \e NULL. const char* getMessage () const; virtual const char* what () const throw () @@ -111,20 +123,24 @@ namespace dynamicgraph return getStringMessage ().c_str (); } - /** Print the error structure. */ - DYNAMIC_GRAPH_DLLAPI friend std::ostream & + /// \brief Print the error structure. + DYNAMIC_GRAPH_DLLAPI friend std::ostream& operator << (std::ostream & os, const ExceptionAbstract & err); protected: - /** Error code. - * \sa ErrorCodeEnum */ + /// \brief Error code. + /// \sa ErrorCodeEnum int code; - /** Error message (can be empty). */ + /// \brief Error message (can be empty). std::string message; # ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM + /// \brief Optional mutable attribute to store exception location. + /// + /// Only present if DYNAMICGRAPH_EXCEPTION_PASSING_PARAM + /// preprocessor symbol exists. mutable Param p; template<class Exc> @@ -146,7 +162,7 @@ namespace dynamicgraph # endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM private: - /// forbid the empty constructor (private). + /// \brief Forbid the empty constructor (private). ExceptionAbstract (); }; } // end of namespace dynamicgraph diff --git a/include/dynamic-graph/exception-factory.h b/include/dynamic-graph/exception-factory.h index 55e53e1a9287036d4789f0ef169cea0047895e15..214c8e28d375e0b9261e08958f6473e2c1bb7da6 100644 --- a/include/dynamic-graph/exception-factory.h +++ b/include/dynamic-graph/exception-factory.h @@ -25,7 +25,10 @@ namespace dynamicgraph { - class DYNAMIC_GRAPH_DLLAPI ExceptionFactory :public ExceptionAbstract + /// \ingroup error + /// + /// \brief Generic error class. + class DYNAMIC_GRAPH_DLLAPI ExceptionFactory : public ExceptionAbstract { public: enum ErrorCodeEnum @@ -46,10 +49,10 @@ namespace dynamicgraph explicit ExceptionFactory (const ExceptionFactory::ErrorCodeEnum& errcode, const std::string & msg = ""); - + ExceptionFactory (const ExceptionFactory::ErrorCodeEnum& errcode, const std::string& msg, const char* format, ...); - + virtual ~ExceptionFactory () throw () {} diff --git a/include/dynamic-graph/exception-signal.h b/include/dynamic-graph/exception-signal.h index 5d25fd21c80f02f9894d240e85b238e7ad81b95e..fcf379cc30db4ce1ac9c785a5753cfe4110ec76e 100644 --- a/include/dynamic-graph/exception-signal.h +++ b/include/dynamic-graph/exception-signal.h @@ -24,6 +24,10 @@ namespace dynamicgraph { + /// \ingroup error + /// + /// \brief Exceptions raised when an error related to signals + /// happen. class DYNAMIC_GRAPH_DLLAPI ExceptionSignal : public ExceptionAbstract { public: diff --git a/include/dynamic-graph/exception-traces.h b/include/dynamic-graph/exception-traces.h index 463447eb0a56275af67c2d898bcc2ea0859be64a..81ab6767857bba9012e1670849fd7b40cba99c12 100644 --- a/include/dynamic-graph/exception-traces.h +++ b/include/dynamic-graph/exception-traces.h @@ -25,6 +25,9 @@ namespace dynamicgraph { + /// \ingroup error + /// + /// \brief Exceptions raised when an error related to traces happen. class DYNAMIC_GRAPH_DLLAPI ExceptionTraces : public ExceptionAbstract { public: diff --git a/include/dynamic-graph/factory.h b/include/dynamic-graph/factory.h index c62a1fc655ddf7032e61e98050fc25b0701dd5fa..b51b11b055b95a2f0eb351cd70657400be0172be 100644 --- a/include/dynamic-graph/factory.h +++ b/include/dynamic-graph/factory.h @@ -27,7 +27,8 @@ # include <dynamic-graph/exception-factory.h> # include <dynamic-graph/dynamic-graph-api.h> - +/// \ingroup dgraph +/// /// \brief Automatically register a class to the global factory /// by relying on the static initialization. /// @@ -192,6 +193,8 @@ namespace dynamicgraph EntityMap entityMap; }; + /// \ingroup dgraph + /// /// \brief Global factory. /// /// This global variable is the only valid instance of the @@ -208,6 +211,8 @@ namespace dynamicgraph DYNAMIC_GRAPH_DLLAPI extern FactoryStorage g_factory; + /// \ingroup dgraph + /// /// \brief This class automatically register an Entity to the /// global factory at initialization and unregister it during /// instance destruction. diff --git a/include/dynamic-graph/shell-procedure.h b/include/dynamic-graph/shell-procedure.h index 6a3af44ddbcc7fd6ddfc76d02199dadd9a42c06c..8b865087ac318a3f4a0c855946ea1fa97b1f7049 100644 --- a/include/dynamic-graph/shell-procedure.h +++ b/include/dynamic-graph/shell-procedure.h @@ -27,27 +27,35 @@ # include <dynamic-graph/interpreter.h> # include <dynamic-graph/config-shell-procedure.hh> -/*! @ingroup dgraph - \brief This plugin exposes shell commands relative to the script language - constructs such as procedures and for loops. - - For more information, load the plugin and type help on a sot shell. -*/ +/// \ingroup dgraph +/// +/// \brief This plugin exposes shell commands relative to the script +/// language constructs such as procedures and for loops. +/// +/// For more information, load the plugin and type help in a shell. class DG_SHELLPROCEDURE_DLLAPI ShellProcedure { public: + /// \brief Symbolizes a function call in the dynamic-graph language. struct Instruction { + /// \brief Command name. std::string cmd; + /// \brief Arguments lists. std::vector<std::string> args; + std::vector<int> params; }; + /// \brief Symbolizes a procedure in the dynamic-graph language. struct Procedure { + /// \brief Store the procedure body. std::list<Instruction> instructions; + /// \brief Store the procedure arguments. std::vector<std::string> params; + /// \brief Reset the procedure. void clear () { instructions.clear (); @@ -55,12 +63,12 @@ class DG_SHELLPROCEDURE_DLLAPI ShellProcedure } }; + /// \brief Map procedure name to their body. typedef std::map<std::string, Procedure> ProcedureList; public: std::string procName; ProcedureList procedureList; - Procedure currentProc; public: diff --git a/include/dynamic-graph/signal-array.h b/include/dynamic-graph/signal-array.h index 19fad5a80fdc65fe77e288d03c62ee123dfc980c..fe12d09a3657f699f12fb35d5d27de0067d86c4a 100644 --- a/include/dynamic-graph/signal-array.h +++ b/include/dynamic-graph/signal-array.h @@ -22,6 +22,9 @@ namespace dynamicgraph { + /// \ingroup dgraph + /// + /// \brief TODO template<class Time> class SignalArray_const { @@ -118,7 +121,9 @@ namespace dynamicgraph return res; } - + /// \ingroup dgraph + /// + /// \brief TODO template<class Time> class SignalArray : public SignalArray_const<Time> { diff --git a/include/dynamic-graph/signal-ptr.h b/include/dynamic-graph/signal-ptr.h index 6d1ad06d48747a3b88b93ef7fba66313403c9809..f048f8e8ec03ebedd404ae2f7071d222a6275998 100644 --- a/include/dynamic-graph/signal-ptr.h +++ b/include/dynamic-graph/signal-ptr.h @@ -24,14 +24,14 @@ namespace dynamicgraph { - - /** \brief This is the only type of signal that can be plugged to, - using the plug () command. - - In that sense, when plugged into, it acts as a "pointer" to the - input signal, hence the name. Operator -> is also overloaded and - can be used to access the pointed signal. - */ + /// \ingroup dgraph + /// + /// \brief This is the only type of signal that can be plugged to, + /// using the plug () command. + /// + /// In that sense, when plugged into, it acts as a "pointer" to the + /// input signal, hence the name. Operator -> is also overloaded and + /// can be used to access the pointed signal. template<class T, class Time> class SignalPtr : public virtual Signal<T,Time> { diff --git a/include/dynamic-graph/tracer-real-time.h b/include/dynamic-graph/tracer-real-time.h index 64f553f7cb60446db4a7da63cc9fe70aeaea126a..2a4939ba4bd6be9e421800147cfa9e70c0f00b9b 100644 --- a/include/dynamic-graph/tracer-real-time.h +++ b/include/dynamic-graph/tracer-real-time.h @@ -25,6 +25,9 @@ namespace dynamicgraph { + /// \ingroup plugin + /// + /// \brief Stream for the tracer real-time. class DG_TRACERREALTIME_DLLAPI OutStringStream : public std::ostringstream { public: @@ -44,6 +47,9 @@ namespace dynamicgraph void empty (); }; + /// \ingroup plugin + /// + /// \brief Main class of the tracer real-time plug-in. class DG_TRACERREALTIME_DLLAPI TracerRealTime : public Tracer { public: @@ -53,20 +59,21 @@ namespace dynamicgraph return CLASS_NAME; } - protected: - int bufferSize; - static const int BUFFER_SIZE_DEFAULT = 1048576; // 1Mo - typedef std::list<std::ofstream*> HardFileList; - HardFileList hardFiles; - - public: TracerRealTime (const std::string n); virtual ~TracerRealTime () {} - public: virtual void closeFiles (); virtual void trace (); + + void display (std::ostream& os) const; + 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); @@ -75,7 +82,6 @@ namespace dynamicgraph const SignalBase<int>& sig); void emptyBuffers (); - public: void setBufferSize (const int& SIZE) { bufferSize=SIZE; @@ -86,16 +92,11 @@ namespace dynamicgraph return bufferSize; } - public: - /* --- DISPLAY ---------------------------------------------------------- */ - void display (std::ostream& os) const; - DG_TRACERREALTIME_DLLAPI friend std::ostream& operator<< - (std::ostream& os, const TracerRealTime& t); + typedef std::list<std::ofstream*> HardFileList; + static const int BUFFER_SIZE_DEFAULT = 1048576; // 1Mo - /* --- PARAMS --- */ - virtual void commandLine (const std::string& cmdLine - ,std::istringstream& cmdArgs - ,std::ostream& os); + int bufferSize; + HardFileList hardFiles; }; } // end of namespace dynamicgraph diff --git a/include/dynamic-graph/tracer.h b/include/dynamic-graph/tracer.h index 24044ddf2ce1523c5242527cfceecf8e2c1343eb..c335820a7fb94778355a2dd47c0ab40a6dc5fcad 100644 --- a/include/dynamic-graph/tracer.h +++ b/include/dynamic-graph/tracer.h @@ -31,6 +31,9 @@ namespace dynamicgraph { + /// \ingroup plugin + /// + /// \brief Tracer plug-in main class. class DG_TRACER_DLLAPI Tracer : public Entity { protected: diff --git a/src/plugins/shell-procedure.cpp b/src/plugins/shell-procedure.cpp index 38f00a1142f0e0816b087734bed3562b319d341e..772583ca3bcaed81ccdc82de48b444a888711c20 100644 --- a/src/plugins/shell-procedure.cpp +++ b/src/plugins/shell-procedure.cpp @@ -99,15 +99,6 @@ cmdEndProcedure( const std::string& cmdLine,std::istringstream&, std::ostream& o dgDEBUG(5)<<"Proc <" <<procName<<">: endproc"<<endl; procedureList[ procName ] = currentProc; - -// std::string toto="toto"; -// for( Procedure::iterator ins=procedureList[ toto ].begin (); -// ins!=procedureList[ toto ].end (); ++ins ) -// { -// dgDEBUG(15) << "Proc <" << procName << "> : " -// << ins->cmd << " -> " << ins->args <<endl; -// } - currentProc.clear (); if( g_shell.deregisterFunction( procName ))