moved rtabmap-ros-pkg project in this project

git-svn-id: http://rtabmap.googlecode.com/svn/branches/0.3/rtabmap@52 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2011-06-05 14:45:39 +00:00
commit 2d73090f3a
338 changed files with 56859 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
#include <cppunit/Portability.h>
#include <string>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
CPPUNIT_NS_BEGIN
/*! \brief Manages dynamic libraries.
*
* The Dynamic Library Manager provides a platform independent way to work with
* dynamic library. It load a specific dynamic library, and can returns specific
* symbol exported by the dynamic library.
*
* If an error occurs, a DynamicLibraryManagerException is thrown.
*
* \internal Implementation of the OS independent methods is in
* DynamicLibraryManager.cpp.
*
* \internal Porting to a new platform:
* - Adds platform detection in config/SelectDllLoader.h. Should define a specific
* macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where
* XYZ is the platform.
* - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform.
* - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is
* only processed if the matching platform has been detected.
* - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(),
* doFindSymbol() in your copy. Those methods usually maps directly to OS calls.
* - Adds the file to the project.
*/
class DynamicLibraryManager
{
public:
typedef void *Symbol;
typedef void *LibraryHandle;
/*! \brief Loads the specified library.
* \param libraryFileName Name of the library to load.
* \exception DynamicLibraryManagerException if a failure occurs while loading
* the library (fail to found or load the library).
*/
DynamicLibraryManager( const std::string &libraryFileName );
/// Releases the loaded library..
~DynamicLibraryManager();
/*! \brief Returns a pointer on the specified symbol exported by the library.
* \param symbol Name of the symbol exported by the library.
* \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL.
* \exception DynamicLibraryManagerException if the symbol is not found.
*/
Symbol findSymbol( const std::string &symbol );
private:
/*! Loads the specified library.
* \param libraryName Name of the library to load.
* \exception DynamicLibraryManagerException if a failure occurs while loading
* the library (fail to found or load the library).
*/
void loadLibrary( const std::string &libraryName );
/*! Releases the loaded library.
*
* \warning Must NOT throw any exceptions (called from destructor).
*/
void releaseLibrary();
/*! Loads the specified library.
*
* May throw any exceptions (indicates failure).
* \param libraryName Name of the library to load.
* \return Handle of the loaded library. \c NULL indicates failure.
*/
LibraryHandle doLoadLibrary( const std::string &libraryName );
/*! Releases the loaded library.
*
* The handle of the library to free is in \c m_libraryHandle. It is never
* \c NULL.
* \warning Must NOT throw any exceptions (called from destructor).
*/
void doReleaseLibrary();
/*! Returns a pointer on the specified symbol exported by the library.
*
* May throw any exceptions (indicates failure).
* \param symbol Name of the symbol exported by the library.
* \return Pointer on the symbol. \c NULL indicates failure.
*/
Symbol doFindSymbol( const std::string &symbol );
/*! Returns detailed information about doLoadLibrary() failure.
*
* Called just after a failed call to doLoadLibrary() to get extra
* error information.
*
* \return Detailed information about the failure of the call to
* doLoadLibrary() that just failed.
*/
std::string getLastErrorDetail() const;
/// Prevents the use of the copy constructor.
DynamicLibraryManager( const DynamicLibraryManager &copy );
/// Prevents the use of the copy operator.
void operator =( const DynamicLibraryManager &copy );
private:
LibraryHandle m_libraryHandle;
std::string m_libraryName;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H

View File

@@ -0,0 +1,53 @@
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <stdexcept>
#include <string>
CPPUNIT_NS_BEGIN
/*! \brief Exception thrown by DynamicLibraryManager when a failure occurs.
*
* Use getCause() to know what function caused the failure.
*
*/
class DynamicLibraryManagerException : public std::runtime_error
{
public:
enum Cause
{
/// Failed to load the dynamic library
loadingFailed =0,
/// Symbol not found in the dynamic library
symbolNotFound
};
/// Failed to load the dynamic library or Symbol not found in the dynamic library.
DynamicLibraryManagerException( const std::string &libraryName,
const std::string &errorDetail,
Cause cause );
~DynamicLibraryManagerException() throw()
{
}
Cause getCause() const;
const char *what() const throw();
private:
std::string m_message;
Cause m_cause;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H

View File

@@ -0,0 +1,113 @@
#ifndef CPPUNIT_PLUGIN_PLUGINMANAGER_H
#define CPPUNIT_PLUGIN_PLUGINMANAGER_H
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( push )
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
#endif
#include <cppunit/plugin/PlugInParameters.h>
struct CppUnitTestPlugIn;
CPPUNIT_NS_BEGIN
class DynamicLibraryManager;
class TestResult;
class XmlOutputter;
/*! \brief Manges TestPlugIn.
*/
class CPPUNIT_API PlugInManager
{
public:
/*! Constructs a PlugInManager object.
*/
PlugInManager();
/// Destructor.
virtual ~PlugInManager();
/*! \brief Loads the specified plug-in.
*
* After being loaded, the CppUnitTestPlugIn::initialize() is called.
*
* \param libraryFileName Name of the file that contains the TestPlugIn.
* \param parameters List of string passed to the plug-in.
* \return Pointer on the DynamicLibraryManager associated to the library.
* Valid until the library is unloaded. Never \c NULL.
* \exception DynamicLibraryManagerException is thrown if an error occurs during loading.
*/
void load( const std::string &libraryFileName,
const PlugInParameters &parameters = PlugInParameters() );
/*! \brief Unloads the specified plug-in.
* \param libraryFileName Name of the file that contains the TestPlugIn passed
* to a previous call to load().
*/
void unload( const std::string &libraryFileName );
/*! \brief Gives a chance to each loaded plug-in to register TestListener.
*
* For each plug-in, call CppUnitTestPlugIn::addListener().
*/
void addListener( TestResult *eventManager );
/*! \brief Gives a chance to each loaded plug-in to unregister TestListener.
* For each plug-in, call CppUnitTestPlugIn::removeListener().
*/
void removeListener( TestResult *eventManager );
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
*/
void addXmlOutputterHooks( XmlOutputter *outputter );
/*! \brief Called when the XmlOutputter is destroyed.
*
* Can be used to free some resources allocated by addXmlOutputterHooks().
*/
void removeXmlOutputterHooks();
protected:
/*! \brief (INTERNAL) Information about a specific plug-in.
*/
struct PlugInInfo
{
std::string m_fileName;
DynamicLibraryManager *m_manager;
CppUnitTestPlugIn *m_interface;
};
/*! Unloads the specified plug-in.
* \param plugIn Information about the plug-in.
*/
void unload( PlugInInfo &plugIn );
private:
/// Prevents the use of the copy constructor.
PlugInManager( const PlugInManager &copy );
/// Prevents the use of the copy operator.
void operator =( const PlugInManager &copy );
private:
typedef CppUnitDeque<PlugInInfo> PlugIns;
PlugIns m_plugIns;
};
CPPUNIT_NS_END
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( pop )
#endif
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_PLUGINMANAGER_H

View File

@@ -0,0 +1,36 @@
#ifndef CPPUNIT_PLUGIN_PARAMETERS
#define CPPUNIT_PLUGIN_PARAMETERS
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/portability/CppUnitDeque.h>
#include <string>
CPPUNIT_NS_BEGIN
/*! \brief Test plug-ins parameters.
*/
class CPPUNIT_API PlugInParameters
{
public:
/// Constructs plug-in parameters from the specified command-line.
PlugInParameters( const std::string &commandLine = "" );
virtual ~PlugInParameters();
/// Returns the command line that was passed on construction.
std::string getCommandLine() const;
private:
std::string m_commandLine;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_PARAMETERS

View File

@@ -0,0 +1,200 @@
#ifndef CPPUNIT_PLUGIN_TESTPLUGIN
#define CPPUNIT_PLUGIN_TESTPLUGIN
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/plugin/PlugInParameters.h>
CPPUNIT_NS_BEGIN
class Test;
class TestFactoryRegistry;
class TestResult;
class XmlOutputter;
CPPUNIT_NS_END
/*! \file
*/
/*! \brief Test plug-in interface.
* \ingroup WritingTestPlugIn
*
* This class define the interface implemented by test plug-in. A pointer to that
* interface is returned by the function exported by the test plug-in.
*
* Plug-in are loaded/unloaded by PlugInManager. When a plug-in is loaded,
* initialize() is called. Before unloading the plug-in, the PlugInManager
* call uninitialize().
*
* addListener() and removeListener() are called respectively before and after
* the test run.
*
* addXmlOutputterHooks() and removeXmlOutputterHooks() are called respectively
* before and after writing the XML output using a XmlOutputter.
*
* \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL
* \see CppUnit::TestPlugInDefaultImpl, CppUnit::XmlOutputter.
*/
struct CppUnitTestPlugIn
{
/*! \brief Called just after loading the dynamic library.
*
* Override this method to add additional suite to the registry, though this
* is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...).
* If you are creating a custom listener to extends the plug-in runner,
* you can use this to configure the listener using the \a parameters.
*
* You could also use the parameters to specify some global parameter, such
* as test datas location, database name...
*
* N.B.: Parameters interface is not define yet, and the plug-in runner does
* not yet support plug-in parameter.
*/
virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
const CPPUNIT_NS::PlugInParameters &parameters ) =0;
/*! \brief Gives a chance to the plug-in to register TestListener.
*
* Override this method to add a TestListener for the test run. This is useful
* if you are writing a custom TestListener, but also if you need to
* setUp some global resource: listen to TestListener::startTestRun(),
* and TestListener::endTestRun().
*/
virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0;
/*! \brief Gives a chance to the plug-in to remove its registered TestListener.
*
* Override this method to remove a TestListener that has been added.
*/
virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0;
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
*/
virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0;
/*! \brief Called when the XmlOutputter is destroyed.
*
* Can be used to free some resources allocated by addXmlOutputterHooks().
*/
virtual void removeXmlOutputterHooks() = 0;
/*! \brief Called just before unloading the dynamic library.
*
* Override this method to unregister test factory added in initialize().
* This is necessary to keep the TestFactoryRegistry 'clean'. When
* the plug-in is unloaded from memory, the TestFactoryRegistry will hold
* reference on test that are no longer available if they are not
* unregistered.
*/
virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0;
virtual ~CppUnitTestPlugIn() {}
};
/*! \brief Name of the function exported by a test plug-in.
* \ingroup WritingTestPlugIn
*
* The signature of the exported function is:
* \code
* CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void);
* \endcode
*/
#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
/*! \brief Type of the function exported by a plug-in.
* \ingroup WritingTestPlugIn
*/
typedef CppUnitTestPlugIn *(*TestPlugInSignature)();
/*! \brief Implements the function exported by the test plug-in
* \ingroup WritingTestPlugIn
*/
#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \
CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \
{ \
static TestPlugInInterfaceType plugIn; \
return &plugIn; \
} \
typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';'
// Note: This include should remain after definition of CppUnitTestPlugIn
#include <cppunit/plugin/TestPlugInDefaultImpl.h>
/*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
* \brief Implements the 'main' function for the plug-in.
*
* This macros implements the main() function for dynamic library.
* For example, WIN32 requires a DllMain function, while some Unix
* requires a main() function. This macros takes care of the implementation.
*/
// Win32
#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
#if !defined(APIENTRY)
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define NOKERNEL
#define NOSOUND
#define NOMINMAX
#define BLENDFUNCTION void // for mingw & gcc
#include <windows.h>
#endif
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
BOOL APIENTRY DllMain( HANDLE hModule, \
DWORD ul_reason_for_call, \
LPVOID lpReserved ) \
{ \
return TRUE; \
} \
typedef char __CppUnitPlugInImplementMainDummyTypeDef
// Unix
#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER)
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
int main( int argc, char *argv[] ) \
{ \
return 0; \
} \
typedef char __CppUnitPlugInImplementMainDummyTypeDef
// Other
#else // other platforms don't require anything specifics
#endif
/*! \brief Implements and exports the test plug-in interface.
* \ingroup WritingTestPlugIn
*
* This macro exports the test plug-in function using the subclass,
* and implements the 'main' function for the plug-in using
* CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
*
* When using this macro, CppUnit must be linked as a DLL (shared library).
* Otherwise, tests registered to the TestFactoryRegistry in the DLL will
* not be visible to the DllPlugInTester.
*
* \see CppUnitTestPlugIn
* \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
*/
#define CPPUNIT_PLUGIN_IMPLEMENT() \
CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \
CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_TESTPLUGIN

View File

@@ -0,0 +1,52 @@
#ifndef CPPUNIT_PLUGIN_TESTPLUGINADAPTER
#define CPPUNIT_PLUGIN_TESTPLUGINADAPTER
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/plugin/TestPlugIn.h>
CPPUNIT_NS_BEGIN
class TestSuite;
/*! \brief Default implementation of test plug-in interface.
* \ingroup WritingTestPlugIn
*
* Override getSuiteName() to specify the suite name. Default is "All Tests".
*
* CppUnitTestPlugIn::getTestSuite() returns a suite that contains
* all the test registered to the default test factory registry
* ( TestFactoryRegistry::getRegistry() ).
*
*/
class CPPUNIT_API TestPlugInDefaultImpl : public CppUnitTestPlugIn
{
public:
TestPlugInDefaultImpl();
virtual ~TestPlugInDefaultImpl();
void initialize( TestFactoryRegistry *registry,
const PlugInParameters &parameters );
void addListener( TestResult *eventManager );
void removeListener( TestResult *eventManager );
void addXmlOutputterHooks( XmlOutputter *outputter );
void removeXmlOutputterHooks();
void uninitialize( TestFactoryRegistry *registry );
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_TESTPLUGINADAPTER