Skip to content
Snippets Groups Projects
Commit f77eb014 authored by Francois Bleibel's avatar Francois Bleibel
Browse files

Settled down the case of mailbox.

parent ff07359b
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Generate header with default script directory. # Generate header with default script directory.
SET(SOT_IMPORT_DEFAULT_PATHS \"${CMAKE_INSTALL_PREFIX}/script\") SET(SOT_IMPORT_DEFAULT_PATHS \"${CMAKE_INSTALL_PREFIX}/script\")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sot-core/import-default-paths.h.cmake CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sot-core/import-default-paths.h.cmake
${CMAKE_CURRENT_SOURCE_DIR}/sot-core/import-default-paths.h) ${${PROJECT_NAME}_BINARY_DIR}/include/sot/import-default-paths.h)
SET(${PROJECT_NAME}_HEADERS SET(${PROJECT_NAME}_HEADERS
sot-core-api.h sot-core-api.h
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <MatrixAbstractLayer/boost.h> #include <MatrixAbstractLayer/boost.h>
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */ /* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
...@@ -50,11 +49,7 @@ ...@@ -50,11 +49,7 @@
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
namespace sot { namespace sot {
class MAILBOX_VECTOR_EXPORT MailboxVector : public Mailbox<maal::boost::Vector> typedef Mailbox<maal::boost::Vector> MailboxVector;
{
public:
MailboxVector( const std::string& name );
};
} }
#endif // #ifdef HAVE_LIBBOOST_THREAD #endif // #ifdef HAVE_LIBBOOST_THREAD
......
...@@ -37,7 +37,37 @@ namespace sot { ...@@ -37,7 +37,37 @@ namespace sot {
//#include <sot-core/debug.h> //#include <sot-core/debug.h>
namespace dg = dynamicgraph; namespace dg = dynamicgraph;
typedef Mailbox<maal::boost::Vector> mailvect;
/*
: public dg::Entity
{
public:
static const std::string CLASS_NAME;
public:
struct sotTimestampedObject
{
maal::boost::Vector obj;
struct timeval timestamp;
};
virtual const std::string& getClassName( void );
Mailbox( const std::string& name );
~Mailbox( void );
void post( const maal::boost::Vector& obj );
sotTimestampedObject& get( sotTimestampedObject& res,const int& dummy );
maal::boost::Vector& getObject( maal::boost::Vector& res,const int& time );
struct timeval& getTimestamp( struct timeval& res,const int& time );
bool hasBeenUpdated( void );
};
*/
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* --- CONSTRUCTION --------------------------------------------------------- */ /* --- CONSTRUCTION --------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
...@@ -141,8 +171,19 @@ getTimestamp( struct timeval& res,const int& time ) ...@@ -141,8 +171,19 @@ getTimestamp( struct timeval& res,const int& time )
return res; return res;
} }
/* Macro for template specialization */
#define MAILBOX_TEMPLATE_SPE(S) \
namespace sot { \
template void Mailbox<S>::post(const S& obj ); \
template maal::boost::Vector& Mailbox<S>::getObject( S& res,const int& time ); \
template bool Mailbox<S>::hasBeenUpdated(void); \
template Mailbox<S>::~Mailbox(); \
template Mailbox<S>::sotTimestampedObject& Mailbox<S>::get( Mailbox<S>::sotTimestampedObject& res,const int& dummy ); \
template Mailbox<S>::Mailbox(const std::string& name); \
} }
} // namespace sot
#endif // #ifdef HAVE_LIBBOOST_THREAD #endif // #ifdef HAVE_LIBBOOST_THREAD
#endif // #ifdef __SOT_MAILBOX_T_CPP #endif // #ifdef __SOT_MAILBOX_T_CPP
...@@ -28,10 +28,11 @@ ...@@ -28,10 +28,11 @@
using namespace sot; using namespace sot;
using namespace dynamicgraph; using namespace dynamicgraph;
typedef Mailbox<maal::boost::Vector> mailvect;
template<>DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(mailvect,"Mailbox<Vector>");
MailboxVector::MailboxVector( const std::string& name): Mailbox<maal::boost::Vector> (name){} // Explicit template specialization
MAILBOX_TEMPLATE_SPE(maal::boost::Vector);
template<>DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(mailvect,"Mailbox<Vector>");
#endif // #ifdef HAVE_LIBBOOST_THREAD #endif // #ifdef HAVE_LIBBOOST_THREAD
......
...@@ -55,7 +55,7 @@ void f( void ) ...@@ -55,7 +55,7 @@ void f( void )
std::cout << " iter " << i << std::endl; std::cout << " iter " << i << std::endl;
for( int j=0;j<25;++j ) vect(j) = j+i*10; for( int j=0;j<25;++j ) vect(j) = j+i*10;
mailbox.post( vect ); mailbox.post( vect );
mailbox.getObject( vect2, 1 ); maal::boost::Vector V = mailbox.getObject( vect2, 1 );
std::cout << vect2 << std::endl; std::cout << vect2 << std::endl;
std::cout << " getClassName " << mailbox.getClassName() << std::endl; std::cout << " getClassName " << mailbox.getClassName() << std::endl;
std::cout << " getName " << mailbox.getName() << std::endl; std::cout << " getName " << mailbox.getName() << std::endl;
......
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