Skip to content
Snippets Groups Projects
Commit 0645c5ed authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Fix warnings.

parent b1dc1872
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ class SOT_CORE_EXPORT Contiifstream
{
protected:
std::string filename;
unsigned int cursor;
std::streamoff cursor;
static const unsigned int BUFFER_SIZE = 256;
char buffer[BUFFER_SIZE];
std::list< std::string > reader;
......
......@@ -18,43 +18,37 @@
* with sot-core. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VS_DEBUG_HH
#define __VS_DEBUG_HH
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdarg.h>
#include <sot-core/sot-core-api.h>
namespace sot {
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#ifndef VP_DEBUG_MODE
#define VP_DEBUG_MODE 0
#endif
#ifndef VP_TEMPLATE_DEBUG_MODE
#define VP_TEMPLATE_DEBUG_MODE 0
#endif
#define SOT_COMMON_TRACES do { \
va_list arg; \
va_start(arg,format); \
vsnprintf( charbuffer,SIZE,format,arg ); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer <<std::endl; \
} while(0)
class SOT_CORE_EXPORT DebugTrace
#ifndef SOT_CORE_DEBUG_HH
# define SOT_CORE_DEBUG_HH
# include <cstdio>
# include <cstdarg>
# include <iostream>
# include <fstream>
# include <sstream>
# include <sot-core/sot-core-api.h>
# ifndef VP_DEBUG_MODE
# define VP_DEBUG_MODE 0
# endif //! VP_DEBUG_MODE
# ifndef VP_TEMPLATE_DEBUG_MODE
# define VP_TEMPLATE_DEBUG_MODE 0
# endif //! VP_TEMPLATE_DEBUG_MODE
# define SOT_COMMON_TRACES \
do { \
va_list arg; \
va_start(arg,format); \
vsnprintf( charbuffer,SIZE,format,arg ); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer <<std::endl; \
} while(0)
namespace sot
{
public:
class SOT_CORE_EXPORT DebugTrace
{
public:
static const int SIZE = 512;
std::stringstream tmpbuffer;
......@@ -65,88 +59,167 @@ class SOT_CORE_EXPORT DebugTrace
DebugTrace( std::ostream& os ): outputbuffer(os) {}
inline void trace( const int level,const char* format,...)
{ if( level<=traceLevel ) SOT_COMMON_TRACES; tmpbuffer.str(""); }
inline void trace( const char* format,...){ SOT_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 ) SOT_COMMON_TRACES; tmpbuffer.str(""); }
inline void traceTemplate( const char* format,...)
{ SOT_COMMON_TRACES; tmpbuffer.str(""); }
inline DebugTrace& pre( const std::ostream& dummy ) { return *this; }
inline DebugTrace& pre( const std::ostream& dummy,int level )
{ traceLevel = level; return *this; }
/* inline DebugTrace& preTemplate( const std::ostream& dummy,int level ) */
/* { traceLevelTemplate = 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 );
};
SOT_CORE_EXPORT extern DebugTrace sotDEBUGFLOW;
SOT_CORE_EXPORT extern DebugTrace sotERRORFLOW;
#ifdef VP_DEBUG
#define sotPREDEBUG __FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
#define sotPREERROR "\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define sotDEBUG(level) if( (level>VP_DEBUG_MODE)||(!sot::sotDEBUGFLOW.outputbuffer.good()) ) ;\
else sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
# define sotDEBUGMUTE(level) if( (level>VP_DEBUG_MODE)||(!sot::sotDEBUGFLOW.outputbuffer.good()) ) ;\
else sot::sotDEBUGFLOW.outputbuffer
# define sotERROR if(!sot::sotDEBUGFLOW.outputbuffer.good()); else sot::sotERRORFLOW.outputbuffer << sotPREERROR
# define sotDEBUGF if(!sot::sotDEBUGFLOW.outputbuffer.good()); else sot::sotDEBUGFLOW.pre(sot::sotDEBUGFLOW.tmpbuffer<<sotPREDEBUG,VP_DEBUG_MODE).trace
# define sotERRORF if(!sot::sotDEBUGFLOW.outputbuffer.good()); else sot::sotERRORFLOW.pre(sot::sotERRORFLOW.tmpbuffer<<sotPREERROR).trace
// TEMPLATE
# define sotTDEBUG(level) if( (level>VP_TEMPLATE_DEBUG_MODE)||(!sot::sotDEBUGFLOW.outputbuffer.good()) ) ;\
else sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
# define sotTDEBUGF if(!sot::sotDEBUGFLOW.outputbuffer.good()); else sot::sotDEBUGFLOW.pre(sot::sotDEBUGFLOW.tmpbuffer<<sotPREDEBUG,VP_TEMPLATE_DEBUG_MODE).trace
inline bool sotDEBUG_ENABLE( const int & level ) { return level<=VP_DEBUG_MODE; }
inline bool sotTDEBUG_ENABLE( const int & level ) { return level<=VP_TEMPLATE_DEBUG_MODE; }
inline void trace(const int level,const char* format, ...)
{
if (level<=traceLevel)
SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline void trace(const char* format,...)
{
SOT_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)
SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline void traceTemplate(const char* format, ...)
{
SOT_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);
};
SOT_CORE_EXPORT extern DebugTrace sotDEBUGFLOW;
SOT_CORE_EXPORT extern DebugTrace sotERRORFLOW;
} // namespace sot
# ifdef VP_DEBUG
# define sotPREDEBUG \
__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define sotPREERROR \
"\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define sotDEBUG(level) \
if ((level>VP_DEBUG_MODE) || (!sot::sotDEBUGFLOW.outputbuffer.good()) ) \
; \
else \
sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
# define sotDEBUGMUTE(level) \
if( (level>VP_DEBUG_MODE)||(!sot::sotDEBUGFLOW.outputbuffer.good()) ) \
; \
else \
sot::sotDEBUGFLOW.outputbuffer
# define sotERROR \
if(!sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else sot::sotERRORFLOW.outputbuffer << sotPREERROR
# define sotDEBUGF \
if(!sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
sot::sotDEBUGFLOW.pre \
(sot::sotDEBUGFLOW.tmpbuffer<<sotPREDEBUG,VP_DEBUG_MODE).trace
# define sotERRORF\
if(!sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
sot::sotERRORFLOW.pre(sot::sotERRORFLOW.tmpbuffer<<sotPREERROR).trace
// TEMPLATE
# define sotTDEBUG(level) \
if((level>VP_TEMPLATE_DEBUG_MODE)||(!sot::sotDEBUGFLOW.outputbuffer.good())) \
; \
else \
sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
# define sotTDEBUGF \
if(!sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
sot::sotDEBUGFLOW.pre \
(sot::sotDEBUGFLOW.tmpbuffer<<sotPREDEBUG,VP_TEMPLATE_DEBUG_MODE).trace
namespace sot
{
inline bool sotDEBUG_ENABLE(const int & level)
{
return level <= VP_DEBUG_MODE;
}
inline bool sotTDEBUG_ENABLE(const int & level)
{
return level<=VP_TEMPLATE_DEBUG_MODE;
}
} // namespace sot
/* -------------------------------------------------------------------------- */
#else // #ifdef VP_DEBUG
#define sotPREERROR "\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# else // VP_DEBUG
# define sotPREERROR \
"\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define sotDEBUG(level) if( 1 ) ; else std::cout
# define sotDEBUGMUTE(level) if( 1 ) ; else std::cout
# define sotERROR sotERRORFLOW.outputbuffer << sotPREERROR
inline void sotDEBUGF( const int level,const char* format,...) { return; }
inline void sotDEBUGF( const char* format,...) { return; }
inline void sotERRORF( const int level,const char* format,...) { return; }
inline void sotERRORF( const char* format,...) { return; }
// TEMPLATE
# define sotTDEBUG(level) if( 1 ) ; else std::cout
inline void sotTDEBUGF( const int level,const char* format,...) { return; }
inline void sotTDEBUGF( const char* format,...) { return; }
#define sotDEBUG_ENABLE(level) false
#define sotTDEBUG_ENABLE(level) false
#endif // #ifdef VP_DEBUG
/* -------------------------------------------------------------------------- */
namespace sot
{
inline void sotDEBUGF(const int,const char*,...) {}
#define sotDEBUGIN(level) sotDEBUG(level) << "# In {" << std::endl
#define sotDEBUGOUT(level) sotDEBUG(level) << "# Out }" << std::endl
#define sotDEBUGINOUT(level) sotDEBUG(level) << "# In/Out { }" << std::endl
inline void sotDEBUGF(const char*,...) {}
inline void sotERRORF(const int, const char*,...) {}
inline void sotERRORF(const char*,...) {}
} // namespace sot
#define sotTDEBUGIN(level) sotTDEBUG(level) << "# In {" << std::endl
#define sotTDEBUGOUT(level) sotTDEBUG(level) << "# Out }" << std::endl
#define sotTDEBUGINOUT(level) sotTDEBUG(level) << "# In/Out { }" << std::endl
// TEMPLATE
# define sotTDEBUG(level) if( 1 ) ; else std::cout
namespace sot
{
inline void sotTDEBUGF(const int, const char*,...) {}
inline void sotTDEBUGF(const char*,...) {}
} // namespace sot
#endif /* #ifdef __VS_DEBUG_HH */
# define sotDEBUG_ENABLE(level) false
# define sotTDEBUG_ENABLE(level) false
/*
* Local variables:
* c-basic-offset: 4
* End:
*/
# endif // VP_DEBUG
# define sotDEBUGIN(level) sotDEBUG(level) << "# In {" << std::endl
# define sotDEBUGOUT(level) sotDEBUG(level) << "# Out }" << std::endl
# define sotDEBUGINOUT(level) sotDEBUG(level) << "# In/Out { }" << std::endl
# define sotTDEBUGIN(level) sotTDEBUG(level) << "# In {" << std::endl
# define sotTDEBUGOUT(level) sotTDEBUG(level) << "# Out }" << std::endl
# define sotTDEBUGINOUT(level) sotTDEBUG(level) << "# In/Out { }" << std::endl
#endif //! #ifdef SOT_CORE_DEBUG_HH
// Local variables:
// c-basic-offset: 4
// End:
......@@ -123,7 +123,6 @@ class SOT_CORE_EXPORT FeatureAbstract
/*! \brief Compute the Jacobian of the error according the robot state.
\par[out] res: The matrix in which the error will be written.
\par[in] time: The time at which the Jacobian is computed \f$ {\bf J}(q(t)) \f$.
\return The matrix res with the appropriate values.
*/
virtual ml::Matrix& computeJacobian( ml::Matrix& res,int time ) = 0;
......@@ -133,7 +132,6 @@ class SOT_CORE_EXPORT FeatureAbstract
or deduced from the estimated state of the robot at the time specified.
\par[out] res: The vector in which the value will be written.
\par[in] time: The time at which the feature is evaluated \f$ {\bf s}(t)) \f$.
\return The vector res with the appropriate values.
*/
virtual ml::Vector& computeActivation( ml::Vector& res,int time ) = 0;
......
......@@ -85,18 +85,18 @@ private:
*/
#define SOT_SIGNAL_CAST_DECLARATION(TYPE) \
dynamicgraph::SignalCastRegisterer sotCastRegisterer_##TYPE \
(typeid(TYPE), \
SignalCast<TYPE>::disp_, \
SignalCast<TYPE>::cast_, \
SignalCast<TYPE>::trace_);
#define SOT_SIGNAL_CAST_DECLARATION_NAMED(TYPE,NAME) \
dynamicgraph::SignalCastRegisterer sotCastRegisterer_##NAME \
(typeid(TYPE), \
SignalCast<TYPE>::disp_, \
SignalCast<TYPE>::cast_, \
SignalCast<TYPE>::trace_);
dynamicgraph::SignalCastRegisterer sotCastRegisterer_##TYPE \
(typeid(TYPE), \
SignalCast<TYPE>::disp_, \
SignalCast<TYPE>::cast_, \
SignalCast<TYPE>::trace_)
#define SOT_SIGNAL_CAST_DECLARATION_NAMED(TYPE,NAME) \
dynamicgraph::SignalCastRegisterer sotCastRegisterer_##NAME \
(typeid(TYPE), \
SignalCast<TYPE>::disp_, \
SignalCast<TYPE>::cast_, \
SignalCast<TYPE>::trace_)
/* Standard definition macros: the three functions can be specified
* in the macros. To define then in the cpp, just put ';' in the args.
......
......@@ -27,48 +27,52 @@ using namespace sot;
namespace sot {
#ifdef WIN32
const char * DebugTrace::DEBUG_FILENAME_DEFAULT = "c:/tmp/sot-core-traces.txt";
#else /*WIN32*/
#else // WIN32
const char * DebugTrace::DEBUG_FILENAME_DEFAULT = "/tmp/sot-core-traces.txt";
#endif /*WIN32*/
#endif // WIN32
#ifdef VP_DEBUG
#ifdef WIN32
std::ofstream debugfile( "C:/tmp/sot-core-traces.txt", std::ios::trunc&std::ios::out );
#else /*WIN32*/
std::ofstream debugfile( "/tmp/sot-core-traces.txt", std::ios::trunc&std::ios::out );
#endif /*WIN32*/
# ifdef WIN32
std::ofstream debugfile("C:/tmp/sot-core-traces.txt",
std::ios::trunc&std::ios::out);
# else // WIN32
std::ofstream debugfile("/tmp/sot-core-traces.txt",
std::ios::trunc&std::ios::out);
# endif // WIN32
#else // VP_DEBUG
#else
std::ofstream debugfile;
std::ofstream debugfile; //( "/dev/null", std::ios::trunc&std::ios::out );
class __sotDebug_init
{
public:
__sotDebug_init()
{
debugfile.setstate (std::ios::failbit);
}
};
__sotDebug_init __sotDebug_initialisator;
class __sotDebug_init
{
public:
__sotDebug_init( void ) {
debugfile.setstate( std::ios::failbit ) ; /* debugfile.close(); */ }
};
__sotDebug_init __sotDebug_initialisator;
#endif
#endif // VP_DEBUG
} // namespace sot
void DebugTrace::openFile( const char * filename )
void DebugTrace::openFile(const char * filename)
{
if( debugfile.good()&&debugfile.is_open() ) debugfile.close();
debugfile.clear();
debugfile.open( filename, std::ios::trunc&std::ios::out );
//std::cout << filename << debugfile.good() << debugfile.is_open() << std::endl;
if (debugfile.good () && debugfile.is_open ())
debugfile.close ();
debugfile.clear ();
debugfile.open (filename, std::ios::trunc&std::ios::out);
}
void DebugTrace::closeFile( const char * filename )
void DebugTrace::closeFile(const char *)
{
if( debugfile.good()&&debugfile.is_open() ) { debugfile.close(); }
debugfile.setstate( std::ios::failbit ) ;
if (debugfile.good () && debugfile.is_open ())
debugfile.close();
debugfile.setstate (std::ios::failbit);
}
namespace sot {
DebugTrace sotDEBUGFLOW(debugfile);
DebugTrace sotERRORFLOW(debugfile);
}
DebugTrace sotDEBUGFLOW(debugfile);
DebugTrace sotERRORFLOW(debugfile);
} // end of namespace sot.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment