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

Added new test test_factory

parent 04837d78
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
# Copyright
#
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-paths.h.cmake
${CMAKE_CURRENT_SOURCE_DIR}/test-paths.h)
#The sot-core plugin libraries that tests have to be linked against
#the name of the variable for test EXECUTABLE_NAME is TEST_${EXECUTABLE_NAME}_LIBS
SET(TEST_tsot_LIBS
......@@ -12,13 +15,14 @@ SET(TEST_tsot_LIBS
#test paths and names (without .cpp extension)
SET (tests
main
link
signal/test_signal
signal/test_depend
signal/test_ptr
signal/test_dep
sot/tsot
sot/test_solverSoth)
sot/test_solverSoth
factory/test_factory)
FOREACH(test ${tests})
GET_FILENAME_COMPONENT(EXECUTABLE_NAME ${test} NAME)
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-JAPAN, Tsukuba, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: test_factory.cc
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
*
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* -------------------------------------------------------------------------- */
/* --- INCLUDES ------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include <string>
#include <iostream>
#include <sot-core/factory.h>
#include <dynamic-graph/entity.h>
#include "../test-paths.h"
#include <sot-core/feature-visual-point.h>
#include <sot-core/exception-feature.h>
#include <sot-core/debug.h>
using namespace std;
using namespace sot;
using namespace dg;
#ifdef WIN32
#include <Windows.h>
#else
#include <dlfcn.h>
#endif
#ifdef WIN32
typedef HMODULE sotPluginKey;
#else
typedef void* sotPluginKey;
#endif
class TestFeature
:public FeatureAbstract
{
public:
TestFeature( void ) : FeatureAbstract("") {}
virtual ~TestFeature( void ) {}
virtual unsigned int& getDimension( unsigned int& res,int time ) {return res;}
virtual ml::Vector& computeError( ml::Vector& res,int time ) {return res;}
virtual ml::Matrix& computeJacobian( ml::Matrix& res,int time ) {return res;}
virtual ml::Vector& computeActivation( ml::Vector& res,int time ) {return res;}
};
int main()
{
sotDEBUG(0) << "# In {"<<endl;
// Entity test("");
// ExceptionFeature t2(ExceptionFeature::BAD_INIT);
// ExceptionSignal t4(ExceptionSignal::COPY_NOT_INITIALIZED);
// Flags t3;
// TestFeature t5;
#ifndef WIN32
sotPluginKey dlib = dlopen(PLUGIN_LIB_INSTALL_PATH "feature-visual-point.so", RTLD_NOW);
#else
sotPluginKey dlib = LoadLibrary (PLUGIN_LIB_INSTALL_PATH "lib/plugin/feature-visual-point.lib");
#endif
if( NULL==dlib )
{
cerr << " Error dl"<<endl;
#ifndef WIN32
cerr << dlerror() <<endl;
#else
// Retrieve the system error message for the last-error code
LPTSTR pszMessage;
DWORD dwLastError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszMessage,
0, NULL );
cerr << pszMessage <<endl;
LocalFree(pszMessage);
#endif
exit(1);
}
#ifndef WIN32
dlib = dlopen(PLUGIN_LIB_INSTALL_PATH "lib/plugin/gain-adaptative.so", RTLD_NOW);
#else
dlib = LoadLibrary (PLUGIN_LIB_INSTALL_PATH "lib/plugin/gain-adaptative.lib");
#endif
if( NULL==dlib )
{
cerr << " Error dl"<<endl;
#ifndef WIN32
cerr << dlerror() <<endl;
#else
// Retrieve the system error message for the last-error code
LPTSTR pszMessage;
DWORD dwLastError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszMessage,
0, NULL );
cerr << pszMessage <<endl;
LocalFree(pszMessage);
#endif
exit(1);
}
Entity* gain = g_factory.newEntity("GainAdaptative","Gain");
FeatureAbstract* point = sotFactory.newFeature("FeatureVisualPoint","DynamicTest.");
try {
gain->display(cout); cout << endl;
cout <<gain->getClassName(); cout << endl;
point->display(cout); cout << endl;
cout <<point->getClassName(); cout << endl;
}
catch ( ExceptionSignal e ) {
cout << "Exception caught! " << e << endl;
}
sotDEBUG(0) << "# Out }"<<endl;
}
File moved
#ifndef TEST_PATHS_H
#define PLUGIN_LIB_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/lib/plugin"
#endif
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