From: <gb...@us...> - 2009-03-24 15:56:15
|
Revision: 7540 http://playerstage.svn.sourceforge.net/playerstage/?rev=7540&view=rev Author: gbiggs Date: 2009-03-24 15:56:04 +0000 (Tue, 24 Mar 2009) Log Message: ----------- Fixed issues with finding geos Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/server/drivers/vectormap/CMakeLists.txt Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-03-23 19:09:46 UTC (rev 7539) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-03-24 15:56:04 UTC (rev 7540) @@ -81,7 +81,8 @@ APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" z) ENDIF (HAVE_Z) IF (HAVE_GEOS) - TARGET_LINK_LIBRARIES (playerc ${GEOS_LIBS}) + TARGET_LINK_LIBRARIES (playerc geos geos_c) + APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" geos geos_c) ENDIF (HAVE_GEOS) IF (PLAYER_OS_QNX) TARGET_LINK_LIBRARIES (playerc socket rpc) Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-03-23 19:09:46 UTC (rev 7539) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-03-24 15:56:04 UTC (rev 7540) @@ -120,6 +120,9 @@ SET (HAVE_CLOCK_GETTIME TRUE) ENDIF (HAVE_LIBRT AND HAVE_CLOCK_GETTIME_FUNC) +# Geos check +CHECK_LIBRARY_EXISTS (geos_c GEOSGeomFromWKB_buf "${PLAYER_EXTRA_LIB_DIRS}" HAVE_GEOS) + # Endianess check INCLUDE (TestBigEndian) TEST_BIG_ENDIAN (WORDS_BIGENDIAN) Modified: code/player/trunk/server/drivers/vectormap/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-03-23 19:09:46 UTC (rev 7539) +++ code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-03-24 15:56:04 UTC (rev 7540) @@ -1,4 +1,8 @@ -PLAYERDRIVER_OPTION (postgis build_postgis ON) +IF (HAVE_STL) + PLAYERDRIVER_OPTION (postgis build_postgis ON) +ELSE (HAVE_STL) + PLAYERDRIVER_OPTION (postgis build_postgis OFF "STL not found") +ENDIF (HAVE_STL) PLAYERDRIVER_REQUIRE_HEADER (postgis build_postgis geos_c.h) PLAYERDRIVER_REQUIRE_PKG (postgis build_postgis libpqxx postgis_includeDir postgis_libDir postgis_linkFlags postgis_cFlags) @@ -7,6 +11,13 @@ LINKFLAGS "-lgeos ${postgis_linkFlags}" CFLAGS "${postgis_cFlags}" SOURCES postgis.cc dbconn.cc) -PLAYERDRIVER_OPTION (vec2map build_vec2map ON) -PLAYERDRIVER_REQUIRE_HEADER (vec2map build_vec2map geos_c.h) +IF (HAVE_GEOS) + IF (HAVE_STL) + PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "const problems to be fixed soon (I hope)") + ELSE (HAVE_STL) + PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "STL not found") + ENDIF (HAVE_STL) +ELSE (HAVE_GEOS) + PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "Geos not found") +ENDIF (HAVE_GEOS) PLAYERDRIVER_ADD_DRIVER (vec2map build_vec2map LINKFLAGS "-lgeos" SOURCES vec2map.cc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-03-24 18:50:24
|
Revision: 7541 http://playerstage.svn.sourceforge.net/playerstage/?rev=7541&view=rev Author: gbiggs Date: 2009-03-24 18:50:06 +0000 (Tue, 24 Mar 2009) Log Message: ----------- Merged changeset 7300 from 2-1-patches to fix geos casting problems Modified Paths: -------------- code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/server/drivers/vectormap/CMakeLists.txt code/player/trunk/server/drivers/vectormap/dbconn.cc code/player/trunk/server/drivers/vectormap/vec2map.cc Added Paths: ----------- code/player/trunk/libplayercore/player_geos.h Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263,7276 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263,7276,7300 /code/player/trunk:6985 Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-03-24 15:56:04 UTC (rev 7540) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-03-24 18:50:06 UTC (rev 7541) @@ -130,6 +130,7 @@ playercommon.h ${playerconfig_h} playercore.h + player_geos.h player.h ${player_interfaces_h} playertime.h Copied: code/player/trunk/libplayercore/player_geos.h (from rev 7300, code/player/branches/release-2-1-patches/libplayercore/player_geos.h) =================================================================== --- code/player/trunk/libplayercore/player_geos.h (rev 0) +++ code/player/trunk/libplayercore/player_geos.h 2009-03-24 18:50:06 UTC (rev 7541) @@ -0,0 +1,18 @@ +#ifndef PLAYER_GEOS_H_ +#define PLAYER_GEOS_H_ + +#ifndef GEOS_VERSION_MAJOR +#include <stddef.h> +#include <geos_c.h> +#endif + +// workaround gcc 4.2's confusion over typedeffed constants +#if GEOS_VERSION_MAJOR >= 3 +typedef const struct GEOSCoordSeq_t * const_GEOSCoordSeq; +typedef const struct GEOSGeom_t * const_GEOSGeom; +#else +typedef struct GEOSCoordSeq_t * const_GEOSCoordSeq; +typedef struct GEOSGeom_t * const_GEOSGeom; +#endif + +#endif /* PLAYER_GEOS_H_ */ Modified: code/player/trunk/server/drivers/vectormap/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-03-24 15:56:04 UTC (rev 7540) +++ code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-03-24 18:50:06 UTC (rev 7541) @@ -13,11 +13,11 @@ IF (HAVE_GEOS) IF (HAVE_STL) - PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "const problems to be fixed soon (I hope)") + PLAYERDRIVER_OPTION (vec2map build_vec2map ON) ELSE (HAVE_STL) PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "STL not found") ENDIF (HAVE_STL) ELSE (HAVE_GEOS) PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "Geos not found") ENDIF (HAVE_GEOS) -PLAYERDRIVER_ADD_DRIVER (vec2map build_vec2map LINKFLAGS "-lgeos" SOURCES vec2map.cc) +PLAYERDRIVER_ADD_DRIVER (vec2map build_vec2map LINKFLAGS "-lgeos -lgeos_c" SOURCES vec2map.cc) Modified: code/player/trunk/server/drivers/vectormap/dbconn.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/dbconn.cc 2009-03-24 15:56:04 UTC (rev 7540) +++ code/player/trunk/server/drivers/vectormap/dbconn.cc 2009-03-24 18:50:06 UTC (rev 7541) @@ -6,10 +6,8 @@ #include <cctype> #include "dbconn.h" #ifdef HAVE_GEOS -#ifndef GEOS_VERSION_MAJOR -#include <geos_c.h> +#include <libplayercore/player_geos.h> #endif -#endif using namespace std; @@ -69,7 +67,7 @@ cerr << "No extent value found." << endl; cerr << "GetVectorMapInfo() failed" << endl; } - + uint32_t length = PQgetlength(res, 0, 0); uint8_t * wkb = new uint8_t[length]; assert(wkb); @@ -280,7 +278,7 @@ } if (PQresultStatus(res) != PGRES_COMMAND_OK) PLAYER_ERROR1("%s", PQresultErrorMessage(res)); PQclear(res); - return -1; + return -1; } PQclear(res); } @@ -314,13 +312,13 @@ printf("GEOSGeomFromWKB_buf returned NULL!\n"); return res; } - GEOSGeom linestring = GEOSGetExteriorRing(polygon); + const_GEOSGeom linestring = GEOSGetExteriorRing(polygon); if (linestring == NULL) { printf("GEOSGetExteriorRing returned NULL!\n"); return res; } - GEOSCoordSeq coords = GEOSGeom_getCoordSeq(linestring); + const_GEOSCoordSeq coords = GEOSGeom_getCoordSeq(linestring); if (coords == NULL) { printf("GEOSGeom_getCoordSeq returned NULL!\n"); Modified: code/player/trunk/server/drivers/vectormap/vec2map.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-03-24 15:56:04 UTC (rev 7540) +++ code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-03-24 18:50:06 UTC (rev 7541) @@ -91,10 +91,8 @@ #include <pthread.h> #include <libplayercore/playercore.h> #ifdef HAVE_GEOS -#ifndef GEOS_VERSION -#include <geos_c.h> +#include <libplayercore/player_geos.h> #endif -#endif #define EPS 0.00001 #define MAXFABS(a, b) ((fabs(a) > fabs(b)) ? fabs(a) : fabs(b)) @@ -124,7 +122,7 @@ // some helper functions #ifdef HAVE_GEOS - void dumpFeature(GEOSGeom geom, vector<player_segment_t> & segments); + void dumpFeature(const_GEOSGeom geom, vector<player_segment_t> & segments); #endif void line(int a, int b, int c, int d, int8_t * cells, int maxx, int maxy); int over(int x, int min, int max); @@ -274,9 +272,9 @@ } #ifdef HAVE_GEOS -void Vec2Map::dumpFeature(GEOSGeom geom, vector<player_segment_t> & segments) +void Vec2Map::dumpFeature(const_GEOSGeom geom, vector<player_segment_t> & segments) { - GEOSCoordSeq seq; + const_GEOSCoordSeq seq; double x0, y0, x1, y1; unsigned int numcoords; player_segment_t segment; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-03-30 06:57:31
|
Revision: 7559 http://playerstage.svn.sourceforge.net/playerstage/?rev=7559&view=rev Author: gbiggs Date: 2009-03-30 06:57:21 +0000 (Mon, 30 Mar 2009) Log Message: ----------- Moved PLAYER_VERSION into playerconfig.h.in so that it can be used after installation. Modified Paths: -------------- code/player/trunk/config.h.in code/player/trunk/playerconfig.h.in Modified: code/player/trunk/config.h.in =================================================================== --- code/player/trunk/config.h.in 2009-03-30 05:55:10 UTC (rev 7558) +++ code/player/trunk/config.h.in 2009-03-30 06:57:21 UTC (rev 7559) @@ -1,8 +1,5 @@ /* config.h. Generated by CMake for @PROJECT_NAME@. */ -/* Player version string */ -#cmakedefine PLAYER_VERSION "${PLAYER_VERSION}" - /* Install prefix */ #define PLAYER_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" Modified: code/player/trunk/playerconfig.h.in =================================================================== --- code/player/trunk/playerconfig.h.in 2009-03-30 05:55:10 UTC (rev 7558) +++ code/player/trunk/playerconfig.h.in 2009-03-30 06:57:21 UTC (rev 7559) @@ -1,3 +1,6 @@ +/* Player version string */ +#cmakedefine PLAYER_VERSION "${PLAYER_VERSION}" + #cmakedefine HAVE_GEOS 1 #cmakedefine HAVE_CFMAKERAW 1 #cmakedefine HAVE_DIRNAME 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-04-03 02:04:15
|
Revision: 7573 http://playerstage.svn.sourceforge.net/playerstage/?rev=7573&view=rev Author: gbiggs Date: 2009-04-03 02:00:17 +0000 (Fri, 03 Apr 2009) Log Message: ----------- Moved HAVE_GETOPT declaration, gcc 4.3 fix Modified Paths: -------------- code/player/trunk/config.h.in code/player/trunk/playerconfig.h.in code/player/trunk/utils/playerprop/playerprop.cpp Modified: code/player/trunk/config.h.in =================================================================== --- code/player/trunk/config.h.in 2009-04-03 01:52:31 UTC (rev 7572) +++ code/player/trunk/config.h.in 2009-04-03 02:00:17 UTC (rev 7573) @@ -20,5 +20,4 @@ #cmakedefine HAVE_UNISTD_H 1 #cmakedefine HAVE_IEEEFP_H 1 #cmakedefine WORDS_BIGENDIAN 1 -#cmakedefine HAVE_GETOPT 1 Modified: code/player/trunk/playerconfig.h.in =================================================================== --- code/player/trunk/playerconfig.h.in 2009-04-03 01:52:31 UTC (rev 7572) +++ code/player/trunk/playerconfig.h.in 2009-04-03 02:00:17 UTC (rev 7573) @@ -24,6 +24,7 @@ #cmakedefine HAVE_USLEEP 1 #cmakedefine HAVE_NANOSLEEP 1 #cmakedefine HAVE_STRUCT_TIMESPEC 1 +#cmakedefine HAVE_GETOPT 1 #if defined HAVE_STDINT_H #include <stdint.h> Modified: code/player/trunk/utils/playerprop/playerprop.cpp =================================================================== --- code/player/trunk/utils/playerprop/playerprop.cpp 2009-04-03 01:52:31 UTC (rev 7572) +++ code/player/trunk/utils/playerprop/playerprop.cpp 2009-04-03 02:00:17 UTC (rev 7573) @@ -29,7 +29,7 @@ #include <config.h> #if !HAVE_GETOPT - #include <replace.h> + #include <replace/replace.h> #endif #include <libplayerc++/playerc++.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-04-03 08:01:53
|
Revision: 7574 http://playerstage.svn.sourceforge.net/playerstage/?rev=7574&view=rev Author: gbiggs Date: 2009-04-03 08:01:42 +0000 (Fri, 03 Apr 2009) Log Message: ----------- Removed some unnecessary #defines from config.h.in Modified Paths: -------------- code/player/trunk/config.h.in code/player/trunk/playerconfig.h.in Modified: code/player/trunk/config.h.in =================================================================== --- code/player/trunk/config.h.in 2009-04-03 02:00:17 UTC (rev 7573) +++ code/player/trunk/config.h.in 2009-04-03 08:01:42 UTC (rev 7574) @@ -10,14 +10,8 @@ #cmakedefine HAVE_JPEG 1 #cmakedefine HAVE_Z 1 #cmakedefine HAVE_LINUX_JOYSTICK_H 1 -#cmakedefine HAVE_STDLIB_H 1 #cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_STRING_H 1 #cmakedefine HAVE_SYS_FILIO_H 1 -#cmakedefine HAVE_SYS_SOUNDCARD_H 1 -#cmakedefine HAVE_SYS_STAT_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 -#cmakedefine HAVE_UNISTD_H 1 #cmakedefine HAVE_IEEEFP_H 1 #cmakedefine WORDS_BIGENDIAN 1 Modified: code/player/trunk/playerconfig.h.in =================================================================== --- code/player/trunk/playerconfig.h.in 2009-04-03 02:00:17 UTC (rev 7573) +++ code/player/trunk/playerconfig.h.in 2009-04-03 08:01:42 UTC (rev 7574) @@ -1,3 +1,5 @@ +/* playerconfig.h. Generated by CMake for @PROJECT_NAME@. */ + /* Player version string */ #cmakedefine PLAYER_VERSION "${PLAYER_VERSION}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-04-08 08:20:41
|
Revision: 7586 http://playerstage.svn.sourceforge.net/playerstage/?rev=7586&view=rev Author: gbiggs Date: 2009-04-08 08:20:15 +0000 (Wed, 08 Apr 2009) Log Message: ----------- Reworked the collection of and setting of libraries to link to and pkg-config results. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/CMake_Todo.txt code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/playerc++config.h.in code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt code/player/trunk/cmake/PlayerUtils.cmake code/player/trunk/cmake/UsePlayerC++.cmake.in code/player/trunk/cmake/UsePlayerC.cmake.in code/player/trunk/cmake/UsePlayerPlugin.cmake.in code/player/trunk/cmake/internal/DriverUtils.cmake code/player/trunk/cmake/internal/LibraryUtils.cmake code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/examples/libplayerc/CMakeLists.txt code/player/trunk/examples/libplayerc/CMakeLists.txt.example.in code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in code/player/trunk/examples/plugins/exampledriver/CMakeLists.txt.example.in code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt.example.in code/player/trunk/examples/plugins/multidriver/CMakeLists.txt.example.in code/player/trunk/examples/plugins/opaquedriver/CMakeLists.txt.example.in code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayerjpeg/CMakeLists.txt code/player/trunk/libplayertcp/CMakeLists.txt code/player/trunk/libplayerxdr/CMakeLists.txt code/player/trunk/rtk2/CMakeLists.txt code/player/trunk/server/CMakeLists.txt code/player/trunk/server/drivers/blobfinder/artoolkitplus/CMakeLists.txt code/player/trunk/server/drivers/blobfinder/shapetracker/CMakeLists.txt code/player/trunk/server/drivers/blobfinder/simpleshape/CMakeLists.txt code/player/trunk/server/drivers/blobfinder/upcbarcode/CMakeLists.txt code/player/trunk/server/drivers/camera/cvcam/CMakeLists.txt code/player/trunk/server/drivers/camera/imageseq/CMakeLists.txt code/player/trunk/server/drivers/health/statgrab/CMakeLists.txt code/player/trunk/server/drivers/map/CMakeLists.txt code/player/trunk/server/drivers/mixed/garcia/CMakeLists.txt code/player/trunk/server/drivers/mixed/mricp/CMakeLists.txt code/player/trunk/server/drivers/opaque/CMakeLists.txt code/player/trunk/server/drivers/planner/wavefront/CMakeLists.txt code/player/trunk/server/drivers/ranger/CMakeLists.txt code/player/trunk/server/drivers/service_adv/CMakeLists.txt code/player/trunk/server/drivers/vectormap/CMakeLists.txt code/player/trunk/server/libplayerdrivers/CMakeLists.txt code/player/trunk/utils/playercam/CMakeLists.txt code/player/trunk/utils/playerjoy/CMakeLists.txt code/player/trunk/utils/playernav/CMakeLists.txt code/player/trunk/utils/playerprint/CMakeLists.txt code/player/trunk/utils/playerprop/CMakeLists.txt code/player/trunk/utils/playerv/CMakeLists.txt code/player/trunk/utils/playervcr/CMakeLists.txt code/player/trunk/utils/playerwritemap/CMakeLists.txt Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -50,7 +50,7 @@ # Include some useful macros INCLUDE (${PLAYER_CMAKE_DIR}/internal/LibraryUtils.cmake) -# Set some common include directories, including the binary dir to get config.h +# Set some common include directories, including the binary dir to get config.h and playerconfig.h INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libplayercore) # Extra directories where needed libraries, etc may be located (set by the user) INCLUDE_DIRECTORIES (${PLAYER_EXTRA_INCLUDE_DIRS}) @@ -74,8 +74,17 @@ ENDIF (PLAYER_OS_WIN) MESSAGE (STATUS "") -SET (PLAYER_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to" FORCE) +#SET (PLAYERCORE_INT_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories for playercore" FORCE) +#SET (PLAYERCORE_INT_LINK_DIRS "" CACHE INTERNAL "Library directories to link playercore to" FORCE) +SET (PLAYERCORE_INT_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link playercore to" FORCE) +#SET (PLAYERCORE_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playercore" FORCE) +#SET (PLAYERCORE_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playercore" FORCE) +SET (PLAYERCORE_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playercore" FORCE) +#SET (PLAYERC_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playerc" FORCE) +#SET (PLAYERC_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playerc" FORCE) SET (PLAYERC_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playerc" FORCE) +#SET (PLAYERCC_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playercc" FORCE) +#SET (PLAYERCC_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playercc" FORCE) SET (PLAYERCC_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playercc" FORCE) # Create packages Modified: code/player/trunk/CMake_Todo.txt =================================================================== --- code/player/trunk/CMake_Todo.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/CMake_Todo.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,7 +1,7 @@ -- Fix installation of python bindings to install to a less-generic location (use distutils to install if possible) - Java bindings for core, xdr, tcp, etc - Figure out why it always rebuilds driverregistry.c. Make it stop. - dist tarballs, packages, etc - add in the extra_dist files to the source one, make the debian one - Drivers being disabled by a check used to correctly force their option to off. Figure out why this broke. Fix it. - Figure out why C++ tests and C++ examples don't link properly when building as static libs, even though the server and utils do. - Add CMakeLists equivalent of the wavefront driver's Makefile.test (and get rid of Makefile.test) +- PLAYER_PROCESS_ARGUMENTS should not need to have arguments enclosed in quotes. Fix this. Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -65,34 +65,41 @@ SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) ENDIF (NOT HAVE_NANOSLEEP) -PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) -ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) -TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) -IF (HAVE_JPEG) - TARGET_LINK_LIBRARIES (playerc playerjpeg) -ENDIF (HAVE_JPEG) IF (HAVE_M) - TARGET_LINK_LIBRARIES (playerc m) - APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" m) - SET (libmLinkStr "-lm") + PLAYERC_ADD_LINK_LIB (m) ENDIF (HAVE_M) IF (HAVE_Z) - TARGET_LINK_LIBRARIES (playerc z) - APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" z) + PLAYERC_ADD_LINK_LIB (z) ENDIF (HAVE_Z) IF (HAVE_GEOS) - TARGET_LINK_LIBRARIES (playerc geos geos_c) - APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" geos geos_c) + PLAYERC_ADD_LINK_LIB (geos geosc) ENDIF (HAVE_GEOS) IF (PLAYER_OS_QNX) - TARGET_LINK_LIBRARIES (playerc socket rpc) + PLAYERC_ADD_LINK_LIB (socket rpc) ELSEIF (PLAYER_OS_SOLARIS) - TARGET_LINK_LIBRARIES (playerc socket nsl rt) + PLAYERC_ADD_LINK_LIB (socket nsl rt) ENDIF (PLAYER_OS_QNX) IF (PLAYER_OS_WIN) - TARGET_LINK_LIBRARIES (playerc Ws2_32) + PLAYERC_ADD_LINK_LIB (Ws2_32) ENDIF (PLAYER_OS_WIN) +LINK_DIRECTORIES (${PLAYERC_EXTRA_LINK_DIRS}) +PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) +ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) +TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) +IF (HAVE_JPEG) + TARGET_LINK_LIBRARIES (playerc playerjpeg) +ENDIF (HAVE_JPEG) + PLAYER_INSTALL_HEADERS (playerc playerc.h) -PLAYER_MAKE_PKGCONFIG ("playerc" "Andrew Howard's Player C client library - part of the Player Project" "playerxdr playererror" "" "" "${libmLinkStr}") +SET (pkgconfigCFlags) +SET (pkgconfigLinkDirs) +SET (pkgconfigLinkLibs) +LIST_TO_STRING_WITH_PREFIX (pkgconfigCFlags "-I" ${PLAYERC_EXTRA_INCLUDE_DIRS}) +LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkDirs "-L" ${PLAYERC_EXTRA_LINK_DIRS}) +LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERC_EXTRA_LINK_LIBRARIES}) +PLAYER_MAKE_PKGCONFIG ("playerc" + "Andrew Howard's Player C client library - part of the Player Project" + "playerxdr playererror" "" "${pkgconfigCFlags}" + "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -41,7 +41,6 @@ IF (Boost_FOUND) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR}) PLAYERCC_ADD_INCLUDE_DIR (${Boost_INCLUDE_DIR}) - LINK_DIRECTORIES (${Boost_LIBRARY_DIRS}) PLAYERCC_ADD_LINK_DIR (${Boost_LIBRARY_DIRS}) IF (Boost_THREAD_FOUND) @@ -208,31 +207,29 @@ SET (playerccSrcs ${playerccSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) ENDIF (NOT HAVE_NANOSLEEP) - PLAYER_ADD_LIBRARY (playerc++ ${playerccSrcs} ${playercppconfig_h}) - TARGET_LINK_LIBRARIES (playerc++ playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + IF (HAVE_M) + PLAYERCC_ADD_LINK_LIB (m) + ENDIF (HAVE_M) + IF (PLAYER_OS_SOLARIS) - TARGET_LINK_LIBRARIES (playerc++ socket nsl) - SET (pkgconfigLibFlags "-lsocket -lnsl") - ELSE (PLAYER_OS_SOLARIS) - SET (pkgconfigLibFlags) + PLAYERCC_ADD_LINK_LIB ("socket") + PLAYERCC_ADD_LINK_LIB ("nsl") ENDIF (PLAYER_OS_SOLARIS) - IF (Boost_LIBRARY_DIRS) - SET (pkgconfigLibFlags "${pkgconfigLibFlags} -L${Boost_LIBRARY_DIRS}") - ENDIF (Boost_LIBRARY_DIRS) - IF (bostIncludeDir) - SET (pkgconfigIncFlags "-I${boostIncludeDir}") - ENDIF (bostIncludeDir) - IF (boostThreadLib) - SET (pkgconfigLibFlags "${pkgconfigLibFlags} -l${boostThreadLib}") - ENDIF (boostThreadLib) - IF (boostSignalsLib) - SET (pkgconfigLibFlags "${pkgconfigLibFlags} -l${boostSignalsLib}") - ENDIF (boostSignalsLib) + LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) + PLAYER_ADD_LIBRARY (playerc++ ${playerccSrcs} ${playercppconfig_h}) + TARGET_LINK_LIBRARIES (playerc++ playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + + SET (pkgconfigCFlags) + SET (pkgconfigLinkDirs) + SET (pkgconfigLinkLibs) + LIST_TO_STRING_WITH_PREFIX (pkgconfigCFlags "-I" ${PLAYERCC_EXTRA_INCLUDE_DIRS}) + LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkDirs "-L" ${PLAYERCC_EXTRA_LINK_DIRS}) + LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERCC_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playerc++" "C++ wrapper for libplayerc - part of the Player Project" - "playerxdr playerc" "" "${pkgconfigIncFlags}" - "-lm ${pkgconfigLibFlags}") + "playerxdr playerc" "" "${pkgconfigCFlags}" + "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerC++.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerC++.cmake @ONLY) PLAYER_INSTALL_HEADERS (playerc++ ${playercppconfig_h} Modified: code/player/trunk/client_libs/libplayerc++/playerc++config.h.in =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++config.h.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/client_libs/libplayerc++/playerc++config.h.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,8 +1,8 @@ #ifndef __PLAYER_CPP_CONFIG_H__ #define __PLAYER_CPP_CONFIG_H__ -#cmakedefine HAVE_BOOST_THREAD -#cmakedefine HAVE_BOOST_SIGNALS +#cmakedefine HAVE_BOOST_THREAD 1 +#cmakedefine HAVE_BOOST_SIGNALS 1 #if defined (HAVE_BOOST_THREAD) #define _POSIX_PTHREAD_SEMANTICS Modified: code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -36,9 +36,9 @@ SET (testsSrcs ${testsSrcs} ${PROJECT_SOURCE_DIR}/replace/round.c) ENDIF (NOT HAVE_ROUND) - ADD_DEFINITIONS (${PLAYERCC_DEFINITIONS}) + LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) ADD_EXECUTABLE (playerc++_test ${testsSrcs}) - TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror ${PLAYERCC_EXTRA_LINK_LIBRARIES}) ENDIF (BUILD_CC_TESTS) ENDIF (BUILD_PLAYERCC_BOOST) ENDIF (BUILD_PLAYERCC) Modified: code/player/trunk/cmake/PlayerUtils.cmake =================================================================== --- code/player/trunk/cmake/PlayerUtils.cmake 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/PlayerUtils.cmake 2009-04-08 08:20:15 UTC (rev 7586) @@ -136,6 +136,16 @@ ############################################################################### +# LIST_TO_STRING_WITH_PREFIX +# Macro to turn a list into a string, prefixing each item +MACRO (LIST_TO_STRING_WITH_PREFIX _string _prefix) + SET (${_string}) + FOREACH (_item ${ARGN}) + SET (${_string} "${${_string}} ${_prefix}${_item}") + ENDFOREACH (_item) +ENDMACRO (LIST_TO_STRING_WITH_PREFIX) + +############################################################################### # This macro processes a list of arguments into separate lists based on # keywords found in the argument stream. For example: # BUILDBLAG (miscArg INCLUDEDIRS /usr/include LIBDIRS /usr/local/lib @@ -145,10 +155,11 @@ # as normal, then pass ${ARGN} to this macro to parse the dynamic-length # arguments (so if ${_otherArgs} comes back non-empty, you've ignored something # or the user has passed in some arguments without a keyword). -MACRO (PLAYER_PROCESS_ARGUMENTS _sourcesArgs _includeDirsArgs _libDirsArgs _linkFlagsArgs _cFlagsArgs _otherArgs) +MACRO (PLAYER_PROCESS_ARGUMENTS _sourcesArgs _includeDirsArgs _libDirsArgs _linkLibsArgs _linkFlagsArgs _cFlagsArgs _otherArgs) SET (${_sourcesArgs}) SET (${_includeDirsArgs}) SET (${_libDirsArgs}) + SET (${_linkLibsArgs}) SET (${_linkFlagsArgs}) SET (${_cFlagsArgs}) SET (${_otherArgs}) @@ -160,6 +171,8 @@ SET (_currentDest ${_includeDirsArgs}) ELSEIF (_arg STREQUAL "LIBDIRS") SET (_currentDest ${_libDirsArgs}) + ELSEIF (_arg STREQUAL "LINKLIBS") + SET (_currentDest ${_linkLibsArgs}) ELSEIF (_arg STREQUAL "LINKFLAGS") SET (_currentDest ${_linkFlagsArgs}) ELSEIF (_arg STREQUAL "CFLAGS") Modified: code/player/trunk/cmake/UsePlayerC++.cmake.in =================================================================== --- code/player/trunk/cmake/UsePlayerC++.cmake.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/UsePlayerC++.cmake.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,18 +1,36 @@ CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) +IF (COMMAND CMAKE_POLICY) + CMAKE_POLICY (SET CMP0003 NEW) +ENDIF (COMMAND CMAKE_POLICY) + INCLUDE (PlayerUtils) INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - SET (PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@ @pkgconfigIncFlags@") - SET (PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib -lm @pkgconfigLibFlags@") + SET (PLAYERCPP_CFLAGS "") + SET (PLAYERCPP_INCLUDE_DIRS @PLAYERCC_EXTRA_INCLUDE_DIRS@) + LIST (APPEND PLAYERCPP_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLAYERCPP_LINK_LIBS @PLAYERCC_EXTRA_LINK_LIBRARIES@) + LIST (APPEND PLAYERCPP_LINK_LIBS "playerc++") + SET (PLAYERCPP_LIBRARY_DIRS @PLAYERCC_EXTRA_LINK_DIRS@) + LIST (APPEND PLAYERCPP_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib") + SET (PLAYERCPP_LINK_FLAGS "") ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERCPP playerc++) - IF (NOT PLAYERCPP_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc++ with pkg-config.") - ENDIF (NOT PLAYERCPP_FOUND) + pkg_check_modules (PLAYERCPP_PKG REQUIRED playerc++) + IF (PLAYERCPP_PKG_CFLAGS_OTHER) + LIST_TO_STRING (PLAYERCPP_CFLAGS "${PLAYERCPP_PKG_CFLAGS_OTHER}") + ELSE (PLAYERCPP_PKG_CFLAGS_OTHER) + SET (PLAYERCPP_CFLAGS "") + ENDIF (PLAYERCPP_PKG_CFLAGS_OTHER) + SET (PLAYERCPP_INCLUDE_DIRS ${PLAYERCPP_PKG_INCLUDE_DIRS}) + SET (PLAYERCPP_LINK_LIBS ${PLAYERCPP_PKG_LIBRARIES}) + SET (PLAYERCPP_LIBRARY_DIRS ${PLAYERCPP_PKG_LIBRARY_DIRS}) + IF (PLAYERCPP_PKG_LDFLAGS_OTHER) + LIST_TO_STRING (PLAYERCPP_LINK_FLAGS ${PLAYERCPP_PKG_LDFLAGS_OTHER}) + ELSE (PLAYERCPP_PKG_LDFLAGS_OTHER) + SET (PLAYERCPP_LINK_FLAGS "") + ENDIF (PLAYERCPP_PKG_LDFLAGS_OTHER) ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERCPP_CFLAGS_STR "${PLAYERCPP_CFLAGS}") -LIST_TO_STRING (PLAYERCPP_LDFLAGS_STR "${PLAYERCPP_LDFLAGS}") ############################################################################### @@ -27,7 +45,7 @@ # See the examples directory (typically, ${prefix}/share/player/examples) for # example CMakeLists.txt files. MACRO (PLAYER_ADD_PLAYERCPP_CLIENT _clientName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLAYERCPP_CLIENT: ${_junk}") ENDIF (_junk) @@ -42,23 +60,34 @@ ADD_EXECUTABLE (${_clientName} ${_srcs}) SET_TARGET_PROPERTIES (${_clientName} PROPERTIES - LINK_FLAGS ${PLAYERCPP_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERCPP_LIBDIR} + INSTALL_RPATH ${PLAYERCPP_LIBRARY_DIRS} BUILD_WITH_INSTALL_RPATH TRUE) + IF (_linkFlags) + SET_TARGET_PROPERTIES (${_clientName} PROPERTIES LINK_FLAGS ${_linkFlags}) + ENDIF (_linkFlags) + IF (PLAYERCPP_LINK_FLAGS) + SET_TARGET_PROPERTIES (${_clientName} PROPERTIES LINK_FLAGS ${PLAYERCPP_LINK_FLAGS}) + ENDIF (PLAYERCPP_LINK_FLAGS) + IF (_linkLibs) + TARGET_LINK_LIBRARIES (${_clientName} ${_linkLibs}) + ENDIF (_linkLibs) + IF (PLAYERCPP_LINK_LIBS) + TARGET_LINK_LIBRARIES (${_clientName} ${PLAYERCPP_LINK_LIBS}) + ENDIF (PLAYERCPP_LINK_LIBS) # Get the current cflags for each source file, and add the global ones # (this allows the user to specify individual cflags for each source file # without the global ones overriding them). - IF (PLAYERCPP_CFLAGS_STR OR _cFlags) + IF (PLAYERCPP_CFLAGS OR _cFlags) FOREACH (_file ${_srcs}) GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERCPP_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${PLAYERCPP_CFLAGS} ${_cFlags}") ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERCPP_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${_fileCFlags} ${PLAYERCPP_CFLAGS} ${_cFlags}") ENDIF (_fileCFlags STREQUAL NOTFOUND) SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES COMPILE_FLAGS ${_newCFlags}) ENDFOREACH (_file) - ENDIF (PLAYERCPP_CFLAGS_STR OR _cFlags) + ENDIF (PLAYERCPP_CFLAGS OR _cFlags) ENDMACRO (PLAYER_ADD_PLAYERCPP_CLIENT) Modified: code/player/trunk/cmake/UsePlayerC.cmake.in =================================================================== --- code/player/trunk/cmake/UsePlayerC.cmake.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/UsePlayerC.cmake.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,21 +1,39 @@ CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) +IF (COMMAND CMAKE_POLICY) + CMAKE_POLICY (SET CMP0003 NEW) +ENDIF (COMMAND CMAKE_POLICY) + INCLUDE (PlayerUtils) INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - SET (PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") - SET (PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib" "-lplayerc") + SET (PLAYERC_CFLAGS "") + SET (PLAYERC_INCLUDE_DIRS @PLAYERC_EXTRA_INCLUDE_DIRS@) + LIST (APPEND PLAYERC_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLAYERC_LINK_LIBS @PLAYERC_EXTRA_LINK_LIBRARIES@) + LIST (APPEND PLAYERC_LINK_LIBS "playerc") + SET (PLAYERC_LIBRARY_DIRS @PLAYERC_EXTRA_LINK_DIRS@) + LIST (APPEND PLAYERC_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib") + SET (PLAYERC_LINK_FLAGS "") ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERC playerc) - IF (NOT PLAYERC_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc with pkg-config.") - ENDIF (NOT PLAYERC_FOUND) + pkg_check_modules (PLAYERC_PKG REQUIRED playerc) + IF (PLAYERC_PKG_CFLAGS_OTHER) + LIST_TO_STRING (PLAYERC_CFLAGS "${PLAYERC_PKG_CFLAGS_OTHER}") + ELSE (PLAYERC_PKG_CFLAGS_OTHER) + SET (PLAYERC_CFLAGS_OTHER "") + ENDIF (PLAYERC_PKG_CFLAGS_OTHER) + SET (PLAYERC_INCLUDE_DIRS ${PLAYERC_PKG_INCLUDE_DIRS}) + SET (PLAYERC_LINK_LIBS ${PLAYERC_PKG_LIBRARIES}) + SET (PLAYERC_LIBRARY_DIRS ${PLAYERC_PKG_LIBRARY_DIRS}) + IF (PLAYERC_PKG_LDFLAGS_OTHER) + LIST_TO_STRING (PLAYERC_LINK_FLAGS ${PLAYERC_PKG_LDFLAGS_OTHER}) + ELSE (PLAYERC_PKG_LDFLAGS_OTHER) + SET (PLAYERC_LINK_FLAGS "") + ENDIF (PLAYERC_PKG_LDFLAGS_OTHER) ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERC_CFLAGS_STR "${PLAYERC_CFLAGS}") -LIST_TO_STRING (PLAYERC_LDFLAGS_STR "${PLAYERC_LDFLAGS}") -############################################################################## +############################################################################### # Macro to build a simple client. # _clientName: The name of the executable to create # Pass source files, flags, etc. as extra args preceded by keywords as follows: @@ -27,7 +45,7 @@ # See the examples directory (typically, ${prefix}/share/player/examples) for # example CMakeLists.txt files. MACRO (PLAYER_ADD_PLAYERC_CLIENT _clientName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFLags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLAYERC_CLIENT: ${_junk}") ENDIF (_junk) @@ -42,23 +60,34 @@ ADD_EXECUTABLE (${_clientName} ${_srcs}) SET_TARGET_PROPERTIES (${_clientName} PROPERTIES - LINK_FLAGS ${PLAYERC_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERC_LIBDIR} + INSTALL_RPATH ${PLAYERC_LIBRARY_DIRS} BUILD_WITH_INSTALL_RPATH TRUE) + IF (PLAYERC_LINK_FLAGS) + SET_TARGET_PROPERTIES (${_clientName} PROPERTIES LINK_FLAGS ${PLAYERC_LINK_FLAGS}) + ENDIF (PLAYERC_LINK_FLAGS) + IF (_linkFlags) + SET_TARGET_PROPERTIES (${_clientName} PROPERTIES LINK_FLAGS ${_linkFlags}) + ENDIF (_linkFlags) + IF (_linkLibs) + TARGET_LINK_LIBRARIES (${_clientName} ${_linkLibs}) + ENDIF (_linkLibs) + IF (PLAYERC_LINK_LIBS) + TARGET_LINK_LIBRARIES (${_clientName} ${PLAYERC_LINK_LIBS}) + ENDIF (PLAYERC_LINK_LIBS) # Get the current cflags for each source file, and add the global ones # (this allows the user to specify individual cflags for each source file # without the global ones overriding them). - IF (PLAYERC_CFLAGS_STR OR _cFLags) + IF (PLAYERC_CFLAGS OR _cFLags) FOREACH (_file ${_srcs}) GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERC_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${PLAYERC_CFLAGS} ${_cFlags}") ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERC_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${_fileCFlags} ${PLAYERC_CFLAGS} ${_cFlags}") ENDIF (_fileCFlags STREQUAL NOTFOUND) SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES COMPILE_FLAGS ${_newCFlags}) ENDFOREACH (_file) - ENDIF (PLAYERC_CFLAGS_STR OR _cFLags) + ENDIF (PLAYERC_CFLAGS OR _cFLags) ENDMACRO (PLAYER_ADD_PLAYERC_CLIENT) Modified: code/player/trunk/cmake/UsePlayerPlugin.cmake.in =================================================================== --- code/player/trunk/cmake/UsePlayerPlugin.cmake.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/UsePlayerPlugin.cmake.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,31 +1,63 @@ CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) +IF (COMMAND CMAKE_POLICY) + CMAKE_POLICY (SET CMP0003 NEW) +ENDIF (COMMAND CMAKE_POLICY) + INCLUDE (PlayerUtils) INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - SET (PLUGIN_PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") - SET (PLUGIN_PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib" "-lplayerc") + SET (PLUGIN_PLAYERC_CFLAGS "") + SET (PLUGIN_PLAYERC_INCLUDE_DIRS @PLAYERC_EXTRA_INCLUDE_DIRS@) + LIST (APPEND PLUGIN_PLAYERC_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLUGIN_PLAYERC_LINK_LIBS @PLAYERC_EXTRA_LINK_LIBRARIES@) + LIST (APPEND PLUGIN_PLAYERC_LINK_LIBS "playerc") + SET (PLUGIN_PLAYERC_LIBRARY_DIRS @PLAYERC_EXTRA_LINK_DIRS@) + LIST (APPEND PLUGIN_PLAYERC_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib") + SET (PLUGIN_PLAYERC_LINK_FLAGS "") ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLUGIN_PLAYERC playerc) - IF (NOT PLUGIN_PLAYERC_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc with pkg-config.") - ENDIF (NOT PLUGIN_PLAYERC_FOUND) + pkg_check_modules (PLUGIN_PLAYERC_PKG REQUIRED playerc) + IF (PLUGIN_PLAYERC_PKG_CFLAGS_OTHER) + LIST_TO_STRING (PLUGIN_PLAYERC_CFLAGS "${PLUGIN_PLAYERC_PKG_CFLAGS_OTHER}") + ELSE (PLUGIN_PLAYERC_PKG_CFLAGS_OTHER) + SET (PLUGIN_PLAYERC_CFLAGS_OTHER "") + ENDIF (PLUGIN_PLAYERC_PKG_CFLAGS_OTHER) + SET (PLUGIN_PLAYERC_INCLUDE_DIRS ${PLUGIN_PLAYERC_PKG_INCLUDE_DIRS}) + SET (PLUGIN_PLAYERC_LINK_LIBS ${PLUGIN_PLAYERC_PKG_LIBRARIES}) + SET (PLUGIN_PLAYERC_LIBRARY_DIRS ${PLUGIN_PLAYERC_PKG_LIBRARY_DIRS}) + IF (PLUGIN_PLAYERC_PKG_LDFLAGS_OTHER) + LIST_TO_STRING (PLUGIN_PLAYERC_LINK_FLAGS ${PLUGIN_PLAYERC_PKG_LDFLAGS_OTHER}) + ELSE (PLUGIN_PLAYERC_PKG_LDFLAGS_OTHER) + SET (PLUGIN_PLAYERC_LINK_FLAGS "") + ENDIF (PLUGIN_PLAYERC_PKG_LDFLAGS_OTHER) ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLUGIN_PLAYERC_CFLAGS_STR "${PLUGIN_PLAYERC_CFLAGS}") -LIST_TO_STRING (PLUGIN_PLAYERC_LDFLAGS_STR "${PLUGIN_PLAYERC_LDFLAGS}") INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - SET (PLAYERCORE_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") - SET (PLAYERCORE_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib -lplayercore @corePCLibs@") + SET (PLAYERCORE_CFLAGS "") + SET (PLAYERCORE_INCLUDE_DIRS @PLAYERCORE_EXTRA_INCLUDE_DIRS@) + LIST (APPEND PLAYERCORE_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLAYERCORE_LINK_LIBS @PLAYERCORE_EXTRA_LINK_LIBRARIES@) + LIST (APPEND PLAYERCORE_LINK_LIBS "playercore") + SET (PLAYERCORE_LIBRARY_DIRS @PLAYERCORE_EXTRA_LINK_DIRS@) + LIST (APPEND PLAYERCORE_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib") + SET (PLAYERCORE_LINK_FLAGS "") ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERCORE playercore) - IF (NOT PLAYERCORE_FOUND) - MESSAGE (FATAL_ERROR "Could not find playercore with pkg-config.") - ENDIF (NOT PLAYERCORE_FOUND) + pkg_check_modules (PLAYERCORE_PKG REQUIRED playercore) + IF (PLAYERCORE_PKG_CFLAGS_OTHER) + LIST_TO_STRING (PLAYERCORE_CFLAGS "${PLAYERCORE_PKG_CFLAGS_OTHER}") + ELSE (PLAYERCORE_PKG_CFLAGS_OTHER) + SET (PLAYERCORE_CFLAGS "") + ENDIF (PLAYERCORE_PKG_CFLAGS_OTHER) + SET (PLAYERCORE_INCLUDE_DIRS ${PLAYERCORE_PKG_INCLUDE_DIRS}) + SET (PLAYERCORE_LINK_LIBS ${PLAYERCORE_PKG_LIBRARIES}) + SET (PLAYERCORE_LIBRARY_DIRS ${PLAYERCORE_PKG_LIBRARY_DIRS}) + IF (PLAYERCORE_PKG_LDFLAGS_OTHER) + LIST_TO_STRING (PLAYERCORE_LINK_FLAGS ${PLAYERCORE_PKG_LDFLAGS_OTHER}) + ELSE (PLAYERCORE_PKG_LDFLAGS_OTHER) + SET (PLAYERCORE_LINK_FLAGS "") + ENDIF (PLAYERCORE_PKG_LDFLAGS_OTHER) ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERCORE_CFLAGS_STR "${PLAYERCORE_CFLAGS}") -LIST_TO_STRING (PLAYERCORE_LDFLAGS_STR "${PLAYERCORE_LDFLAGS}") # This is slightly different from the one used by the Player build system itself. @@ -59,7 +91,7 @@ # See the examples directory (typically, ${prefix}/share/player/examples) for # example CMakeLists.txt files. MACRO (PLAYER_ADD_PLUGIN_DRIVER _driverName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_DRIVER: ${_junk}") ENDIF (_junk) @@ -74,25 +106,36 @@ ADD_LIBRARY (${_driverName} SHARED ${_srcs}) SET_TARGET_PROPERTIES (${_driverName} PROPERTIES - LINK_FLAGS ${PLAYERCORE_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERCORE_LIBDIR} + INSTALL_RPATH ${PLAYERCORE_LIBRARY_DIRS} BUILD_WITH_INSTALL_RPATH TRUE) + IF (_linkFlags) + SET_TARGET_PROPERTIES (${_driverName} PROPERTIES LINK_FLAGS ${_linkFlags}) + ENDIF (_linkFlags) + IF (PLAYERCORE_LINK_FLAGS) + SET_TARGET_PROPERTIES (${_driverName} PROPERTIES LINK_FLAGS ${PLAYERCORE_LINK_FLAGS}) + ENDIF (PLAYERCORE_LINK_FLAGS) + IF (_linkLibs) + TARGET_LINK_LIBRARIES (${_driverName} ${_linkLibs}) + ENDIF (_linkLibs) + IF (PLAYERCORE_LINK_LIBS) + TARGET_LINK_LIBRARIES (${_driverName} ${PLAYERCORE_LINK_LIBS}) + ENDIF (PLAYERCORE_LINK_LIBS) # Get the current cflags for each source file, and add the global ones # (this allows the user to specify individual cflags for each source file # without the global ones overriding them). - IF (PLAYERCORE_CFLAGS_STR OR _cFLags) + IF (PLAYERCORE_CFLAGS OR _cFLags) FOREACH (_file ${_srcs}) GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERCORE_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${PLAYERCORE_CFLAGS} ${_cFlags}") ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERCORE_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${_fileCFlags} ${PLAYERCORE_CFLAGS} ${_cFlags}") ENDIF (_fileCFlags STREQUAL NOTFOUND) SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES COMPILE_FLAGS ${_newCFlags}) ENDFOREACH (_file) - ENDIF (PLAYERCORE_CFLAGS_STR OR _cFLags) + ENDIF (PLAYERCORE_CFLAGS OR _cFLags) ENDMACRO (PLAYER_ADD_PLUGIN_DRIVER) @@ -117,16 +160,16 @@ MESSAGE (FATAL_ERROR "No Python interpreter found. Cannot continue.") ENDIF (NOT PYTHONINTERP_FOUND) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_INTERFACE: ${_junk}") ENDIF (_junk) LIST_TO_STRING (_cFlags "${_cFlags}") - IF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) - INCLUDE_DIRECTORIES (${_includeDirs} ${PLUGIN_PLAYERC_INC_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - ENDIF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) + IF (_includeDirs OR PLUGIN_PLAYERC_INCLUDE_DIRS) + INCLUDE_DIRECTORIES (${_includeDirs} ${PLUGIN_PLAYERC_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) + ENDIF (_includeDirs OR PLUGIN_PLAYERC_INCLUDE_DIRS) IF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) LINK_DIRECTORIES (${_libDirs} ${PLUGIN_PLAYERC_LIBRARY_DIRS}) ENDIF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) @@ -136,32 +179,47 @@ PROCESS_INTERFACES (${_interfDef} ${interface_h} --plugin) SET (functiontable_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_functiontable.c) PROCESS_INTERFACES (${_interfDef} ${functiontable_c} --plugin --functiontable) - SET_SOURCE_FILES_PROPERTIES (${functiontable_c} PROPERTIES - COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) + IF (PLUGIN_PLAYERC_CFLAGS) + SET_SOURCE_FILES_PROPERTIES (${functiontable_c} PROPERTIES + COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS}) + ENDIF (PLUGIN_PLAYERC_CFLAGS) SET (xdr_h ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.h) SET (xdr_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.c) PROCESS_XDR (${interface_h} ${xdr_h} ${xdr_c}) - SET_SOURCE_FILES_PROPERTIES (${xdr_c} PROPERTIES COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) + IF (PLUGIN_PLAYERC_CFLAGS) + SET_SOURCE_FILES_PROPERTIES (${xdr_c} PROPERTIES COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS}) + ENDIF (PLUGIN_PLAYERC_CFLAGS) ADD_LIBRARY (${_interfName} SHARED ${interface_h} ${functiontable_c} ${xdr_h} ${xdr_c} ${_srcs}) SET_TARGET_PROPERTIES (${_interfName} PROPERTIES - LINK_FLAGS ${PLUGIN_PLAYERC_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLUGIN_PLAYERC_LIBDIR} + INSTALL_RPATH ${PLUGIN_PLAYERC_LIBRARY_DIRS} BUILD_WITH_INSTALL_RPATH TRUE) + IF (_linkFlags) + SET_TARGET_PROPERTIES (${_interfName} PROPERTIES LINK_FLAGS ${_linkFlags}) + ENDIF (_linkFlags) + IF (PLUGIN_PLAYERC_LINK_FLAGS) + SET_TARGET_PROPERTIES (${_interfName} PROPERTIES LINK_FLAGS ${PLUGIN_PLAYERC_LINK_FLAGS}) + ENDIF (PLUGIN_PLAYERC_LINK_FLAGS) + IF (_linkLibs) + TARGET_LINK_LIBRARIES (${_interfName} ${_linkLibs}) + ENDIF (_linkLibs) + IF (PLUGIN_PLAYERC_LINK_LIBS) + TARGET_LINK_LIBRARIES (${_interfName} ${PLUGIN_PLAYERC_LINK_LIBS}) + ENDIF (PLUGIN_PLAYERC_LINK_LIBS) # Get the current cflags for each source file, and add the global ones # (this allows the user to specify individual cflags for each source file # without the global ones overriding them). - IF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) + IF (PLUGIN_PLAYERC_CFLAGS OR _cFLags) FOREACH (_file ${_srcs}) GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${PLUGIN_PLAYERC_CFLAGS} ${_cFlags}") ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") + SET (_newCFlags "${_fileCFlags} ${PLUGIN_PLAYERC_CFLAGS} ${_cFlags}") ENDIF (_fileCFlags STREQUAL NOTFOUND) SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES COMPILE_FLAGS ${_newCFlags}) ENDFOREACH (_file) - ENDIF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) + ENDIF (PLUGIN_PLAYERC_CFLAGS OR _cFLags) ENDMACRO (PLAYER_ADD_PLUGIN_INTERFACE) Modified: code/player/trunk/cmake/internal/DriverUtils.cmake =================================================================== --- code/player/trunk/cmake/internal/DriverUtils.cmake 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/internal/DriverUtils.cmake 2009-04-08 08:20:15 UTC (rev 7586) @@ -14,6 +14,7 @@ SET (PLAYER_DRIVERSLIB_SOURCES_MAP_DESC "Source files for libplayerdrivers") SET (PLAYER_DRIVERSLIB_INCLUDEDIRS_DESC "Include dirs for libplayerdrivers") SET (PLAYER_DRIVERSLIB_LIBDIRS_DESC "Lib dirs for libplayerdrivers") +SET (PLAYER_DRIVERSLIB_LINKLIBS_DESC "Libraries for libplayerdrivers") SET (PLAYER_DRIVERSLIB_LINKFLAGS_DESC "Link flags for libplayerdrivers") SET (PLAYER_DRIVERSLIB_CFLAGS_DESC "Compile flags for libplayerdrivers") SET (PLAYER_NOT_BUILT_DRIVERS_DESC "List of drivers that will not be built") @@ -32,7 +33,7 @@ # CFLAGS <compile flags list> MACRO (PLAYERDRIVER_ADD_DRIVER _name _cumulativeVar) IF (${_cumulativeVar}) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: Unkeyworded arguments found in PLAYERDRIVER_ADD_DRIVER: ${_junk}") ENDIF (_junk) @@ -41,7 +42,7 @@ MESSAGE (STATUS "WARNING: No sources given for driver ${_name}") ENDIF (NOT _srcs) # Add this driver's list of sources to the list of sources for libplayerdrivers - PLAYERDRIVER_ADD_TO_BUILT (${_name} "${_includeDirs}" "${_libDir}" "${_linkFlags}" "${_cFlags}" ${_srcs}) + PLAYERDRIVER_ADD_TO_BUILT (${_name} "${_includeDirs}" "${_libDirs}" "${_linkLibs}" "${_linkFlags}" "${_cFlags}" ${_srcs}) ENDIF (${_cumulativeVar}) ENDMACRO (PLAYERDRIVER_ADD_DRIVER) @@ -56,13 +57,13 @@ # LINKFLAGS <link flags list> # CFLAGS <compile flags list> MACRO (PLAYERDRIVER_ADD_EXTRA _name) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkLibs _linkFlags _cFlags _junk ${ARGN}) IF (_junk) MESSAGE (STATUS "WARNING: Unkeyworded arguments found in PLAYERDRIVER_ADD_EXTRA: ${_junk}") ENDIF (_junk) LIST_TO_STRING (_cFlags "${_cFlags}") # Add the list of sources to the list of sources for libplayerdrivers, and add various flags - PLAYERDRIVER_ADD_EXTRA_TO_BUILT (${_name} "${_includeDir}" "${_libDir}" "${_linkFlags}" "${_cFlags}" ${_srcs}) + PLAYERDRIVER_ADD_EXTRA_TO_BUILT (${_name} "${_includeDir}" "${_libDirs}" "${_linkLibs}" "${_linkFlags}" "${_cFlags}" ${_srcs}) ENDMACRO (PLAYERDRIVER_ADD_EXTRA) @@ -150,7 +151,7 @@ ############################################################################### -# PLAYERDRIVER_REQUIRE_PKG (_name _cumulativeVar _package _includeDir _libDir _linkFlags _cFlags [_version]) +# PLAYERDRIVER_REQUIRE_PKG (_name _cumulativeVar _package _includeDirs _libDirs _linkLibs _linkFlags _cFlags [_version]) # Check if a required package is available. # If a minimum version is required, supply it as an optional argument with no spaces. For example, # ">=0.9.6". @@ -160,7 +161,7 @@ # the driver has been enabled. # _package: Name (and possibly version) of the package to look for. INCLUDE (FindPkgConfig) -MACRO (PLAYERDRIVER_REQUIRE_PKG _name _cumulativeVar _package _includeDir _libDir _linkFlags _cFlags) +MACRO (PLAYERDRIVER_REQUIRE_PKG _name _cumulativeVar _package _includeDirs _libDirs _linkLibs _linkFlags _cFlags) IF (NOT PKG_CONFIG_FOUND) MESSAGE (STATUS "Could not find pkg-config; cannot search for ${_package} for driver ${_name}.") IF (${_cumulativeVar}) @@ -186,7 +187,8 @@ APPEND_TO_CACHED_LIST (PLAYERDRIVER_HAVE_DEFINES ${PLAYERDRIVER_HAVE_DEFINES_DESC} "HAVE_PKG_${_packageNameUpper}") # Set the values SET (${_includeDir} ${${_pkgVar}_INCLUDE_DIRS}) - SET (${_libDir} ${${_pkgVar}_LIBRARY_DIRS}) + SET (${_libDirs} ${${_pkgVar}_LIBRARY_DIRS}) + SET (${_linkLibs} ${${_pkgVar}_LIBRARIES}) LIST_TO_STRING (${_cFlags} "${${_pkgVar}_CFLAGS}") LIST_TO_STRING (${_linkFlags} "${${_pkgVar}_LDFLAGS}") ELSEIF (${_cumulativeVar}) @@ -395,7 +397,7 @@ ############################################################################### # Add a driver to the list of drivers to be built. -MACRO (PLAYERDRIVER_ADD_TO_BUILT _name _includeDir _libDir _linkFlags _cFlags) +MACRO (PLAYERDRIVER_ADD_TO_BUILT _name _includeDir _libDirs _linkLibs _linkFlags _cFlags) # Source files go into a map so we can set the cflags on them later on SET (tempList) FOREACH (sourceFile ${ARGN}) @@ -411,7 +413,8 @@ # Append the various build options APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_INCLUDEDIRS ${PLAYER_DRIVERSLIB_INCLUDEDIRS_DESC} ${_includeDir}) - APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LIBDIRS ${PLAYER_DRIVERSLIB_LIBDIRS_DESC} ${_libDir}) + APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LIBDIRS ${PLAYER_DRIVERSLIB_LIBDIRS_DESC} ${_libDirs}) + APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LINKLIBS ${PLAYER_DRIVERSLIB_LINKLIBS_DESC} ${_linkLibs}) # APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LINKFLAGS ${PLAYER_DRIVERSLIB_LINKFLAGS_DESC} ${_linkFlags}) SET (PLAYER_DRIVERSLIB_LINKFLAGS "${PLAYER_DRIVERSLIB_LINKFLAGS} ${_linkFlags}" CACHE INTERNAL ${PLAYER_DRIVERSLIB_LINKFLAGS_DESC} FORCE) # C flags go into a map indexed by name because they're driver-specific @@ -424,7 +427,7 @@ ############################################################################### # Add some extra code to playerdrivers. -MACRO (PLAYERDRIVER_ADD_EXTRA_TO_BUILT _name _includeDir _libDir _linkFlags _cFlags) +MACRO (PLAYERDRIVER_ADD_EXTRA_TO_BUILT _name _includeDir _libDirs _linkLibs _linkFlags _cFlags) # Source files go into a map so we can set the cflags on them later on SET (tempList) FOREACH (sourceFile ${ARGN}) @@ -434,7 +437,8 @@ # Append the various build options APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_INCLUDEDIRS ${PLAYER_DRIVERSLIB_INCLUDEDIRS_DESC} ${_includeDir}) - APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LIBDIRS ${PLAYER_DRIVERSLIB_LIBDIRS_DESC} ${_libDir}) + APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LIBDIRS ${PLAYER_DRIVERSLIB_LIBDIRS_DESC} ${_libDirs}) + APPEND_TO_CACHED_LIST (PLAYER_DRIVERSLIB_LINKLIBS ${PLAYER_DRIVERSLIB_LINKLIBS_DESC} ${_linkLibs}) SET (PLAYER_DRIVERSLIB_LINKFLAGS "${PLAYER_DRIVERSLIB_LINKFLAGS} ${_linkFlags}" CACHE INTERNAL ${PLAYER_DRIVERSLIB_LINKFLAGS_DESC} FORCE) # C flags go into a map indexed by name because they're driver-specific INSERT_INTO_GLOBAL_MAP (PLAYER_DRIVERSLIB_CFLAGS ${_name} "${_cFlags}") @@ -493,6 +497,7 @@ SET (PLAYER_DRIVERSLIB_SOURCES_MAP "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_SOURCES_MAP_DESC} FORCE) SET (PLAYER_DRIVERSLIB_INCLUDEDIRS "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_INCLUDEDIRS_DESC} FORCE) SET (PLAYER_DRIVERSLIB_LIBDIRS "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_LIBDIRS_DESC} FORCE) + SET (PLAYER_DRIVERSLIB_LINKLIBS "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_LINKLIBS_DESC} FORCE) SET (PLAYER_DRIVERSLIB_LINKFLAGS "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_LINKFLAGS_DESC} FORCE) SET (PLAYER_DRIVERSLIB_CFLAGS "" CACHE INTERNAL ${PLAYER_DRIVERSLIB_CFLAGS_DESC} FORCE) Modified: code/player/trunk/cmake/internal/LibraryUtils.cmake =================================================================== --- code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-04-08 08:20:15 UTC (rev 7586) @@ -55,13 +55,63 @@ ############################################################################### -# PLAYER_ADD_LINK_LIB (library1 [library2 ...]) +# PLAYERCORE_ADD_INT_INCLUDE_DIR (dir1 [dir2 ...]) +# Add include directories for the core libraries. +MACRO (PLAYERCORE_ADD_INT_INCLUDE_DIR) + SET (tempList ${PLAYERCORE_INT_INCLUDE_DIRS}) + LIST (APPEND tempList ${ARGN}) + SET (PLAYERCORE_INT_INCLUDE_DIRS ${tempList} CACHE INTERNAL "Extra include directories for playercore" FORCE) +ENDMACRO (PLAYERCORE_ADD_INT_INCLUDE_DIR) + + +############################################################################### +# PLAYERCORE_ADD_INT_LINK_DIR (dir1 [dir2 ...]) +# Add link directories for the core libraries. +MACRO (PLAYERCORE_ADD_INT_LINK_DIR) + SET (tempList ${PLAYERCORE_INT_LINK_DIRS}) + LIST (APPEND tempList ${ARGN}) + SET (PLAYERCORE_INT_LINK_DIRS ${tempList} CACHE INTERNAL "Library directories to link playercore to" FORCE) +ENDMACRO (PLAYERCORE_ADD_INT_LINK_DIR) + + +############################################################################### +# PLAYERCORE_ADD_INT_LINK_LIB (library1 [library2 ...]) +# Add libraries to the link line for the core libraries. +MACRO (PLAYERCORE_ADD_INT_LINK_LIB) + SET (tempList ${PLAYERCORE_INT_LINK_LIBRARIES}) + LIST (APPEND tempList ${ARGN}) + SET (PLAYERCORE_INT_LINK_LIBRARIES ${tempList} CACHE INTERNAL "Libs to link playercore to" FORCE) +ENDMACRO (PLAYERCORE_ADD_INT_LINK_LIB) + + +############################################################################### +# PLAYERCORE_ADD_INCLUDE_DIR (dir1 [dir2 ...]) +# Add include directories for stuff that uses the core libraries. +MACRO (PLAYERCORE_ADD_INCLUDE_DIR) + SET (tempList ${PLAYERCORE_EXTRA_INCLUDE_DIRS}) + LIST (APPEND tempList ${ARGN}) + SET (PLAYERCORE_EXTRA_INCLUDE_DIRS ${tempList} CACHE INTERNAL "Extra include directories with playercore" FORCE) +ENDMACRO (PLAYERCORE_ADD_INCLUDE_DIR) + + +############################################################################### +# PLAYERCORE_ADD_LINK_DIR (dir1 [dir2 ...]) +# Add link directories for stuff that links to the core libraries. +MACRO (PLAYERCORE_ADD_LINK_DIR) + SET (tempList ${PLAYERCORE_EXTRA_LINK_DIRS}) + LIST (APPEND tempList ${ARGN}) + SET (PLAYERCORE_EXTRA_LINK_DIRS ${tempList} CACHE INTERNAL "Library directories to link in with playercore" FORCE) +ENDMACRO (PLAYERCORE_ADD_LINK_DIR) + + +############################################################################### +# PLAYERCORE_ADD_LINK_LIB (library1 [library2 ...]) # Add libraries to the link line for stuff that links to the core libraries. -MACRO (PLAYER_ADD_LINK_LIB) - SET (tempList ${PLAYER_EXTRA_LINK_LIBRARIES}) +MACRO (PLAYERCORE_ADD_LINK_LIB) + SET (tempList ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) LIST (APPEND tempList ${ARGN}) - SET (PLAYER_EXTRA_LINK_LIBRARIES ${tempList} CACHE INTERNAL "Libs to link to" FORCE) -ENDMACRO (PLAYER_ADD_LINK_LIB) + SET (PLAYERCORE_EXTRA_LINK_LIBRARIES ${tempList} CACHE INTERNAL "Libs to link to with playercore" FORCE) +ENDMACRO (PLAYERCORE_ADD_LINK_LIB) ############################################################################### Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-04-08 08:20:15 UTC (rev 7586) @@ -139,23 +139,22 @@ # we have to unseparate the flags back into strings so they can be passed to the # SET_x_PROPERTIES functions properly. Change the LIST_TO_STRING to SET and make with # VERBOSE=1 to see the mess that happens otherwise. - LIST_TO_STRING (GNOMECANVAS_LINKFLAGS "${GNOMECANVAS_PKG_LDFLAGS}") - LIST_TO_STRING (GNOMECANVAS_CFLAGS "${GNOMECANVAS_PKG_CFLAGS}") + LIST_TO_STRING (GNOMECANVAS_LINKFLAGS "${GNOMECANVAS_PKG_LDFLAGS_OTHER}") + LIST_TO_STRING (GNOMECANVAS_CFLAGS "${GNOMECANVAS_PKG_CFLAGS_OTHER}") ENDIF (GNOMECANVAS_PKG_FOUND) pkg_check_modules (GTK_PKG gtk+-2.0) IF (GTK_PKG_FOUND) SET (WITH_GTK TRUE) - SET (GTK_INCLUDEDIR ${GTK_PKG_INCLUDE_DIRS}) - LIST_TO_STRING (GTK_LINKFLAGS "${GTK_PKG_LDFLAGS}") - LIST_TO_STRING (GTK_CFLAGS "${GTK_PKG_CFLAGS}") + LIST_TO_STRING (GTK_LINKFLAGS "${GTK_PKG_LDFLAGS_OTHER}") + LIST_TO_STRING (GTK_CFLAGS "${GTK_PKG_CFLAGS_OTHER}") ENDIF (GTK_PKG_FOUND) pkg_check_modules (GDKPIXBUF_PKG gdk-pixbuf-2.0) IF (GDKPIXBUF_PKG_FOUND) SET (WITH_GDKPIXBUF TRUE) - LIST_TO_STRING (GDKPIXBUF_LINKFLAGS "${GDKPIXBUF_PKG_LDFLAGS}") - LIST_TO_STRING (GDKPIXBUF_CFLAGS "${GDKPIXBUF_PKG_CFLAGS}") + LIST_TO_STRING (GDKPIXBUF_LINKFLAGS "${GDKPIXBUF_PKG_LDFLAGS_OTHER}") + LIST_TO_STRING (GDKPIXBUF_CFLAGS "${GDKPIXBUF_PKG_CFLAGS_OTHER}") ENDIF (GDKPIXBUF_PKG_FOUND) ENDIF (NOT PKG_CONFIG_FOUND) Modified: code/player/trunk/examples/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/examples/libplayerc/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/libplayerc/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,4 +1,4 @@ -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${GTK_INCLUDEDIR}) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs) ADD_EXECUTABLE (vmap vmap.c) TARGET_LINK_LIBRARIES (vmap playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) Modified: code/player/trunk/examples/libplayerc/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/libplayerc/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/libplayerc/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerc_examples) # Include this CMake module to get most of the settings needed to build @@ -8,4 +9,4 @@ PLAYER_ADD_PLAYERC_CLIENT (vmap SOURCES vmap.c) -PLAYER_ADD_PLAYERC_CLIENT (speech_c_client SOURCES speech_c_client.c) \ No newline at end of file +PLAYER_ADD_PLAYERC_CLIENT (speech_c_client SOURCES speech_c_client.c) Modified: code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerc++_examples) # Include this CMake module to get most of the settings needed to build @@ -33,4 +34,4 @@ IF (HAVE_BOOST_SIGNALS) PLAYER_ADD_PLAYERCPP_CLIENT (example2 SOURCES example2.cc) -ENDIF (HAVE_BOOST_SIGNALS) \ No newline at end of file +ENDIF (HAVE_BOOST_SIGNALS) Modified: code/player/trunk/examples/plugins/exampledriver/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/plugins/exampledriver/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/plugins/exampledriver/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerplugin_examples) # Include this CMake module to get most of the settings needed to build @@ -4,4 +5,4 @@ SET (CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules) INCLUDE (UsePlayerPlugin) -PLAYER_ADD_PLUGIN_DRIVER (exampledriver SOURCES exampledriver.cc) \ No newline at end of file +PLAYER_ADD_PLUGIN_DRIVER (exampledriver SOURCES exampledriver.cc) Modified: code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerplugin_examples) # Include this CMake module to get most of the settings needed to build @@ -10,4 +11,4 @@ # Note the use of files generated during the PLAYER_ADD_PLUGIN_INTERFACE step PLAYER_ADD_PLUGIN_DRIVER (example_driver SOURCES eginterf_driver.cc example_interface.h example_xdr.h) PLAYER_ADD_PLAYERC_CLIENT (example_client SOURCES example_client.c example_interface.h) -TARGET_LINK_LIBRARIES (example_client example) \ No newline at end of file +TARGET_LINK_LIBRARIES (example_client example) Modified: code/player/trunk/examples/plugins/multidriver/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/plugins/multidriver/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/plugins/multidriver/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerplugin_examples) # Include this CMake module to get most of the settings needed to build @@ -4,4 +5,4 @@ SET (CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules) INCLUDE (UsePlayerPlugin) -PLAYER_ADD_PLUGIN_DRIVER (multidriver SOURCES multidriver.cc) \ No newline at end of file +PLAYER_ADD_PLUGIN_DRIVER (multidriver SOURCES multidriver.cc) Modified: code/player/trunk/examples/plugins/opaquedriver/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/plugins/opaquedriver/CMakeLists.txt.example.in 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/examples/plugins/opaquedriver/CMakeLists.txt.example.in 2009-04-08 08:20:15 UTC (rev 7586) @@ -1,3 +1,4 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) PROJECT (playerplugin_examples) # Include this CMake module to get most of the settings needed to build @@ -6,4 +7,4 @@ INCLUDE (UsePlayerC) PLAYER_ADD_PLUGIN_DRIVER (opaquedriver SOURCES opaquedriver.cc) -PLAYER_ADD_PLAYERC_CLIENT (opaque SOURCES opaque.c) \ No newline at end of file +PLAYER_ADD_PLAYERC_CLIENT (opaque SOURCES opaque.c) Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -36,10 +36,11 @@ ENDIF (NOT HAVE_XDR) IF (NOT PTHREAD_INCLUDE_DIR STREQUAL "") - INCLUDE_DIRECTORIES (${PTHREAD_INCLUDE_DIR}) + PLAYERCORE_ADD_INCLUDE_DIR (${PTHREAD_INCLUDE_DIR}) ENDIF (NOT PTHREAD_INCLUDE_DIR STREQUAL "") IF (NOT PTHREAD_LIB_DIR STREQUAL "") - LINK_DIRECTORIES (${PTHREAD_LIB_DIR}) + PLAYERCORE_ADD_LINK_DIR (${PTHREAD_LIB_DIR}) + SET (playercoreLinkDirs ${playercoreLinkDirs} ${PTHREAD_LIB_DIR}) ENDIF (NOT PTHREAD_LIB_DIR STREQUAL "") SET (playercoreSrcs driver.cc @@ -59,19 +60,15 @@ # from the fact that message cloning functions are auto-generated into # playerxdr and used here. Those functions should go into a separate # library. -SET (coreLibs playerutils playererror playerxdr) -IF (PLAYER_OS_QNX) - SET (corePCLibs) -ELSE (PLAYER_OS_QNX) - SET (coreLibs ${coreLibs} ${PTHREAD_LIB}) - SET (corePCLibs "-l${PTHREAD_LIB}") - PLAYER_ADD_LINK_LIB (${PTHREAD_LIB}) -ENDIF (PLAYER_OS_QNX) +PLAYERCORE_ADD_INT_LINK_LIB (playerutils playererror playerxdr) +IF (NOT PLAYER_OS_QNX) + PLAYERCORE_ADD_LINK_LIB (${PTHREAD_LIB}) +ENDIF (NOT PLAYER_OS_QNX) + IF (HAVE_CLOCK_GETTIME) - SET (coreLibs ${coreLibs} rt) - SET (corePCLibs "${corePCLibs} -lrt") - PLAYER_ADD_LINK_LIB (rt) + PLAYERCORE_ADD_INT_LINK_LIB (rt) + SET (playercoreLinkLibs ${playercoreLinkLibs} "rt") ELSE (HAVE_CLOCK_GETTIME) SET (playercoreSrcs ${playercoreSrcs} ${PROJECT_SOURCE_DIR}/replace/clock_gettime.c) ENDIF (HAVE_CLOCK_GETTIME) @@ -80,23 +77,30 @@ ENDIF (NOT HAVE_GETTIMEOFDAY) IF (HAVE_LIBLTDL) IF (PLAYER_OS_QNX) - SET (coreLibs ${coreLibs} ltdl) - SET (corePCLibs "${corePCLibs} -lltdl") - PLAYER_ADD_LINK_LIB (ltdl) + PLAYERCORE_ADD_LINK_LIB (ltdl) + SET (playercoreLinkLibs ${playercoreLinkLibs} "ltdl") ELSE (PLAYER_OS_QNX) - SET (coreLibs ${coreLibs} ltdl dl) - SET (corePCLibs "${corePCLibs} -lltdl -ldl") - PLAYER_ADD_LINK_LIB (ltdl dl) + PLAYERCORE_ADD_LINK_LIB (ltdl dl) + SET (playercoreLinkLibs ${playercoreLinkLibs} "ltdl" "dl") ENDIF (PLAYER_OS_QNX) ENDIF (HAVE_LIBLTDL) IF (NOT HAVE_DIRNAME) SET (playercoreSrcs ${playercoreSrcs} ${PROJECT_SOURCE_DIR}/replace/dirname.c) ENDIF (NOT HAVE_DIRNAME) +INCLUDE_DIRECTORIES (${PLAYERCORE_INT_INCLUDE_DIRS} ${PLAYERCORE_EXTRA_INCLUDE_DIRS}) +LINK_DIRECTORIES (${PLAYERCORE_INT_LINK_DIRS} ${PLAYERCORE_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playercore ${playercoreSrcs} ${player_interfaces_h} ${playerxdr_h}) -TARGET_LINK_LIBRARIES (playercore ${coreLibs}) +TARGET_LINK_LIBRARIES (playercore ${PLAYERCORE_INT_LINK_LIBRARIES} ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) +SET (pkgconfigCFlags) +SET (pkgconfigLinkDirs) +SET (pkgconfigLinkLibs) +LIST_TO_STRING_WITH_PREFIX (pkgconfigCFlags "-I" ${PLAYERCORE_EXTRA_INCLUDE_DIRS}) +LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkDirs "-L" ${PLAYERCORE_EXTRA_LINK_DIRS}) +LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playercore" "Player core library - part of the Player Project" - "playererror" "" "" "${corePCLibs}") + "playererror" "" "${pkgconfigCFLags}" + "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerPlugin.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerPlugin.cmake @ONLY) Modified: code/player/trunk/libplayerjpeg/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerjpeg/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/libplayerjpeg/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -3,8 +3,8 @@ PLAYER_ADD_LIBRARY (playerjpeg ${playerjpegSrcs}) TARGET_LINK_LIBRARIES (playerjpeg jpeg) - PLAYER_ADD_LINK_LIB (jpeg) + PLAYERCORE_ADD_INT_LINK_LIB (jpeg) PLAYER_INSTALL_HEADERS (playerjpeg playerjpeg.h) ELSE (HAVE_JPEG) MESSAGE (STATUS "JPEG support not included.") -ENDIF (HAVE_JPEG) \ No newline at end of file +ENDIF (HAVE_JPEG) Modified: code/player/trunk/libplayertcp/CMakeLists.txt =================================================================== --- code/player/trunk/libplayertcp/CMakeLists.txt 2009-04-07 23:00:21 UTC (rev 7585) +++ code/player/trunk/libplayertcp/CMakeLists.txt 2009-04-08 08:20:15 UTC (rev 7586) @@ -43,16 +43,16 @@ TARGET_LINK_LIBRARIES (playertcp Ws2_32) ENDIF (PLAYER_OS_WIN) IF (SOCKET_LIBS) - PLAYER_ADD_LINK_LIB (${SOCKET_LIBS}) + PLAYERCORE_ADD_INT_LINK_LIB (${SOCKET_LIBS}) ENDIF (SOCKET_LIBS) IF (HAVE_Z) TARGET_LINK_LIBRARIES (playertcp z) - PLAYER_ADD_LINK_LIB (z) + PLAYERCORE_ADD_INT_LINK_LIB (z) SET (zLibFlag -lz) ENDIF (HAVE_Z) IF (PLAYER_OS_SOLARIS) TARGET_LINK_LIBRARIES (playertcp rt) - PLAYER_ADD_LINK_LIB (rt) + PLAYERCORE_ADD_INT_LINK_LIB (rt... [truncated message content] |
From: <th...@us...> - 2009-04-21 00:15:46
|
Revision: 7603 http://playerstage.svn.sourceforge.net/playerstage/?rev=7603&view=rev Author: thjc Date: 2009-04-21 00:15:40 +0000 (Tue, 21 Apr 2009) Log Message: ----------- merge of player property docs from 2-1 Modified Paths: -------------- code/player/trunk/doc/player.dox.in code/player/trunk/libplayercore/property.h Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263,7276,7300 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263,7276,7300,7602 /code/player/trunk:6985 Modified: code/player/trunk/doc/player.dox.in =================================================================== --- code/player/trunk/doc/player.dox.in 2009-04-20 23:55:58 UTC (rev 7602) +++ code/player/trunk/doc/player.dox.in 2009-04-21 00:15:40 UTC (rev 7603) @@ -460,7 +460,7 @@ # with spaces. #INPUT = player.txt install.html migration.html tutorials.html utils.html clients.html plugin_driver.html configfile.html protocol.html ../libplayerxdr/playerxdr.html ../libplayerxdr ../libplayercore/playercore.h ../server/libplayerdrivers ../libplayertcp ../libplayercore ../server/drivers/ ../utils/playerv/playerv.c ../utils/playernav/playernav.c ../utils/playercam/playercam.c ../utils/playerjoy/playerjoy.cc ../utils/playerprint/playerprint.cc ../utils/playervcr/playervcr.c ../utils/dgps_server/dgps_server.dox ../client_libs/libplayerc/doc/mainpage.html ../client_libs/libplayerc/doc/libplayerc_py.html ../client_libs/libplayerc/playerc.h ../client_libs/libplayerc++/playerclient.h ../client_libs/libplayerc++/utility.h ../client_libs/libplayerc++/clientproxy.h ../client_libs/libplayerc++/playerc++.h ../client_libs/libplayerc++/playerc++.cc ../client_libs/libplayerc++/playererror.h -INPUT = player.txt quick_start.txt architecture.txt supported_hardware.txt tutorial_devices.txt tutorial_migration.txt tutorial_cameras.txt tutorial_automake.txt tutorial_crosscompiling.txt tutorial_args.txt tutorial_datalog.txt tutorial_config.txt tutorial_interface.txt tutorial_plugins.txt tutorial_maps.txt install.txt ../server/server.cc ../libplayercore/player.h @PROJECT_BINARY_DIR@/libplayercore/player_interfaces.h ../libplayercore/error.h ../libplayercore/configfile.h ../libplayercore/driver.h ../libplayercore/device.h ../libplayercore/message.h ../server/drivers ../libplayercore/interface_util.h ../libplayersd/playersd.h ../libplayertcp/playertcp.h ../libplayerxdr/playerxdr.html @PROJECT_BINARY_DIR@/libplayerxdr/playerxdr.h ../server/libplayerdrivers/driverregistry.h ../utils/playerv/playerv.c ../utils/playernav/playernav.c ../utils/playercam/playercam.c ../utils/playerjoy/playerjoy.cc ../utils/playerprint/playerprint.cc ../utils/playervcr/playervcr.c ../utils/dgps_server/dgps_server.dox ../utils/playerwritemap/playerwritemap.c ../client_libs/libplayerc/playerc.h ../client_libs/libplayerc/bindings/python/libplayerc_py.html ../client_libs/libplayerc++/playerclient.h ../client_libs/libplayerc++/playerc++.h ../client_libs/libplayerc++/playerc++.cc ../client_libs/libplayerc++/playererror.h ../client_libs/libplayerc++/utility.h ../client_libs/libplayerc++/clientproxy.h +INPUT = player.txt quick_start.txt architecture.txt supported_hardware.txt tutorial_devices.txt tutorial_migration.txt tutorial_cameras.txt tutorial_automake.txt tutorial_crosscompiling.txt tutorial_args.txt tutorial_datalog.txt tutorial_config.txt tutorial_interface.txt tutorial_plugins.txt tutorial_maps.txt install.txt ../server/server.cc ../libplayercore/player.h @PROJECT_BINARY_DIR@/libplayercore/player_interfaces.h ../libplayercore/error.h ../libplayercore/configfile.h ../libplayercore/driver.h ../libplayercore/device.h ../libplayercore/message.h ../server/drivers ../libplayercore/interface_util.h ../libplayersd/playersd.h ../libplayertcp/playertcp.h ../libplayerxdr/playerxdr.html @PROJECT_BINARY_DIR@/libplayerxdr/playerxdr.h ../server/libplayerdrivers/driverregistry.h ../utils/playerv/playerv.c ../utils/playernav/playernav.c ../utils/playercam/playercam.c ../utils/playerjoy/playerjoy.cc ../utils/playerprint/playerprint.cc ../utils/playervcr/playervcr.c ../utils/dgps_server/dgps_server.dox ../utils/playerwritemap/playerwritemap.c ../client_libs/libplayerc/playerc.h ../client_libs/libplayerc/bindings/python/libplayerc_py.html ../client_libs/libplayerc++/playerclient.h ../client_libs/libplayerc++/playerc++.h ../client_libs/libplayerc++/playerc++.cc ../client_libs/libplayerc++/playererror.h ../client_libs/libplayerc++/utility.h ../client_libs/libplayerc++/clientproxy.h ../libplayercore/property.h # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left Modified: code/player/trunk/libplayercore/property.h =================================================================== --- code/player/trunk/libplayercore/property.h 2009-04-20 23:55:58 UTC (rev 7602) +++ code/player/trunk/libplayercore/property.h 2009-04-21 00:15:40 UTC (rev 7603) @@ -55,7 +55,7 @@ class ConfigFile; class Driver; -// Property base class +/// Property base class class PLAYERCORE_EXPORT Property { public: @@ -82,7 +82,7 @@ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -// Integer property class +/// Integer property class class PLAYERCORE_EXPORT IntProperty : public Property { public: @@ -110,7 +110,7 @@ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -// Double property class +/// Double property class class PLAYERCORE_EXPORT DoubleProperty : public Property { public: @@ -138,6 +138,7 @@ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// +/// String Property Class class PLAYERCORE_EXPORT StringProperty : public Property { public: @@ -166,6 +167,7 @@ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// +/// Property node structure typedef struct PropertyNode { char *key; @@ -173,7 +175,7 @@ struct PropertyNode *next; } PropertyNode; -// Property bag class: stores registered properties +/// Property bag class: stores registered properties class PLAYERCORE_EXPORT PropertyBag { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-05-01 07:11:05
|
Revision: 7608 http://playerstage.svn.sourceforge.net/playerstage/?rev=7608&view=rev Author: gbiggs Date: 2009-05-01 07:10:59 +0000 (Fri, 01 May 2009) Log Message: ----------- Applied patch #2773055 Modified Paths: -------------- code/player/trunk/rtk2/rtk_canvas.c code/player/trunk/server/drivers/laser/sickLDMRS.cc code/player/trunk/utils/playerv/pv_dev_power.c Modified: code/player/trunk/rtk2/rtk_canvas.c =================================================================== --- code/player/trunk/rtk2/rtk_canvas.c 2009-04-30 00:47:18 UTC (rev 7607) +++ code/player/trunk/rtk2/rtk_canvas.c 2009-05-01 07:10:59 UTC (rev 7608) @@ -775,6 +775,7 @@ int sizex, int sizey, uint8_t *image) { FILE *file; + int ret = -1; if (!filename) { @@ -792,7 +793,7 @@ // Save PPM image fprintf(file, "P6\n%d %d\n255\n", sizex, sizey); - int ret = fwrite(image, sizex * sizey * 3, 1, file); + ret = fwrite(image, sizex * sizey * 3, 1, file); if (ret < 0) { fprintf(stderr,"Failed to write Image"); Modified: code/player/trunk/server/drivers/laser/sickLDMRS.cc =================================================================== --- code/player/trunk/server/drivers/laser/sickLDMRS.cc 2009-04-30 00:47:18 UTC (rev 7607) +++ code/player/trunk/server/drivers/laser/sickLDMRS.cc 2009-05-01 07:10:59 UTC (rev 7608) @@ -74,7 +74,6 @@ #include <arpa/inet.h> #endif #include <string.h> -#include <iostream> //#include <stdint.h> //#include <sys/time.h> //#include <time.h> @@ -180,7 +179,7 @@ if (cf->ReadDeviceAddr(&this->opaque_id, section, "requires", PLAYER_OPAQUE_CODE, -1, NULL) != 0) { - puts ("No Opaque driver specified"); + PLAYER_ERROR("No Opaque driver specified"); this->SetError(-1); return; } @@ -210,7 +209,7 @@ // Set up the device. Return 0 if things go well, and -1 otherwise. int sickLDMRS::MainSetup() { - puts("Setting up sickLDMRS driver"); + PLAYER_WARN("Setting up sickLDMRS driver"); if(Device::MatchDeviceAddress(this->opaque_id, this->device_addr)) { @@ -242,7 +241,7 @@ delete [] buffer; buffer = NULL; - puts("sickLDMRS driver ready"); + PLAYER_WARN("sickLDMRS driver ready"); return(0); } @@ -263,11 +262,11 @@ delete [] buffer; - puts("sickLDMRS driver shutting down"); + PLAYER_WARN("sickLDMRS driver shutting down"); opaque->Unsubscribe(InQueue); - puts("sickLDMRS driver has been shutdown"); + PLAYER_WARN("sickLDMRS driver has been shutdown"); } @@ -284,7 +283,7 @@ { //GlobalTime->GetTime(&(this->debug_time)); //PLAYER_MSG2(1,"LUX driver received data packet at %d:%d", this->debug_time.tv_sec, this->debug_time.tv_usec); - //puts("Received tcp data"); + //PLAYER_WARN("Received tcp data"); player_opaque_data_t * recv = reinterpret_cast<player_opaque_data_t * > (data); unsigned int messageOffset = rx_count; rx_count += recv->data_count; @@ -330,7 +329,7 @@ //TODO: Implement a timeout here so that if it gets no data back in a time frame it either errors or sends a reset and stuff while(rx_count > HEADER_LEN) { - //puts("Got enough data"); + //PLAYER_WARN("Got enough data"); // find our continuous data header unsigned int ii; bool found = false; Modified: code/player/trunk/utils/playerv/pv_dev_power.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_power.c 2009-04-30 00:47:18 UTC (rev 7607) +++ code/player/trunk/utils/playerv/pv_dev_power.c 2009-05-01 07:10:59 UTC (rev 7608) @@ -121,6 +121,8 @@ void power_draw(power_t *power) { char text[256]; + int size = 0; + int ret; rtk_fig_show(power->fig, 1); rtk_fig_clear(power->fig); @@ -131,8 +133,6 @@ rtk_fig_color_rgb32(power->fig, COLOR_POWER); text[0] = 0; - int size = 0; - int ret; if( power->proxy->valid & PLAYER_POWER_MASK_VOLTS ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-05-01 07:40:26
|
Revision: 7609 http://playerstage.svn.sourceforge.net/playerstage/?rev=7609&view=rev Author: gbiggs Date: 2009-05-01 07:40:22 +0000 (Fri, 01 May 2009) Log Message: ----------- Applied patch #2778486 Modified Paths: -------------- code/player/trunk/server/drivers/ranger/hokuyo_aist.cc code/player/trunk/utils/pmap/CMakeLists.txt Modified: code/player/trunk/server/drivers/ranger/hokuyo_aist.cc =================================================================== --- code/player/trunk/server/drivers/ranger/hokuyo_aist.cc 2009-05-01 07:10:59 UTC (rev 7608) +++ code/player/trunk/server/drivers/ranger/hokuyo_aist.cc 2009-05-01 07:40:22 UTC (rev 7609) @@ -101,6 +101,10 @@ - high_sensitivity (integer) - Default: 0 - Set to non-zero to enable high sensitivity mode on models that support it. + - min_dist (float, metres) + - Default: 0m + - Minimum possible distance. Below that means there is an error (a scratch on the laser for + instance). The reading is then adjusted to the average of the neighboring valid beams. @par Example @@ -127,6 +131,7 @@ const int DEFAULT_SPEED_LEVEL = 0; const int DEFAULT_SENSITIVITY = 0; const int DEFAULT_GET_INTENSITIES = 0; +const double DEFAULT_MIN_DIST = 0.0; //////////////////////////////////////////////////////////////////////////////////////////////////// // Driver object @@ -151,6 +156,7 @@ bool _verbose, _powerOnStartup, _getIntensities, _ignoreUnknowns; double _minAngle, _maxAngle; IntProperty _baudRate, _speedLevel, _highSensitivity; + DoubleProperty _minDist; std::string _portOpts; // Geometry player_ranger_geom_t _geom; @@ -174,12 +180,14 @@ _baudRate ("baud_rate", DEFAULT_BAUDRATE, false), _speedLevel ("speed_level", DEFAULT_SPEED_LEVEL, false), _highSensitivity ("high_sensitivity", DEFAULT_SENSITIVITY, false), + _minDist ("min_dist", DEFAULT_MIN_DIST, false), _ranges (NULL), _intensities (NULL) { // Get the baudrate, speed and sensitivity RegisterProperty ("baud_rate", &_baudRate, cf, section); RegisterProperty ("speed_level", &_speedLevel, cf, section); RegisterProperty ("high_sensitivity", &_highSensitivity, cf, section); + RegisterProperty ("min_dist", &_minDist, cf, section); // Get config _getIntensities = cf->ReadBool (section, "get_intensities", false); @@ -492,10 +500,18 @@ return false; } + double lastValidValue = _minDist; for (unsigned int ii = 0; ii < _data.Length (); ii++) { _ranges[ii] = _data[ii] / 1000.0f; _intensities[ii] = _data.Intensities ()[ii]; + if (_minDist > 0) + { + if (_ranges[ii] < _minDist) + _ranges[ii] = lastValidValue; + else + lastValidValue = _ranges[ii]; + } } rangeData.ranges = _ranges; @@ -523,8 +539,18 @@ return false; } + double lastValidValue = _minDist; for (unsigned int ii = 0; ii < _data.Length (); ii++) + { _ranges[ii] = _data[ii] / 1000.0f; + if (_minDist > 0) + { + if (_ranges[ii] < _minDist) + _ranges[ii] = lastValidValue; + else + lastValidValue = _ranges[ii]; + } + } rangeData.ranges = _ranges; rangeData.ranges_count = _data.Length (); Publish (device_addr, PLAYER_MSGTYPE_DATA, PLAYER_RANGER_DATA_RANGE, Modified: code/player/trunk/utils/pmap/CMakeLists.txt =================================================================== --- code/player/trunk/utils/pmap/CMakeLists.txt 2009-05-01 07:10:59 UTC (rev 7608) +++ code/player/trunk/utils/pmap/CMakeLists.txt 2009-05-01 07:40:22 UTC (rev 7609) @@ -9,7 +9,8 @@ pkg_check_modules (GSL_PKG gsl) IF (GSL_PKG_FOUND) - LIST_TO_STRING (GSL_CFLAGS "${GSL_PKG_CFLAGS}") + LIST_TO_STRING (GSL_CFLAGS "${GSL_PKG_CFLAGS_OTHER}") + LIST_TO_STRING (GSL_LDFLAGS "${GSL_PKG_LDFLAGS_OTHER}") LINK_DIRECTORIES (${GSL_PKG_LIBRARY_DIRS}) INCLUDE (FindOpenGL) @@ -25,7 +26,8 @@ SET (lododriverSrcs lodo_driver.cc) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs - ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_CURRENT_BINARY_DIR} + ${GSL_PKG_INCLUDE_DIRS}) IF (GLUT_FOUND) INCLUDE_DIRECTORIES (${GLUT_INCLUDE_DIR}) ENDIF (GLUT_FOUND) @@ -43,6 +45,7 @@ ENDIF (GLUT_FOUND) SET_SOURCE_FILES_PROPERTIES (${pmapSrcs} PROPERTIES COMPILE_FLAGS "${GSL_CFLAGS} --fast-math") + SET_TARGET_PROPERTIES (pmap PROPERTIES LINK_FLAGS "${GSL_LDFLAGS}") TARGET_LINK_LIBRARIES (pmap ${GSL_PKG_LIBRARIES}) PLAYER_ADD_LIBRARY (lodo ${lodoSrcs}) @@ -52,6 +55,7 @@ ENDIF (GLUT_FOUND) SET_SOURCE_FILES_PROPERTIES (${lodoSrcs} PROPERTIES COMPILE_FLAGS "${GSL_CFLAGS} --fast-math") + SET_TARGET_PROPERTIES (lodo PROPERTIES LINK_FLAGS "${GSL_LDFLAGS}") TARGET_LINK_LIBRARIES (lodo ${GSL_PKG_LIBRARIES}) PLAYER_ADD_LIBRARY (lododriver ${lododriverSrcs}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-05-08 00:24:08
|
Revision: 7626 http://playerstage.svn.sourceforge.net/playerstage/?rev=7626&view=rev Author: gbiggs Date: 2009-05-08 00:23:57 +0000 (Fri, 08 May 2009) Log Message: ----------- Added checks for specific required gtk functions to playervcr, disabled pmaptest when getopt_long is not found Modified Paths: -------------- code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/utils/playervcr/CMakeLists.txt code/player/trunk/utils/pmap/CMakeLists.txt Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-05-07 08:09:17 UTC (rev 7625) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-05-08 00:23:57 UTC (rev 7626) @@ -50,6 +50,7 @@ CHECK_FUNCTION_EXISTS (cfmakeraw HAVE_CFMAKERAW) CHECK_FUNCTION_EXISTS (dirname HAVE_DIRNAME) CHECK_FUNCTION_EXISTS (getopt HAVE_GETOPT) +CHECK_FUNCTION_EXISTS (getopt_long HAVE_GETOPT_LONG) CHECK_INCLUDE_FILES (linux/joystick.h HAVE_LINUX_JOYSTICK_H) CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H) CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) Modified: code/player/trunk/utils/playervcr/CMakeLists.txt =================================================================== --- code/player/trunk/utils/playervcr/CMakeLists.txt 2009-05-07 08:09:17 UTC (rev 7625) +++ code/player/trunk/utils/playervcr/CMakeLists.txt 2009-05-08 00:23:57 UTC (rev 7626) @@ -1,17 +1,32 @@ +INCLUDE (CheckFunctionExists) OPTION (BUILD_UTILS_PLAYERVCR "Build the playervcr utility" ON) IF (BUILD_UTILS_PLAYERVCR) IF (WITH_GTK) - SET (playervcrSrcs playervcr.c) + SET (CMAKE_REQUIRED_FLAGS ${GTK_CFLAGS}) + SET (CMAKE_REQUIRED_INCLUDES ${GTK_PKG_INCLUDE_DIRS}) + SET (CMAKE_REQUIRED_LIBRARIES ${GTK_PKG_LIBRARIES}) + CHECK_FUNCTION_EXISTS (gtk_dialog_new_with_buttons HAVE_GTK_DIALOG_NEW_WITH_BUTTONS) + CHECK_FUNCTION_EXISTS (gtk_button_set_use_stock HAVE_GTK_BUTTON_SET_USE_STOCK) + CHECK_FUNCTION_EXISTS (gtk_dialog_run HAVE_GTK_DIALOG_RUN) + SET (CMAKE_REQUIRED_FLAGS) + SET (CMAKE_REQUIRED_INCLUDES) + SET (CMAKE_REQUIRED_LIBRARIES) - INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${GTK_PKG_INCLUDE_DIRS}) - LINK_DIRECTORIES (${GTK_PKG_LIBRARY_DIRS}) - PLAYER_ADD_EXECUTABLE (playervcr ${playervcrSrcs}) - TARGET_LINK_LIBRARIES (playervcr playerc playerxdr playererror - playerutils ${PLAYERC_EXTRA_LINK_LIBRARIES} ${GTK_PKG_LIBRARIES}) - SET_SOURCE_FILES_PROPERTIES (${playervcrSrcs} PROPERTIES - COMPILE_FLAGS "${GTK_CFLAGS}") - SET_TARGET_PROPERTIES (playervcr PROPERTIES - LINK_FLAGS "${GTK_LINKFLAGS}") + IF (HAVE_GTK_DIALOG_NEW_WITH_BUTTONS AND HAVE_GTK_BUTTON_SET_USE_STOCK AND HAVE_GTK_DIALOG_RUN) + SET (playervcrSrcs playervcr.c) + + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${GTK_PKG_INCLUDE_DIRS}) + LINK_DIRECTORIES (${GTK_PKG_LIBRARY_DIRS}) + PLAYER_ADD_EXECUTABLE (playervcr ${playervcrSrcs}) + TARGET_LINK_LIBRARIES (playervcr playerc playerxdr playererror + playerutils ${PLAYERC_EXTRA_LINK_LIBRARIES} ${GTK_PKG_LIBRARIES}) + SET_SOURCE_FILES_PROPERTIES (${playervcrSrcs} PROPERTIES + COMPILE_FLAGS "${GTK_CFLAGS}") + SET_TARGET_PROPERTIES (playervcr PROPERTIES + LINK_FLAGS "${GTK_LINKFLAGS}") + ELSE (HAVE_GTK_DIALOG_NEW_WITH_BUTTONS AND HAVE_GTK_BUTTON_SET_USE_STOCK AND HAVE_GTK_DIALOG_RUN) + MESSAGE (STATUS "playervcr will not be built - GTK version is too old") + ENDIF (HAVE_GTK_DIALOG_NEW_WITH_BUTTONS AND HAVE_GTK_BUTTON_SET_USE_STOCK AND HAVE_GTK_DIALOG_RUN) ELSE (WITH_GTK) MESSAGE (STATUS "playervcr will not be built - GTK not found") ENDIF (WITH_GTK) Modified: code/player/trunk/utils/pmap/CMakeLists.txt =================================================================== --- code/player/trunk/utils/pmap/CMakeLists.txt 2009-05-07 08:09:17 UTC (rev 7625) +++ code/player/trunk/utils/pmap/CMakeLists.txt 2009-05-08 00:23:57 UTC (rev 7626) @@ -32,18 +32,15 @@ INCLUDE_DIRECTORIES (${GLUT_INCLUDE_DIR}) ENDIF (GLUT_FOUND) - IF (NOT HAVE_GETOPT) - INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) - SET (getoptSrc ${PROJECT_SOURCE_DIR}/replace/getopt.c) - ENDIF (NOT HAVE_GETOPT) + IF (HAVE_GETOPT_LONG) + PLAYER_ADD_EXECUTABLE (pmaptest ${pmaptestSrcs} ${getoptSrc}) + TARGET_LINK_LIBRARIES (pmaptest pmap lodo) + IF (GLUT_FOUND) + TARGET_LINK_LIBRARIES (pmaptest ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) + ENDIF (GLUT_FOUND) + TARGET_LINK_LIBRARIES (pmaptest ${GSL_PKG_LIBRARIES}) + ENDIF (HAVE_GETOPT_LONG) - PLAYER_ADD_EXECUTABLE (pmaptest ${pmaptestSrcs} ${getoptSrc}) - TARGET_LINK_LIBRARIES (pmaptest pmap lodo) - IF (GLUT_FOUND) - TARGET_LINK_LIBRARIES (pmaptest ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) - ENDIF (GLUT_FOUND) - TARGET_LINK_LIBRARIES (pmaptest ${GSL_PKG_LIBRARIES}) - PLAYER_ADD_LIBRARY (pmap ${pmapSrcs}) IF (GLUT_FOUND) TARGET_LINK_LIBRARIES (pmap ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-06-04 06:24:28
|
Revision: 7780 http://playerstage.svn.sourceforge.net/playerstage/?rev=7780&view=rev Author: thjc Date: 2009-06-04 06:24:20 +0000 (Thu, 04 Jun 2009) Log Message: ----------- added initial playerwkb version, currently disabled in top level lists file as it doesnt build Modified Paths: -------------- code/player/trunk/CMakeLists.txt Added Paths: ----------- code/player/trunk/libplayerwkb/ code/player/trunk/libplayerwkb/CMakeLists.txt code/player/trunk/libplayerwkb/playerwkb.c code/player/trunk/libplayerwkb/playerwkb.h Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-06-04 00:42:45 UTC (rev 7779) +++ code/player/trunk/CMakeLists.txt 2009-06-04 06:24:20 UTC (rev 7780) @@ -60,6 +60,7 @@ ADD_SUBDIRECTORY (libplayercore) ADD_SUBDIRECTORY (libplayerxdr) ADD_SUBDIRECTORY (config) # Example config files +#ADD_SUBDIRECTORY (libplayerwkb) ADD_SUBDIRECTORY (libplayerjpeg) ADD_SUBDIRECTORY (libplayertcp) ADD_SUBDIRECTORY (libplayersd) Added: code/player/trunk/libplayerwkb/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerwkb/CMakeLists.txt (rev 0) +++ code/player/trunk/libplayerwkb/CMakeLists.txt 2009-06-04 06:24:20 UTC (rev 7780) @@ -0,0 +1,8 @@ +SET (playerwkbSrcs playerwkb.c) +PLAYER_ADD_LIBRARY (playerwkb ${playerwkbSrcs}) +PLAYER_INSTALL_HEADERS (playerwkb playerwkb.h) + +IF (HAVE_GEOS) + TARGET_LINK_LIBRARIES (playerwkb geos_c) + PLAYERCORE_ADD_INT_LINK_LIB (geos_c) +ENDIF (HAVE_GEOS) Added: code/player/trunk/libplayerwkb/playerwkb.c =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.c (rev 0) +++ code/player/trunk/libplayerwkb/playerwkb.c 2009-06-04 06:24:20 UTC (rev 7780) @@ -0,0 +1,319 @@ +#include "playerwkb.h" +#include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ +#include <libplayercore/error.h> +#include <stddef.h> + +#ifdef HAVE_GEOS + +#ifndef GEOS_VERSION_MAJOR +#include <geos_c.h> +#endif + +#include <stdio.h> +#include <stdarg.h> + +int geosinit_done = 0; + +/** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ +void player_wkb_geosprint(const char * format, ...) +{ + va_list ap; + va_start(ap, format); + fprintf(stderr, "GEOSError: "); + vfprintf(stderr,format, ap); + fflush(stderr); + va_end(ap); +}; + +#else + +#include <string.h> + +#define WKB_POINT 1 +#define WKB_LINESTRING 2 +#define WKB_POLYGON 3 +#define WKB_MULTIPOINT 4 +#define WKB_MULTILINESTRING 5 +#define WKB_MULTIPOLYGON 6 +#define WKB_GEOMETRYCOLLECTION 7 + +int player_wkb_endians_detect(struct PlayerWKBEndians * endians) +{ + int ui32_one = 1; + double dbl_one = 1.0; + uint8_t uint32_one_be[] = { 0, 0, 0, 1 }; + uint8_t uint32_one_le[] = { 1, 0, 0, 0 }; + uint8_t dbl_one_be[] = { 0x3f, 0xf0, 0, 0, 0, 0, 0, 0 }; + uint8_t dbl_one_le[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x3f }; + const uint8_t * bytes; + + memset(endians, 0, sizeof(struct PlayerWKBEndians)); + if (sizeof(double) != 8) + { + PLAYER_ERROR("incompatible size of double"); + return -1; + } + if (sizeof(uint32_t) != 4) + { + PLAYER_ERROR("incompatible size of uint32_t"); + return -1; + } + bytes = (uint8_t *)(&ui32_one); + if (!memcmp(uint32_one_be, bytes, sizeof(uint32_t))) + { + endians->uint32_endians = player_wkb_big; + } else if (!memcmp(uint32_one_le, bytes, sizeof(uint32_t))) + { + endians->uint32_endians = player_wkb_little; + } else + { + PLAYER_ERROR("unknown integer endians"); + return -1; + } + bytes = (uint8_t *)(&dbl_one); + if (!memcmp(dbl_one_be, bytes, sizeof(double))) + { + endians->dbl_endians = player_wkb_big; + } else if (!memcmp(dbl_one_le, bytes, sizeof(double))) + { + endians->dbl_endians = player_wkb_little; + } else + { + PLAYER_ERROR("unknown double precision endians"); + return -1; + } + return 0; +} + +#endif + +playerwkbprocessor_t player_wkb_create_processor() +{ +#ifdef HAVE_GEOS + return initGEOS_r(player_wkb_geosprint, player_wkb_geosprint); +#else + return NULL; +#endif +} + +void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor) +{ +#ifdef HAVE_GEOS + finishGEOS_r(wkbprocessor); +#endif +} + +#ifdef HAVE_GEOS + +void player_wkb_process_geom(playerwkbprocessor_t wkbprocessor, const GEOSGeometry * geom, void (* callback)(void *, double, double, double, double), void * ptr) +{ + double x0, y0, x1, y1; + const GEOSCoordSequence * seq; + size_t numcoords; + int i; + + switch (GEOSGeomTypeId_r((GEOSContextHandle_t)wkbprocessor, geom)) + { + case GEOS_POINT: + seq = GEOSGeom_getCoordSeq_r((GEOSContextHandle_t)wkbprocessor, geom); + if (!seq) + { + PLAYER_ERROR("Invalid coordinate sequence"); + return; + } + GEOSCoordSeq_getX(seq, 0, &x0); + GEOSCoordSeq_getY(seq, 0, &y0); + callback(ptr, x0 - 0.1, y0, x0 + 0.1, y0); + break; + case GEOS_LINESTRING: + case GEOS_LINEARRING: + seq = GEOSGeom_getCoordSeq_r((GEOSContextHandle_t)wkbprocessor, geom); + if (GEOSCoordSeq_getSize_r((GEOSContextHandle_t)wkbprocessor, seq, (unsigned int *)(&numcoords))) + { + if (numcoords > 0) + { + GEOSCoordSeq_getX_r((GEOSContextHandle_t)wkbprocessor, seq, 0, &x1); + GEOSCoordSeq_getY_r((GEOSContextHandle_t)wkbprocessor, seq, 0, &y1); + if (numcoords < 2) + { + callback(ptr, x1 - 0.1, y1, x1 + 0.1, y1); + callback(ptr, x1, y1 - 0.1, x1, y1 + 0.1); + + } else for (i = 0; i < (signed)numcoords; i++) + { + x0 = x1; + y0 = y1; + GEOSCoordSeq_getX_r((GEOSContextHandle_t)wkbprocessor, seq, i, &x1); + GEOSCoordSeq_getY_r((GEOSContextHandle_t)wkbprocessor, seq, i, &y1); + callback(ptr, x0, y0, x1, y1); + } + } + } + break; + case GEOS_POLYGON: + player_wkb_process_geom(wkbprocessor, GEOSGetExteriorRing_r((GEOSContextHandle_t)wkbprocessor, geom), callback, ptr); + numcoords = GEOSGetNumInteriorRings_r((GEOSContextHandle_t)wkbprocessor, geom); + for (i = 0; i < (signed)numcoords; i++) player_wkb_process_geom(wkbprocessor, GEOSGetInteriorRingN_r((GEOSContextHandle_t)wkbprocessor, geom, i), callback, ptr); + break; + case GEOS_MULTIPOINT: + case GEOS_MULTILINESTRING: + case GEOS_MULTIPOLYGON: + case GEOS_GEOMETRYCOLLECTION: + numcoords = GEOSGetNumGeometries_r((GEOSContextHandle_t)wkbprocessor, geom); + for (i = 0; i < (signed)numcoords; i++) player_wkb_process_geom(wkbprocessor, GEOSGetGeometryN_r((GEOSContextHandle_t)wkbprocessor, geom, i), callback, ptr); + break; + default: + PLAYER_WARN("unknown feature type!"); + } +} + +#endif + +const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, void (* callback)(void *, double, double, double, double), void * ptr) +{ +#ifdef HAVE_GEOS + + GEOSGeometry * geom; + + if (!wkb) + { + PLAYER_ERROR("NULL wkb"); + return NULL; + } + geom = GEOSGeomFromWKB_buf_r((GEOSContextHandle_t)wkbprocessor, wkb, wkb_count); + if (!geom) + { + PLAYER_ERROR("cannot read wkb"); + return NULL; + } + player_wkb_process_geom(wkbprocessor, geom, callback, ptr); + GEOSGeom_destroy_r((GEOSContextHandle_t)wkbprocessor, geom); + return wkb + wkb_count; + +#else + + double x0, y0, x1, y1; + struct PlayerWKBEndians endians; + uint32_t numcoords, numrings; + int i, j; + uint32_t type; + enum player_wkb_endians wkb_endians; + +#define UINT_FROM_WKB(dst) do \ +{ \ + if (wkb_endians == (endians.uint32_endians)) memcpy((dst), wkb, 4); \ + else \ + { \ + ((uint8_t *)(dst))[0] = wkb[(4 - 1) - 0]; \ + ((uint8_t *)(dst))[1] = wkb[(4 - 1) - 1]; \ + ((uint8_t *)(dst))[2] = wkb[(4 - 1) - 2]; \ + ((uint8_t *)(dst))[3] = wkb[(4 - 1) - 3]; \ + } \ + wkb += 4; \ +} while (0) + +#define DBL_FROM_WKB(dst) do \ +{ \ + if (wkb_endians == (endians.dbl_endians)) memcpy((dst), wkb, 8); \ + else \ + { \ + ((uint8_t *)(dst))[0] = wkb[(8 - 1) - 0]; \ + ((uint8_t *)(dst))[1] = wkb[(8 - 1) - 1]; \ + ((uint8_t *)(dst))[2] = wkb[(8 - 1) - 2]; \ + ((uint8_t *)(dst))[3] = wkb[(8 - 1) - 3]; \ + ((uint8_t *)(dst))[4] = wkb[(8 - 1) - 4]; \ + ((uint8_t *)(dst))[5] = wkb[(8 - 1) - 5]; \ + ((uint8_t *)(dst))[6] = wkb[(8 - 1) - 6]; \ + ((uint8_t *)(dst))[7] = wkb[(8 - 1) - 7]; \ + } \ + wkb += 8; \ +} while (0) + + wkbprocessor = wkbprocessor; + wkb_count = wkb_count; + if (!wkb) + { + PLAYER_ERROR("NULL wkb"); + return NULL; + } + if (player_wkb_endians_detect(&endians)) return NULL; + wkb_endians = (enum player_wkb_endians)(wkb[0]); wkb++; + if ((wkb_endians != player_wkb_big) && (wkb_endians != player_wkb_little)) + { + PLAYER_ERROR1("invalid wkb: unknown endians, %d", wkb_endians); + return NULL; + } + UINT_FROM_WKB(&type); + switch (type) + { + case WKB_POINT: + DBL_FROM_WKB(&x0); + DBL_FROM_WKB(&y0); + callback(ptr, x0 - 0.1, y0, x0 + 0.1, y0); + callback(ptr, x0, y0 - 0.1, x0, y0 + 0.1); + break; + case WKB_LINESTRING: + UINT_FROM_WKB(&numcoords); + if (numcoords > 0) + { + DBL_FROM_WKB(&x1); + DBL_FROM_WKB(&y1); + if (numcoords < 2) + { + callback(ptr, x1 - 0.1, y1, x1 + 0.1, y1); + callback(ptr, x1, y1 - 0.1, x1, y1 + 0.1); + } else for (i = 1; i < ((signed)(numcoords)); i++) + { + x0 = x1; + y0 = y1; + DBL_FROM_WKB(&x1); + DBL_FROM_WKB(&y1); + callback(ptr, x0, y0, x1, y1); + } + } + break; + case WKB_POLYGON: + UINT_FROM_WKB(&numrings); + for (i = 0; i < (signed)(numrings); i++) + { + UINT_FROM_WKB(&numcoords); + if (numcoords > 0) + { + DBL_FROM_WKB(&x1); + DBL_FROM_WKB(&y1); + if (numcoords < 2) + { + callback(ptr, x1 - 0.1, y1, x1 + 0.1, y1); + callback(ptr, x1, y1 - 0.1, x1, y1 + 0.1); + } else for (j = 1; j < (signed)(numcoords); j++) + { + x0 = x1; + y0 = y1; + DBL_FROM_WKB(&x1); + DBL_FROM_WKB(&y1); + callback(ptr, x0, y0, x1, y1); + } + } + } + break; + case WKB_MULTIPOINT: + case WKB_MULTILINESTRING: + case WKB_MULTIPOLYGON: + case WKB_GEOMETRYCOLLECTION: + UINT_FROM_WKB(&numrings); + for (i = 0; i < (signed)(numrings); i++) + { + wkb = player_wkb_process_wkb(wkb, callback, ptr); + if (!wkb) return NULL; + } + break; + default: + PLAYER_WARN("unknown wkb feature type!"); + return NULL; + } + return wkb; +#undef UINT_FROM_WKB +#undef DBL_FROM_WKB + +#endif +} Added: code/player/trunk/libplayerwkb/playerwkb.h =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.h (rev 0) +++ code/player/trunk/libplayerwkb/playerwkb.h 2009-06-04 06:24:20 UTC (rev 7780) @@ -0,0 +1,43 @@ +#ifndef __PLAYER_WKB_H +#define __PLAYER_WKB_H + +#include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ + +#ifdef HAVE_GEOS + +#ifndef GEOS_VERSION_MAJOR +#include <geos_c.h> +#endif + +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_GEOS + +typedef GEOSContextHandle_t playerwkbprocessor_t; + +#else + +typedef void * playerwkbprocessor_t; + +enum player_wkb_endians { player_wkb_big = 0, player_wkb_little = 1 }; + +struct PlayerWKBEndians +{ + enum player_wkb_endians uint32_endians, dbl_endians; +}; + +#endif + +playerwkbprocessor_t player_wkb_create_processor(); +void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor); +const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, void (* callback)(void *, double, double, double, double), void * ptr); + +#ifdef __cplusplus +} +#endif + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-06-04 14:21:40
|
Revision: 7781 http://playerstage.svn.sourceforge.net/playerstage/?rev=7781&view=rev Author: thjc Date: 2009-06-04 14:21:36 +0000 (Thu, 04 Jun 2009) Log Message: ----------- updated playerwkb with pauls latest changes Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/libplayerwkb/playerwkb.c code/player/trunk/libplayerwkb/playerwkb.h Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-06-04 06:24:20 UTC (rev 7780) +++ code/player/trunk/CMakeLists.txt 2009-06-04 14:21:36 UTC (rev 7781) @@ -60,7 +60,7 @@ ADD_SUBDIRECTORY (libplayercore) ADD_SUBDIRECTORY (libplayerxdr) ADD_SUBDIRECTORY (config) # Example config files -#ADD_SUBDIRECTORY (libplayerwkb) +ADD_SUBDIRECTORY (libplayerwkb) ADD_SUBDIRECTORY (libplayerjpeg) ADD_SUBDIRECTORY (libplayertcp) ADD_SUBDIRECTORY (libplayersd) Modified: code/player/trunk/libplayerwkb/playerwkb.c =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.c 2009-06-04 06:24:20 UTC (rev 7780) +++ code/player/trunk/libplayerwkb/playerwkb.c 2009-06-04 14:21:36 UTC (rev 7781) @@ -1,14 +1,23 @@ -#include "playerwkb.h" #include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ #include <libplayercore/error.h> #include <stddef.h> +#include "playerwkb.h" + #ifdef HAVE_GEOS #ifndef GEOS_VERSION_MAJOR #include <geos_c.h> #endif +#if (GEOS_VERSION_MAJOR < 3 || GEOS_VERSION_MINOR < 1) +#undef HAVE_GEOS +#endif + +#endif + +#ifdef HAVE_GEOS + #include <stdio.h> #include <stdarg.h> @@ -209,7 +218,7 @@ ((uint8_t *)(dst))[2] = wkb[(4 - 1) - 2]; \ ((uint8_t *)(dst))[3] = wkb[(4 - 1) - 3]; \ } \ - wkb += 4; \ + wkb += 4; wkb_count -= 4; \ } while (0) #define DBL_FROM_WKB(dst) do \ @@ -226,18 +235,16 @@ ((uint8_t *)(dst))[6] = wkb[(8 - 1) - 6]; \ ((uint8_t *)(dst))[7] = wkb[(8 - 1) - 7]; \ } \ - wkb += 8; \ + wkb += 8; wkb_count -= 4; \ } while (0) - wkbprocessor = wkbprocessor; - wkb_count = wkb_count; if (!wkb) { PLAYER_ERROR("NULL wkb"); return NULL; } if (player_wkb_endians_detect(&endians)) return NULL; - wkb_endians = (enum player_wkb_endians)(wkb[0]); wkb++; + wkb_endians = (enum player_wkb_endians)(wkb[0]); wkb++; wkb_count--; if ((wkb_endians != player_wkb_big) && (wkb_endians != player_wkb_little)) { PLAYER_ERROR1("invalid wkb: unknown endians, %d", wkb_endians); @@ -303,7 +310,7 @@ UINT_FROM_WKB(&numrings); for (i = 0; i < (signed)(numrings); i++) { - wkb = player_wkb_process_wkb(wkb, callback, ptr); + wkb = player_wkb_process_wkb(wkbprocessor, wkb, wkb_count, callback, ptr); if (!wkb) return NULL; } break; Modified: code/player/trunk/libplayerwkb/playerwkb.h =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.h 2009-06-04 06:24:20 UTC (rev 7780) +++ code/player/trunk/libplayerwkb/playerwkb.h 2009-06-04 14:21:36 UTC (rev 7781) @@ -9,8 +9,12 @@ #include <geos_c.h> #endif +#if (GEOS_VERSION_MAJOR < 3 || GEOS_VERSION_MINOR < 1) +#undef HAVE_GEOS #endif +#endif + #ifdef __cplusplus extern "C" { #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-06-05 16:09:58
|
Revision: 7791 http://playerstage.svn.sourceforge.net/playerstage/?rev=7791&view=rev Author: thjc Date: 2009-06-05 16:09:52 +0000 (Fri, 05 Jun 2009) Log Message: ----------- applied patch from paul 2801743: Player SVN trunk: libplayerwkb big patch Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt code/player/trunk/client_libs/libplayerc/dev_vectormap.c code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/playerc++.h code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/vectormapproxy.cc code/player/trunk/examples/libplayerc/vmap.c code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayerwkb/CMakeLists.txt code/player/trunk/libplayerwkb/playerwkb.c code/player/trunk/libplayerwkb/playerwkb.h code/player/trunk/server/CMakeLists.txt code/player/trunk/server/drivers/vectormap/CMakeLists.txt code/player/trunk/server/drivers/vectormap/dbconn.cc code/player/trunk/server/drivers/vectormap/dbconn.h code/player/trunk/server/drivers/vectormap/postgis.cc code/player/trunk/server/drivers/vectormap/vec2map.cc code/player/trunk/server/libplayerdrivers/CMakeLists.txt code/player/trunk/utils/playerv/pv_dev_vectormap.c Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -86,7 +86,7 @@ LINK_DIRECTORIES (${PLAYERC_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) -TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) +TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror playerwkb ${PLAYERC_EXTRA_LINK_LIBRARIES}) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (playerc playerjpeg) ENDIF (HAVE_JPEG) @@ -101,5 +101,5 @@ LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERC_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playerc" "Andrew Howard's Player C client library - part of the Player Project" - "playerxdr playererror" "" "${pkgconfigCFlags}" + "playerxdr playererror playerwkb" "" "${pkgconfigCFlags}" "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") Modified: code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -40,7 +40,7 @@ SWIG_ADD_MODULE (playerc python ${playerc_i}) SWIG_LINK_LIBRARIES (playerc ${PYTHON_LIBRARIES}) ADD_DEPENDENCIES (${SWIG_MODULE_playerc_REAL_NAME} playerc_wrap_i_target) - TARGET_LINK_LIBRARIES (${SWIG_MODULE_playerc_REAL_NAME} playerxdr playerc playererror) + TARGET_LINK_LIBRARIES (${SWIG_MODULE_playerc_REAL_NAME} playerxdr playerc playererror playerwkb) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (${SWIG_MODULE_playerc_REAL_NAME} playerjpeg) ENDIF (HAVE_JPEG) Modified: code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake 2009-06-05 16:09:52 UTC (rev 7791) @@ -17,7 +17,7 @@ top_builddir + '/libplayerxdr/.libs', top_builddir + '/libplayercore/.libs', top_builddir + '/libplayerjpeg/.libs'], - libraries = ['playerxdr', 'playerc', 'playerjpeg', 'jpeg', 'playererror']) + libraries = ['playerxdr', 'playerc', 'playerjpeg', 'jpeg', 'playererror', 'playerwkb']) setup(name = 'playerc', Modified: code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -49,7 +49,7 @@ SWIG_ADD_MODULE (playercr ruby ${playerc_i}) SWIG_LINK_LIBRARIES (playercr ${RUBY_LIBRARY}) ADD_DEPENDENCIES (${SWIG_MODULE_playercr_REAL_NAME} playerc_wrap_i_target) - TARGET_LINK_LIBRARIES (${SWIG_MODULE_playercr_REAL_NAME} playerxdr playerc playererror) + TARGET_LINK_LIBRARIES (${SWIG_MODULE_playercr_REAL_NAME} playerxdr playerc playererror playerwkb) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (${SWIG_MODULE_playercr_REAL_NAME} playerjpeg) ENDIF (HAVE_JPEG) Modified: code/player/trunk/client_libs/libplayerc/dev_vectormap.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-06-05 16:09:52 UTC (rev 7791) @@ -59,23 +59,13 @@ #include "playerc.h" #include "error.h" #include <libplayerxdr/playerxdr.h> +#include <libplayerwkb/playerwkb.h> #if defined (WIN32) #define snprintf _snprintf #define strdup _strdup #endif -/** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ -void geosprint(const char* format, ...) -{ - va_list ap; - va_start(ap,format); - fprintf(stderr,"GEOSError: "); - vfprintf(stderr,format, ap); - fflush(stderr); - va_end(ap); -} - // Create a new vectormap proxy playerc_vectormap_t *playerc_vectormap_create(playerc_client_t *client, int index) { @@ -85,13 +75,15 @@ playerc_device_init(&device->info, client, PLAYER_VECTORMAP_CODE, index, (playerc_putmsg_fn_t) NULL); - + device->wkbprocessor = player_wkb_create_processor(); + if ((void *)(device->wkbprocessor)) PLAYERC_WARN("Using GEOS"); else PLAYERC_WARN("Not using GEOS"); return device; } // Destroy a vectormap proxy void playerc_vectormap_destroy(playerc_vectormap_t *device) { + player_wkb_destroy_processor(device->wkbprocessor); playerc_device_term(&device->info); playerc_vectormap_cleanup(device); free(device); @@ -100,26 +92,12 @@ // Subscribe to the vectormap device int playerc_vectormap_subscribe(playerc_vectormap_t *device, int access) { -#ifdef HAVE_GEOS - initGEOS(geosprint,geosprint); -#endif - device->geom = NULL; return playerc_device_subscribe(&device->info, access); } // Un-subscribe from the vectormap device int playerc_vectormap_unsubscribe(playerc_vectormap_t *device) { - if (device->geom) - { -#ifdef HAVE_GEOS - GEOSGeom_destroy(device->geom); -#endif - device->geom = NULL; - } -#ifdef HAVE_GEOS - finishGEOS(); -#endif return playerc_device_unsubscribe(&device->info); } @@ -206,24 +184,16 @@ } -GEOSGeom playerc_vectormap_get_feature_data(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index) +uint8_t * playerc_vectormap_get_feature_data(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index) { -#ifdef HAVE_GEOS - if (device->geom) - { - GEOSGeom_destroy(device->geom); - device->geom = NULL; - } - device->geom = GEOSGeomFromWKB_buf( - device->layers_data[layer_index]->features[feature_index].wkb, - device->layers_data[layer_index]->features[feature_index].wkb_count - ); - return device->geom; -#else - return NULL; -#endif + return device->layers_data[layer_index]->features[feature_index].wkb; } +size_t playerc_vectormap_get_feature_data_count(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index) +{ + return (size_t)(device->layers_data[layer_index]->features[feature_index].wkb_count); +} + void playerc_vectormap_cleanup(playerc_vectormap_t *device) { unsigned ii; Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-05 16:09:52 UTC (rev 7791) @@ -54,18 +54,11 @@ #if !defined (WIN32) #include <netinet/in.h> /* need this for struct sockaddr_in */ #endif +#include <stddef.h> /* size_t */ #include <stdio.h> #include <playerconfig.h> -#ifdef HAVE_GEOS -#ifndef GEOS_VERSION_MAJOR -#include <geos_c.h> -#endif -#else -typedef void * GEOSGeom; -#endif - /* Get the message structures from Player*/ #include <libplayercore/playercommon.h> #include <libplayercore/player.h> @@ -73,6 +66,7 @@ #include <libplayercore/interface_util.h> #include <libplayerxdr/playerxdr.h> #include <libplayerxdr/functiontable.h> +#include <libplayerwkb/playerwkb.h> #if defined (WIN32) #include <winsock2.h> #endif @@ -2404,8 +2398,8 @@ player_vectormap_layer_data_t** layers_data; /** Layer info. */ player_vectormap_layer_info_t** layers_info; - /** geos geometry returned by get_feature_data */ - GEOSGeom geom; + /** WKB processor instance if you want to deal with WKB data */ + playerwkbprocessor_t wkbprocessor; } playerc_vectormap_t; @@ -2433,9 +2427,10 @@ /** @brief Clean up the dynamically allocated memory for the vectormap. */ PLAYERC_EXPORT void playerc_vectormap_cleanup(playerc_vectormap_t *device); -/** @brief Get an individual feature as a geos geometry. Must only be used after a successful call to playerc_vectormap_get_layer_data. - * The geos geometry is owned by the proxy, duplicate it if it is needed after the next call to get_feature_data. Non-reentrant. */ -PLAYERC_EXPORT GEOSGeom playerc_vectormap_get_feature_data(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index); +/** @brief Get an individual feature as a WKB geometry. Must only be used after a successful call to playerc_vectormap_get_layer_data. + * The WKB geometry is owned by the proxy, duplicate it if it is needed after the next call to get_feature_data. */ +PLAYERC_EXPORT uint8_t * playerc_vectormap_get_feature_data(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index); +PLAYERC_EXPORT size_t playerc_vectormap_get_feature_data_count(playerc_vectormap_t *device, unsigned layer_index, unsigned feature_index); /** @} */ Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -218,7 +218,7 @@ INCLUDE_DIRECTORIES (${PLAYERCC_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playerc++ ${playerccSrcs} ${playercppconfig_h}) - TARGET_LINK_LIBRARIES (playerc++ playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (playerc++ playerwkb playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) SET (pkgconfigCFlags) SET (pkgconfigLinkDirs) @@ -228,7 +228,7 @@ LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERCC_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playerc++" "C++ wrapper for libplayerc - part of the Player Project" - "playerxdr playerc" "" "${pkgconfigCFlags}" + "playerwkb playerxdr playerc" "" "${pkgconfigCFlags}" "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerC++.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerC++.cmake @ONLY) Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-06-05 16:09:52 UTC (rev 7791) @@ -49,6 +49,7 @@ #ifndef PLAYERCC_H #define PLAYERCC_H +#include <cstddef> #include <cmath> #include <string> #include <list> @@ -2492,7 +2493,8 @@ int GetLayerCount() const; std::vector<std::string> GetLayerNames() const; int GetFeatureCount(unsigned layer_index) const; - GEOSGeom GetFeatureData(unsigned layer_index, unsigned feature_index) const; + const uint8_t * GetFeatureData(unsigned layer_index, unsigned feature_index) const; + size_t GetFeatureDataCount(unsigned layer_index, unsigned feature_index) const; }; /** Modified: code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -38,7 +38,7 @@ LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) ADD_EXECUTABLE (playerc++_test ${testsSrcs}) - TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror playerwkb ${PLAYERCC_EXTRA_LINK_LIBRARIES}) ENDIF (BUILD_CC_TESTS) ENDIF (BUILD_PLAYERCC_BOOST) ENDIF (BUILD_PLAYERCC) Modified: code/player/trunk/client_libs/libplayerc++/vectormapproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/vectormapproxy.cc 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/client_libs/libplayerc++/vectormapproxy.cc 2009-06-05 16:09:52 UTC (rev 7791) @@ -139,12 +139,17 @@ return mDevice->layers_data[layer_index]->features_count; } -GEOSGeom VectorMapProxy::GetFeatureData(unsigned layer_index, unsigned feature_index) const +const uint8_t * VectorMapProxy::GetFeatureData(unsigned layer_index, unsigned feature_index) const { scoped_lock_t lock(mPc->mMutex); return playerc_vectormap_get_feature_data(mDevice, layer_index, feature_index); } +size_t VectorMapProxy::GetFeatureDataCount(unsigned layer_index, unsigned feature_index) const +{ + scoped_lock_t lock(mPc->mMutex); + return playerc_vectormap_get_feature_data_count(mDevice, layer_index, feature_index); +} ostream& std::operator << (ostream &os, const VectorMapProxy &c) Modified: code/player/trunk/examples/libplayerc/vmap.c =================================================================== --- code/player/trunk/examples/libplayerc/vmap.c 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/examples/libplayerc/vmap.c 2009-06-05 16:09:52 UTC (rev 7791) @@ -9,7 +9,6 @@ { playerc_client_t* client = NULL; playerc_vectormap_t* vmap = NULL; - GEOSGeom g; printf("Creating client\n"); client = playerc_client_create(NULL, "localhost", 6665); @@ -53,21 +52,13 @@ } PrintMapInfo(vmap); - PrintLayerInfo(vmap); - PrintLayerData(vmap); - - printf("Getting feature data\n"); - g = playerc_vectormap_get_feature_data(vmap, 0, 0); - if (g == NULL) + if (vmap->layers_count > 0) { - printf("Error getting feature data\n"); + PrintLayerInfo(vmap); + PrintLayerData(vmap); + if (vmap->layers_data[0]->features_count) PrintFeatureData(vmap); } - PrintMapInfo(vmap); - PrintLayerInfo(vmap); - PrintLayerData(vmap); - PrintFeatureData(vmap); - printf("\n"); printf("Unsubscribing\n"); playerc_vectormap_unsubscribe(vmap); Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -134,7 +134,6 @@ playercommon.h ${playerconfig_h} playercore.h - player_geos.h player.h ${player_interfaces_h} playertime.h Modified: code/player/trunk/libplayerwkb/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerwkb/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/libplayerwkb/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -1,8 +1,14 @@ SET (playerwkbSrcs playerwkb.c) PLAYER_ADD_LIBRARY (playerwkb ${playerwkbSrcs}) -PLAYER_INSTALL_HEADERS (playerwkb playerwkb.h) IF (HAVE_GEOS) - TARGET_LINK_LIBRARIES (playerwkb geos_c) + TARGET_LINK_LIBRARIES (playerwkb playererror geos geos_c) PLAYERCORE_ADD_INT_LINK_LIB (geos_c) + SET (wkbLibFlag "-lgeos -lgeos_c") +ELSE (HAVE_GEOS) + TARGET_LINK_LIBRARIES (playerwkb playererror) + SET (wkbLibFlag) ENDIF (HAVE_GEOS) + +PLAYER_MAKE_PKGCONFIG ("playerwkb" "Player WKB processing library - part of the Player Project" "playererror" "" "" "${wkbLibFlag}") +PLAYER_INSTALL_HEADERS (playerwkb playerwkb.h) Modified: code/player/trunk/libplayerwkb/playerwkb.c =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.c 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/libplayerwkb/playerwkb.c 2009-06-05 16:09:52 UTC (rev 7791) @@ -1,6 +1,6 @@ +#include <stddef.h> /* NULL, size_t typedef and some versions of GEOS CAPI need this */ #include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ #include <libplayercore/error.h> -#include <stddef.h> #include "playerwkb.h" @@ -21,8 +21,6 @@ #include <stdio.h> #include <stdarg.h> -int geosinit_done = 0; - /** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ void player_wkb_geosprint(const char * format, ...) { @@ -37,6 +35,7 @@ #else #include <string.h> +#include <assert.h> #define WKB_POINT 1 #define WKB_LINESTRING 2 @@ -99,7 +98,7 @@ playerwkbprocessor_t player_wkb_create_processor() { #ifdef HAVE_GEOS - return initGEOS_r(player_wkb_geosprint, player_wkb_geosprint); + return (playerwkbprocessor_t)(initGEOS_r(player_wkb_geosprint, player_wkb_geosprint)); #else return NULL; #endif @@ -108,13 +107,15 @@ void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor) { #ifdef HAVE_GEOS - finishGEOS_r(wkbprocessor); + finishGEOS_r((GEOSContextHandle_t)wkbprocessor); +#else + wkbprocessor = wkbprocessor; #endif } #ifdef HAVE_GEOS -void player_wkb_process_geom(playerwkbprocessor_t wkbprocessor, const GEOSGeometry * geom, void (* callback)(void *, double, double, double, double), void * ptr) +void player_wkb_process_geom(playerwkbprocessor_t wkbprocessor, const GEOSGeometry * geom, playerwkbcallback_t callback, void * ptr) { double x0, y0, x1, y1; const GEOSCoordSequence * seq; @@ -178,7 +179,7 @@ #endif -const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, void (* callback)(void *, double, double, double, double), void * ptr) +const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, playerwkbcallback_t callback, void * ptr) { #ifdef HAVE_GEOS @@ -210,6 +211,7 @@ #define UINT_FROM_WKB(dst) do \ { \ + assert(wkb_count >= 4); \ if (wkb_endians == (endians.uint32_endians)) memcpy((dst), wkb, 4); \ else \ { \ @@ -223,6 +225,7 @@ #define DBL_FROM_WKB(dst) do \ { \ + assert(wkb_count >= 8); \ if (wkb_endians == (endians.dbl_endians)) memcpy((dst), wkb, 8); \ else \ { \ @@ -235,7 +238,7 @@ ((uint8_t *)(dst))[6] = wkb[(8 - 1) - 6]; \ ((uint8_t *)(dst))[7] = wkb[(8 - 1) - 7]; \ } \ - wkb += 8; wkb_count -= 4; \ + wkb += 8; wkb_count -= 8; \ } while (0) if (!wkb) @@ -244,6 +247,7 @@ return NULL; } if (player_wkb_endians_detect(&endians)) return NULL; + assert(wkb_count > 1); wkb_endians = (enum player_wkb_endians)(wkb[0]); wkb++; wkb_count--; if ((wkb_endians != player_wkb_big) && (wkb_endians != player_wkb_little)) { Modified: code/player/trunk/libplayerwkb/playerwkb.h =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.h 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/libplayerwkb/playerwkb.h 2009-06-05 16:09:52 UTC (rev 7791) @@ -1,6 +1,7 @@ #ifndef __PLAYER_WKB_H #define __PLAYER_WKB_H +#include <stddef.h> /* size_t typedef and some versions of GEOS CAPI need this */ #include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ #ifdef HAVE_GEOS @@ -36,9 +37,11 @@ #endif +typedef void (* playerwkbcallback_t)(void *, double, double, double, double); + playerwkbprocessor_t player_wkb_create_processor(); void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor); -const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, void (* callback)(void *, double, double, double, double), void * ptr); +const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, playerwkbcallback_t callback, void * ptr); #ifdef __cplusplus } Modified: code/player/trunk/server/CMakeLists.txt =================================================================== --- code/player/trunk/server/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -33,7 +33,7 @@ # Server executable ADD_EXECUTABLE (player ${playerSrcs} ${getoptSrc}) TARGET_LINK_LIBRARIES (player playerdrivers playercore playererror playerutils - playertcp playerudp playerxdr + playertcp playerudp playerxdr playerwkb ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) IF (INCLUDE_RTKGUI) TARGET_LINK_LIBRARIES (player rtk) Modified: code/player/trunk/server/drivers/vectormap/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/drivers/vectormap/CMakeLists.txt 2009-06-05 16:09:52 UTC (rev 7791) @@ -3,21 +3,19 @@ ELSE (HAVE_STL) PLAYERDRIVER_OPTION (postgis build_postgis OFF "STL not found") ENDIF (HAVE_STL) -PLAYERDRIVER_REQUIRE_HEADER (postgis build_postgis geos_c.h) PLAYERDRIVER_REQUIRE_PKG (postgis build_postgis libpqxx postgis_includeDirs postgis_libDirs postgis_linkLibs postgis_linkFlags postgis_cFlags) PLAYERDRIVER_ADD_DRIVER (postgis build_postgis INCLUDEDIRS "${postgis_includeDirs}" LIBDIRS "${postgis_libDirs}" LINKLIBS - "${postgis_linkLibs}" LINKFLAGS "-lgeos ${postgis_linkFlags}" + "${postgis_linkLibs}" LINKFLAGS "${postgis_linkFlags}" CFLAGS "${postgis_cFlags}" SOURCES postgis.cc dbconn.cc) -IF (HAVE_GEOS) - IF (HAVE_STL) - PLAYERDRIVER_OPTION (vec2map build_vec2map ON) - ELSE (HAVE_STL) - PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "STL not found") - ENDIF (HAVE_STL) -ELSE (HAVE_GEOS) - PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "Geos not found") -ENDIF (HAVE_GEOS) -PLAYERDRIVER_ADD_DRIVER (vec2map build_vec2map LINKFLAGS "-lgeos -lgeos_c" SOURCES vec2map.cc) +IF (HAVE_STL) + PLAYERDRIVER_OPTION (vec2map build_vec2map ON) +ELSE (HAVE_STL) + PLAYERDRIVER_OPTION (vec2map build_vec2map OFF "STL not found") +ENDIF (HAVE_STL) + +SET(vec2map_linkFlags) + +PLAYERDRIVER_ADD_DRIVER (vec2map build_vec2map LINKFLAGS "${vec2map_linkFlags}" SOURCES vec2map.cc) Modified: code/player/trunk/server/drivers/vectormap/dbconn.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/dbconn.cc 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/drivers/vectormap/dbconn.cc 2009-06-05 16:09:52 UTC (rev 7791) @@ -4,10 +4,10 @@ #include <iostream> #include <cassert> #include <cctype> +#include <new> // nothrow +#include <cfloat> // DBL_MIN, DBL_MAX +#include <libplayerwkb/playerwkb.h> #include "dbconn.h" -#ifdef HAVE_GEOS -#include <libplayercore/player_geos.h> -#endif using namespace std; @@ -69,7 +69,7 @@ } uint32_t length = PQgetlength(res, 0, 0); - uint8_t * wkb = new uint8_t[length]; + uint8_t * wkb = new(nothrow) uint8_t[length]; assert(wkb); length = Text2Bin(PQgetvalue(res, 0, 0), wkb, length); BoundingBox extent = BinaryToBBox(wkb, length); @@ -119,7 +119,7 @@ info.name = layer_name; uint32_t length = PQgetlength(res, 0, 0); - uint8_t * wkb = new uint8_t[length]; + uint8_t * wkb = new(nothrow) uint8_t[length]; assert(wkb); length = Text2Bin(PQgetvalue(res, 0, 0), wkb, length); info.extent = BinaryToBBox(wkb, length); @@ -154,10 +154,10 @@ data.name = layer_name; for (int i=0; i<num_rows; ++i) { - FeatureDataHolder * fd = new FeatureDataHolder(string(PQgetvalue(res, i, 0))); + FeatureDataHolder * fd = new(nothrow) FeatureDataHolder(string(PQgetvalue(res, i, 0))); assert(fd); uint32_t length = PQgetlength(res, i, 1); - uint8_t * wkb = new uint8_t[length]; + uint8_t * wkb = new(nothrow) uint8_t[length]; assert(wkb); length = Text2Bin(PQgetvalue(res, i, 1), wkb, length); fd->wkb.assign(wkb, wkb + length); @@ -229,7 +229,7 @@ for (int i = 0; i < (int)(data.features.size()); i++) { feature = data.features[i].Convert(); - char * wkb_buff = new char[((feature->wkb_count) * 2) + 1]; + char * wkb_buff = new(nothrow) char[((feature->wkb_count) * 2) + 1]; assert(wkb_buff); char * ptr = wkb_buff; for (uint32_t j = 0; j < (feature->wkb_count); j++) @@ -298,57 +298,30 @@ return 0; } +void PostgresConn::bbcb(void * bbox, double x0, double y0, double x1, double y1) +{ + assert(bbox); + if (x0 < BBOX(bbox)->x0) BBOX(bbox)->x0 = x0; + if (y0 < BBOX(bbox)->y0) BBOX(bbox)->y0 = y0; + if (x1 > BBOX(bbox)->x1) BBOX(bbox)->x1 = x1; + if (y1 > BBOX(bbox)->y1) BBOX(bbox)->y1 = y1; +} + BoundingBox PostgresConn::BinaryToBBox(const uint8_t* wkb, uint32_t length) { BoundingBox res; memset(&res, 0, sizeof(BoundingBox)); + res.x0 = DBL_MAX; + res.y0 = DBL_MAX; + res.x1 = DBL_MIN; + res.y1 = DBL_MIN; if (length == 0) return res; -#ifdef HAVE_GEOS - GEOSGeom polygon; - polygon = GEOSGeomFromWKB_buf(wkb, length); - if (polygon == NULL) + if (!player_wkb_process_wkb(this->wkbprocessor, wkb, static_cast<size_t>(length), reinterpret_cast<playerwkbcallback_t>(PostgresConn::bbcb), reinterpret_cast<void *>(&res))) { - printf("GEOSGeomFromWKB_buf returned NULL!\n"); - return res; + PLAYER_ERROR("Error while processing wkb!"); } - const_GEOSGeom linestring = GEOSGetExteriorRing(polygon); - if (linestring == NULL) - { - printf("GEOSGetExteriorRing returned NULL!\n"); - return res; - } - const_GEOSCoordSeq coords = GEOSGeom_getCoordSeq(linestring); - if (coords == NULL) - { - printf("GEOSGeom_getCoordSeq returned NULL!\n"); - return res; - } - - double xmin = INT_MAX, ymin = INT_MAX; - double xmax = INT_MIN, ymax = INT_MIN; - double tempX, tempY = 0; - - for (int ii=0; ii<GEOSGetNumCoordinates(linestring); ++ii) - { - GEOSCoordSeq_getX(coords, ii, &tempX); - GEOSCoordSeq_getY(coords, ii, &tempY); - if (tempX > xmax) - xmax = tempX; - if (tempX < xmin) - xmin = tempX; - if (tempY > ymax) - ymax = tempY; - if (tempY < ymin) - ymin = tempY; - } - - res.x0 = xmin; - res.y0 = ymin; - res.x1 = xmax; - res.y1 = ymax; - GEOSGeom_destroy(polygon); -#endif + if (this->debug) PLAYER_WARN4("bbox: %.4f, %.4f, %.4f, %.4f", res.x0, res.y0, res.x1, res.y1); return res; } @@ -361,7 +334,8 @@ info.extent.y1 = extent.y1; info.layers_count = layers.size(); if (info.layers) delete [](info.layers); - info.layers = new player_vectormap_layer_info_t[layers.size()]; + assert(info.layers_count > 0); + info.layers = new(nothrow) player_vectormap_layer_info_t[info.layers_count]; assert(info.layers); for (uint32_t ii=0; ii<layers.size(); ++ii) { @@ -398,7 +372,7 @@ assert(feature_data.name); feature_data.name_count = name.size() + 1; if (feature_data.wkb) delete [](feature_data.wkb); - feature_data.wkb = new uint8_t[wkb.size()]; + feature_data.wkb = new(nothrow) uint8_t[wkb.size()]; assert(feature_data.wkb); feature_data.wkb_count = wkb.size(); if (feature_data.attrib) free(feature_data.attrib); @@ -428,13 +402,13 @@ if (layer_data.name) free(layer_data.name); layer_data.name = strdup(name.c_str()); assert(layer_data.name); - layer_data.name_count = name.size()+1; + layer_data.name_count = name.size() + 1; layer_data.features_count = features.size(); if (layer_data.features) delete [](layer_data.features); layer_data.features = NULL; if (layer_data.features_count > 0) { - layer_data.features = new player_vectormap_feature_data_t[layer_data.features_count]; + layer_data.features = new(nothrow) player_vectormap_feature_data_t[layer_data.features_count]; assert(layer_data.features); for (uint32_t ii=0; ii<layer_data.features_count; ++ii) { Modified: code/player/trunk/server/drivers/vectormap/dbconn.h =================================================================== --- code/player/trunk/server/drivers/vectormap/dbconn.h 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/drivers/vectormap/dbconn.h 2009-06-05 16:09:52 UTC (rev 7791) @@ -4,6 +4,7 @@ #include <libpq-fe.h> #include <libplayercore/playercore.h> #include <libplayercore/error.h> +#include <libplayerwkb/playerwkb.h> #include <vector> #include <string> #include <cstring> @@ -16,8 +17,10 @@ typedef struct { double x0, y0, x1, y1; -}BoundingBox; +} BoundingBox; +#define BBOX(ptr) (reinterpret_cast<BoundingBox *>(ptr)) + class FeatureDataHolder { public: @@ -140,8 +143,8 @@ class PostgresConn { public: - PostgresConn(){ conn = NULL; }; - virtual ~PostgresConn(){ if (Connected()) Disconnect(); }; + PostgresConn(int debug = 0){ this->wkbprocessor = player_wkb_create_processor(); this->conn = NULL; this->debug = debug; }; + virtual ~PostgresConn(){ if (Connected()) Disconnect(); player_wkb_destroy_processor(this->wkbprocessor); }; bool Connect(const char* dbname, const char* host, const char* user, const char* password, const char* port); bool Disconnect(); bool Connected() { return (conn != NULL) && (PQstatus(conn) != CONNECTION_BAD); }; @@ -154,8 +157,10 @@ private: BoundingBox BinaryToBBox(const uint8_t *binary, uint32_t length); uint32_t Text2Bin(const char * text, unsigned char * bin, uint32_t maxlen); + playerwkbprocessor_t wkbprocessor; PGconn *conn; - + int debug; + static void bbcb(void * bbox, double x0, double y0, double x1, double y1); }; #endif /* __DBCONN_H_ */ Modified: code/player/trunk/server/drivers/vectormap/postgis.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/postgis.cc 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/drivers/vectormap/postgis.cc 2009-06-05 16:09:52 UTC (rev 7791) @@ -120,26 +120,9 @@ #include <libplayercore/playercore.h> #include <libplayercore/error.h> #include "dbconn.h" -#ifdef HAVE_GEOS -#ifndef GEOS_VERSION_MAJOR -#include <geos_c.h> -#endif -#endif using namespace std; -/** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ -inline void geosprint(const char* format, ...) -{ - va_list ap; - va_start(ap,format); - fprintf(stderr,"GEOSError: "); - vfprintf(stderr,format, ap); - fflush(stderr); - va_end(ap); - -}; - //////////////////////////////////////////////////////////////////////////////// class PostGIS : public Driver { @@ -150,7 +133,8 @@ const char* user, const char* password, const char* port, - vector<string> & layerNames); + vector<string> & layerNames, + int debug); ~PostGIS(); int Setup(); int Shutdown(); @@ -175,6 +159,7 @@ vector<string> layerNames; PostgresConn *conn; + int debug; }; //////////////////////////////////////////////////////////////////////////////// @@ -185,6 +170,7 @@ const char* user = cf->ReadString(section,"user", "postgres"); const char* password = cf->ReadString(section,"password", ""); const char* port = cf->ReadString(section,"port", "5432"); + int debug = cf->ReadInt(section, "debug", 0); vector<string> layerNames; @@ -200,7 +186,7 @@ const char* layer_name = cf->ReadTupleString(section, "layers", i, ""); layerNames.push_back(string(layer_name)); } - return((Driver*)(new PostGIS(cf, section, dbname, host, user, password, port, layerNames))); + return((Driver*)(new PostGIS(cf, section, dbname, host, user, password, port, layerNames, debug))); } //////////////////////////////////////////////////////////////////////////////// @@ -217,7 +203,8 @@ const char* user, const char* password, const char* port, - vector<string> & layerNames) + vector<string> & layerNames, + int debug) : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_VECTORMAP_CODE) { this->dbname = dbname; @@ -227,21 +214,11 @@ this->port = port; this->layerNames = layerNames; this->conn = NULL; -#ifdef HAVE_GEOS - PLAYER_MSG0(2, "Initialising GEOS"); - initGEOS(geosprint, geosprint); - PLAYER_MSG0(2, "GEOS Initialised"); -#endif + this->debug = debug; } //////////////////////////////////////////////////////////////////////////////// -PostGIS::~PostGIS() -{ -#ifdef HAVE_GEOS - PLAYER_MSG0(2, "Shutting down GEOS"); - finishGEOS(); -#endif -} +PostGIS::~PostGIS() { } //////////////////////////////////////////////////////////////////////////////// // Load resources @@ -249,10 +226,10 @@ { PLAYER_MSG0(2, "PostGIS vectormap initialising"); - conn = new PostgresConn(); - conn->Connect(dbname, host, user, password, port); + this->conn = new PostgresConn(this->debug); + this->conn->Connect(this->dbname, this->host, this->user, this->password, this->port); - if (!conn->Connected()) + if (!(this->conn->Connected())) { PLAYER_ERROR("Could not connect to Postgres database!"); return(1); @@ -267,15 +244,15 @@ int PostGIS::Shutdown() { PLAYER_MSG0(2, "PostGIS vectormap shutting down"); - if (conn != NULL && conn->Connected()) + if (this->conn != NULL && this->conn->Connected()) { PLAYER_MSG0(2, "Disconnecting database"); - conn->Disconnect(); + this->conn->Disconnect(); } - if (conn != NULL) + if (this->conn != NULL) { - delete conn; - conn = NULL; + delete this->conn; + this->conn = NULL; } PLAYER_MSG0(2, "PostGIS vectormap stopped"); @@ -293,14 +270,14 @@ PLAYER_VECTORMAP_REQ_GET_MAP_INFO, this->device_addr)) { - VectorMapInfoHolder info = RequestVectorMapInfo(); - const player_vectormap_info_t* response = info.Convert(); + VectorMapInfoHolder info = this->RequestVectorMapInfo(); + player_vectormap_info_t * response = const_cast<player_vectormap_info_t *>(info.Convert()); this->Publish(this->device_addr, resp_queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_VECTORMAP_REQ_GET_MAP_INFO, - (void*)response); + reinterpret_cast<void *>(response)); return(0); } // Request for layer data ///////////////////////////////////////////////////////// @@ -308,14 +285,14 @@ PLAYER_VECTORMAP_REQ_GET_LAYER_DATA, this->device_addr)) { - player_vectormap_layer_data_t* request = reinterpret_cast<player_vectormap_layer_data_t*>(data); - LayerDataHolder ldata = RequestLayerData(request->name); - const player_vectormap_layer_data_t* response = ldata.Convert(); + player_vectormap_layer_data_t* request = reinterpret_cast<player_vectormap_layer_data_t *>(data); + LayerDataHolder ldata = this->RequestLayerData(request->name); + player_vectormap_layer_data_t * response = const_cast<player_vectormap_layer_data_t *>(ldata.Convert()); this->Publish(this->device_addr, resp_queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_VECTORMAP_REQ_GET_LAYER_DATA, - (void*)response); + reinterpret_cast<void *>(response)); return(0); } @@ -325,13 +302,13 @@ this->device_addr)) { player_vectormap_layer_data_t* request = reinterpret_cast<player_vectormap_layer_data_t*>(data); - RequestLayerWrite(request); + this->RequestLayerWrite(request); this->Publish(this->device_addr, resp_queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_VECTORMAP_REQ_WRITE_LAYER, - (void*)request); + reinterpret_cast<void *>(request)); return(0); } // Don't know how to handle this message ///////////////////////////////////////// @@ -340,49 +317,49 @@ VectorMapInfoHolder PostGIS::RequestVectorMapInfo() { - if (conn == NULL || conn->Connected() == false) + if (this->conn == NULL || this->conn->Connected() == false) { PLAYER_ERROR("PostGis::RequestVectorMapInfo() failed! No db connection."); } - VectorMapInfoHolder info = conn->GetVectorMapInfo(layerNames); + VectorMapInfoHolder info = this->conn->GetVectorMapInfo(this->layerNames); return info; } LayerInfoHolder PostGIS::RequestLayerInfo(const char* layer_name) { - if (conn == NULL || conn->Connected() == false) + if (this->conn == NULL || this->conn->Connected() == false) { PLAYER_ERROR("PostGis::RequestLayerInfo() failed! No db connection."); } - LayerInfoHolder info = conn->GetLayerInfo(layer_name); + LayerInfoHolder info = this->conn->GetLayerInfo(layer_name); return info; } LayerDataHolder PostGIS::RequestLayerData(const char* layer_name) { - if (conn == NULL || conn->Connected() == false) + if (this->conn == NULL || this->conn->Connected() == false) { PLAYER_ERROR("PostGis::RequestLayerData() failed! No db connection."); } - LayerDataHolder data = conn->GetLayerData(layer_name); + LayerDataHolder data = this->conn->GetLayerData(layer_name); return data; } void PostGIS::RequestLayerWrite(player_vectormap_layer_data_t* data) { - if (conn == NULL || conn->Connected() == false) + if (this->conn == NULL || this->conn->Connected() == false) { PLAYER_ERROR("PostGis::WriteLayerData() failed! No db connection."); } LayerDataHolder layer(data); - if (conn->WriteLayerData(layer)) + if (this->conn->WriteLayerData(layer)) { PLAYER_ERROR("PostGis::WriteLayerData() failed!"); } Modified: code/player/trunk/server/drivers/vectormap/vec2map.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-06-05 15:16:17 UTC (rev 7790) +++ code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-06-05 16:09:52 UTC (rev 7791) @@ -44,9 +44,6 @@ - cells_per_unit (float) - Default: 0.0 (Should be set to something greater than zero!) - How many cells are occupied for one vectormap unit (for example 50.0 cells for one meter) -- init_geos (integer) - - Default: 1 - - If set to 1, GEOS will be initialized by this driver. If you use other driver that uses GEOS (e.g. postgis), you must set it to 0. - full_extent (integer) - Default: 1 - If set to 1, extent will be computed as if point (0, 0) were in the middle. Warning! It can produce large grid map! @@ -66,35 +63,27 @@ requires ["vectormap:0"] provides ["map:0"] cells_per_unit 50.0 - init_geos 0 ) @endverbatim -@par TODO -Try to use BuildWKB() method as in sicknav200 driver instead of GEOS. Note that it should use Linestring instead of Multipoint. - @author Paul Osmialowski */ /** @} */ -#include <cassert> -#include <cstddef> -#include <cstring> -#include <cstdio> -#include <cstdarg> -#include <ctime> -#include <cmath> -#include <vector> -#include <string> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <time.h> +#include <math.h> #include <pthread.h> +#include <assert.h> #include <libplayercore/playercore.h> -#ifdef HAVE_GEOS -#include <libplayercore/player_geos.h> -#endif +#include <libplayerwkb/playerwkb.h> -#define EPS 0.00001 +#define EPS 0.0000001 #define MAXFABS(a, b) ((fabs(a) > fabs(b)) ? fabs(a) : fabs(b)) using namespace std; @@ -117,15 +106,21 @@ void * data); private: + struct seglist + { + player_segment_t seg; + struct Vec2Map::seglist * next; // segment is valid only if next is not NULL + struct Vec2Map::seglist * last; // for the first element only + }; +#define SEGLIST(ptr) (reinterpret_cast<struct Vec2Map::seglist *>(ptr)) + // Main function for device thread. virtual void Main(); // some helper functions -#ifdef HAVE_GEOS - void dumpFeature(const_GEOSGeom geom, vector<player_segment_t> & segments); -#endif - void line(int a, int b, int c, int d, int8_t * cells, int maxx, int maxy); - int over(int x, int min, int max); + static void line(int a, int b, int c, int d, int8_t * cells, int maxx, int maxy); + static int over(int x, int min, int max); + static void add_segment(void * segptr, double x0, double y0, double x1, double y1); // The address of the vectormap device to which we will // subscribe @@ -137,25 +132,12 @@ Device * vectormap_dev; double cells_per_unit; - int init_geos; int full_extent; int draw_border; const char * skip_feature; + playerwkbprocessor_t wkbProcessor; }; -#ifdef HAVE_GEOS -/** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ -void vec2map_geosprint(const char* format, ...) -{ - va_list ap; - va_start(ap,format); - fprintf(stderr,"GEOSError: "); - vfprintf(stderr,format, ap); - fflush(stderr); - va_end(ap); -}; -#endif - //////////////////////////////////////////////////////////////////////////////// // Constructor. Retrieve options from the configuration file and do any // pre-Setup() setup. @@ -164,12 +146,12 @@ // to the vectormap interface. // Vec2Map::Vec2Map(ConfigFile * cf, int section) -// : Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_MAP_CODE) : ThreadedDriver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN) { memset(&(this->vectormap_addr), 0, sizeof(player_devaddr_t)); memset(&(this->map_addr), 0, sizeof(player_devaddr_t)); this->skip_feature = NULL; + this->wkbProcessor = player_wkb_create_processor(); // one per driver instance this->cells_per_unit = cf->ReadFloat(section, "cells_per_unit", 0.0); if ((this->cells_per_unit) <= 0.0) { @@ -177,14 +159,6 @@ this->SetError(-1); return; } - this->init_geos = cf->ReadInt(section, "init_geos", 1); - if (this->init_geos) - { -#ifdef HAVE_GEOS - PLAYER_WARN("Initializing GEOS"); - initGEOS(vec2map_geosprint, vec2map_geosprint); -#endif - } this->full_extent = cf->ReadInt(section, "full_extent", 1); this->draw_border = cf->ReadInt(section, "draw_border", 1); this->skip_feature = cf->ReadString(section, "skip_feature", ""); @@ -209,13 +183,7 @@ Vec2Map::~Vec2Map() { - if (this->init_geos) - { -#ifdef HAVE_GEOS - PLAYER_WARN("Finishing GEOS"); - finishGEOS(); -#endif - } + player_wkb_destroy_processor(this->wkbProcessor); } //////////////////////////////////////////////////////////////////////////////// @@ -235,7 +203,6 @@ PLAYER_ERROR("unable to subscribe to vectormap device"); return -1; } - return 0; } @@ -262,7 +229,7 @@ pthread_testcancel(); // Process incoming messages - ProcessMessages(); + this->ProcessMessages(); // sleep for a while tspec.tv_sec = 0; @@ -271,83 +238,31 @@ } } -#ifdef HAVE_GEOS -void Vec2Map::dumpFeature(const_GEOSGeom geom, vector<player_segment_t> & segments) +void Vec2Map::add_segment(void * segptr, double x0, double y0, double x1, double y1) { - const_GEOSCoordSeq seq; - double x0, y0, x1, y1; - unsigned int numcoords; - player_segment_t segment; - int i; + struct Vec2Map::seglist * tmp; - switch (GEOSGeomTypeId(geom)) - { - case GEOS_POINT: - seq = GEOSGeom_getCoordSeq(geom); - GEOSCoordSeq_getX(seq, 0, &x0); - GEOSCoordSeq_getY(seq, 0, &y0); - memset(&segment, 0, sizeof segment); - segment.x0 = x0; - segment.y0 = y0; - segment.x1 = x0; - segment.y1 = y0; - segments.push_back(segment); - break; - case GEOS_LINESTRING: - case GEOS_LINEARRING: - seq = GEOSGeom_getCoordSeq(geom); - if (GEOSCoordSeq_getSize(seq, &numcoords)) - { - if (numcoords > 0) - { - GEOSCoordSeq_getX(seq, 0, &x1); - GEOSCoordSeq_getY(seq, 0, &y1); - if (numcoords < 2) - { - memset(&segment, 0, sizeof segment); - segment.x0 = x1; - segment.y0 = y1; - segment.x1 = x1; - segment.y1 = y1; - segments.push_back(segment); - } else for (i = 0; i < (signed)numcoords; i++) - { - x0 = x1; - y0 = y1; - GEOSCoordSeq_getX(seq, i, &x1); - GEOSCoordSeq_getY(seq, i, &y1); - memset(&segment, 0, sizeof segment); - segment.x0 = x0; - segment.y0 = y0; - segment.x1 = x1; - segment.y1 = y1; - segments.push_back(segment); - } - } - } - break; - case GEOS_POLYGON: - this->dumpFeature(GEOSGetExteriorRing(geom), segments); - numcoords = GEOSGetNumInteriorRings(geom); - for (i = 0; i < (signed)numcoords; i++) this->dumpFeature(GEOSGetInteriorRingN(geom, i), segments); - break; - case GEOS_MULTIPOINT: - case GEOS_MULTILINESTRING: - case GEOS_MULTIPOLYGON: - case GEOS_GEOMETRYCOLLECTION: - numcoords = GEOSGetNumGeometries(geom); - for (i = 0; i < (signed)numcoords; i++) this->dumpFeature(GEOSGetGeometryN(geom, i), segments); - break; - default: - PLAYER_WARN("unknown feature type!"); - } + assert(segptr); + tmp = SEGLIST(segptr)->last; + if (!tmp) tmp = SEGLIST(segptr); + memset(&(tmp->seg), 0, sizeof tmp->seg); + tmp->seg.x0 = x0; + tmp->seg.y0 = y0; + tmp->seg.x1 = x1; + tmp->seg.y1 = y1; + tmp->next = reinterpret_cast<struct Vec2Map::seglist *>(malloc(sizeof(struct Vec2Map::seglist))); + assert(tmp->next); + memset(tmp->next, 0, sizeof(struct Vec2Map::seglist)); + memset(&(tmp->next->seg), 0, sizeof tmp->next->seg); + tmp->next->last = NULL; + tmp->next->next = NULL; + SEGLIST(segptr)->last = tmp->next; } -#endif int Vec2Map::over(int x, int min, int max) { - if (x<min) return -1; - if (x>=max) return 1; + if (x < min) return -1; + if (x >= max) return 1; return 0; } @@ -368,7 +283,7 @@ } else { wspX = 1.0; - if (!distY) wspY=0.0; else wspY=1.0 / (((double)distX) / ((double)distY)); + if (!distY) wspY = 0.0; else wspY = 1.0 / ((static_cast<double>(distX)) / (static_cast<double>(distY))); } } else { @@ -379,13 +294,13 @@ } else { wspY = 1.0; - if (!distX) wspX = 0.0; else wspX = 1.0 / (((double)distY) / ((double)distX)); + if (!distX) wspX = 0.0; else wspX = 1.0 / ((static_cast<double>(distY)) / (static_cast<double>(distX))); } } if (c < a) wspX = -wspX; if (d < b) wspY = -wspY; - x = (double)a; y = (double)b; + x = static_cast<double>(a); y = static_cast<double>(b); if (x < 0) x = 0; if (y < 0) y = 0; if (x >= width) x = (width - 1); @@ -393,12 +308,12 @@ cells[(static_cast<int>(y) * width) + (static_cast<int>(x))] = 1; if ((fabs(wspX) < EPS) && (fabs(wspY) < EPS)) return; - while (!((fabs(x - (double)c) < EPS) && (fabs(y - (double)d) < EPS))) + while (!((fabs(x - static_cast<double>(c)) < EPS) && (fabs(y - static_cast<double>(d)) < EPS))) { x += wspX; y += wspY; - if (over(static_cast<int>(x), 0, width)) break; - if (over(static_cast<int>(y), 0, height)) break; + if (Vec2Map::over(static_cast<int>(x), 0, width)) break; + if (Vec2Map::over(static_cast<int>(y), 0, height)) break; cells[(static_cast<int>(y) * width) + (static_cast<int>(x))] = 1; } } @@ -411,18 +326,18 @@ player_map_data_t map_data, map_data_request; player_map_data_vector_t map_data_vector; player_vectormap_layer_data_t layer, * layer_data; - const char * layer_name; player_vectormap_info_t * vectormap_info; Message * msg; - uint32_t width, height, data_count, layers_count, ii, jj; + Message * rep; + uint32_t width, height, data_count, ii, jj; int8_t * cells; - vector<player_segment_t> segments; - vector<string> layer_names; -#ifdef HAVE_GEOS - GEOSGeom geom = NULL; -#endif + struct Vec2Map::seglist segments, * tmp; double basex, basey; + memset(&(segments.seg), 0, sizeof segments.seg); + segments.last = NULL; + segments.next = NULL; + // Process messages here. Send a response if necessary, using Publish(). // If you handle the message successfully, return 0. Otherwise, // return -1, and a NACK will be sent for you, if a response is required. @@ -485,7 +400,7 @@ resp_queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_MAP_REQ_GET_INFO, - (void *)&map_info, sizeof map_info, NULL); + reinterpret_cast<void *>(&map_info)); return 0; } @@ -493,7 +408,6 @@ PLAYER_MAP_REQ_GET_DATA, this->map_addr)) { -#ifdef HAVE_GEOS memset(&map_data, 0, sizeof map_data); if (!data) { @@ -537,46 +451,48 @@ basey = vectormap_info->extent.y0; } data_count = width * height; - layers_count = vectormap_info->layers_count; - if (!((data_count > 0) && (layers_count > 0))) + if (!((data_count > 0) && ((vectormap_info->layers_count) > 0))) { PLAYER_WARN("Invalid map"); + delete msg; return -1; } - for (ii = 0; ii < layers_count; ii++) + for (ii = 0; ii < (vectormap_info->layers_count); ii++) { - layer_names.push_back(string(vectormap_info->layers[ii].name)); - } - delete msg; - msg = NULL; - for (ii = 0; ii < layers_count; ii++) - { memset(&layer, 0, sizeof layer); - layer_name = layer_names[ii].c_str(); - layer.name_count = strlen(layer_name) + 1; - layer.name = new char[layer.name_count]; - assert(layer.name); - strcpy(layer.name, layer_name); - msg = this->vectormap_dev->Request(this->InQueue, + layer.name_count = strlen(vectormap_info->layers[ii].name) + 1; + assert((layer.name_count) > 0); + layer.name = reinterpret_cast<char *>(malloc(layer.name_count)); + if (!(layer.name)) + { + PLAYER_ERROR("cannot allocate space for layer.name"); + delete msg; + return -1; + } + strcpy(layer.name, vectormap_info->layers[ii].name); + rep = this->vectormap_dev->Request(this->InQueue, PLAYER_MSGTYPE_REQ, PLAYER_VECTORMAP_REQ_GET_LAYER_DATA, - (void *)(&layer), 0, NULL, true); - delete []layer.name; - if (!msg) + reinterpret_cast<void *>(&layer), 0, NULL, true); + free(layer.name); + layer.name = NULL; + if (!rep) { PLAYER_WARN("failed to acquire layer data"); return -1; } - if ((msg->GetDataSize()) < (sizeof(player_vectormap_layer_data_t))) + if ((rep->GetDataSize()) < (sizeof(player_vectormap_layer_data_t))) { - PLAYER_WARN2("invalid acqired data size %d vs %d", msg->GetDataSize(), sizeof(player_vectormap_layer_data_t)); + PLAYER_WARN2("invalid acqired data size %d vs %d", rep->GetDataSize(), sizeof(player_vectormap_layer_data_t)); + delete rep; delete msg; return -1; } - layer_data = reinterpret_cast<player_vectormap_layer_data_t *>(msg->GetPayload()); + layer_data = reinterpret_cast<player_vectormap_layer_data_t *>(rep->GetPayload()); if (!layer_data) { PLAYER_WARN("no data acquired"); + delete rep; delete msg; return -1; } @@ -585,29 +501,45 @@ if (this->skip_feature) if ((strlen(this->skip_feature)) && (layer_data->features[jj].name_count > 0)) if (!strcmp(this->skip_feature, layer_data->features[jj].name)) continue; - geom = GEOSGeomFromWKB_buf(layer_data->features[jj].wkb, layer_data->features[jj].wkb_count); - this->dumpFeature(geom, segments); - GEOSGeom_destroy(geom); - geom = NULL; + if (!player_wkb_process_wkb(this->wkbProcessor, layer_data->features[jj].wkb, static_cast<size_t>(layer_data->features[jj].wkb_count), reinterpret_cast<playerwkbcallback_t>(Vec2Map::add_segment), reinterpret_cast<void *>(&segments))) + { + PLAYER_ERROR("Error while processing wkb!"); + } } - delete msg; - msg = NULL; + delete rep; + rep = NULL; } + vectormap_info = NULL; + delete msg; + msg = NULL; map_data.data = NULL; - cells = new int8_t[data_count]; - assert(cells); + cells = reinterpret_cast<int8_t *>(malloc(data_count * sizeof(int8_t))); + if (!cells) + { + PLAYER_ERROR("cannot allocate space for cells"); + return -1; + } memset(cells, -1, data_count); if (this->draw_border) { - line(0, 0, width - 1, 0, cells, width, height); - line(width - 1, 0, width - 1, height - 1, cells, width, height); - line(width - 1, height - 1, 0, height - 1, cells, width, height); - line(0, height - 1, 0, 0, cells, width, height); + Vec2Map::line(0, 0, width - 1, 0, cells, width, height); + Vec2Map::line(width - 1, 0, width - 1, height - 1, cells, width, height); + Vec2Map::line(width - 1, height - 1, 0, height - 1, cells, width, height); + Vec2Map::line(0, height - 1, 0, 0, cells, width, height); } - for (ii = 0; ii < segments.size(); ii++) + for (tmp = &segments; tmp->next; tmp = tmp->next) { - line(static_cast<int>((segments[ii].x0 - basex) * this->cells_per_unit), static_cast<int>((segments[ii].y0 - basey) * this->cells_per_unit), static_cast<int>((segments[ii].x1 - basex) * this->cells_per_unit), static_cast<int>((segments[ii].y1 - basey) * this->cells_per_unit) , cells, width, height); + Vec2Map::line(static_cast<int>((tmp->seg.x0 - basex) * this->cells_per_unit), static_cast<int>((tmp->seg.y0 - basey) * this->cells_per_unit), static_cast<int>((tmp->seg.x1 - basex) * this->cells_per_unit), static_cast<int>((tmp->seg.y1 - basey) * this->cells_per_unit) , cells, width, height); } + if (!(segments.next)) assert(!(segments.last)); + if (!(segments.last)) assert(!(segments.next)); + while (segments.next) + { + tmp = segments.next->next; + free(segments.next); + segments.next = tmp; + } + segments.last = NULL; if (map_data_request.col >= width) map_data_request.col = width - 1; if (map_data_request.row >= height) map_data_request.row = height - 1; if (map_data_request.col + map_data_request.width >= width) map_data_request.width = width - map_data_request.col; @@ -615,7 +547,14 @@ if ((map_data_request.width > 0) && (map_data_request.height > 0)) { map_data.data_count = map_data_request.width * map_data_request.height; - map_data.data = new int8_t[map_data.data_count]; + assert(map_data.data_count > 0); + map_data.data = reinterpret_cast<int8_t *>(malloc(map_data.data_count * sizeof(int8_t))); + if (!(map_data.data)) + { + PLAYER_ERROR("cannot allocate space for map data"); + if (cells) free(cells); + return -1; + } for (ii = 0; ii < (map_data_request.height); ii++) memcpy(map_data.data + (ii * (map_data_request.width)), cells + (ii * width) + map_data_request.col, map_data_request.width); } @@ -623,21 +562,18 @@ resp_queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_MAP_REQ_GET_DATA, - (void *)&map_data); - if (cells) delete []cells; - if (map_data.data) delete [](map_data.data); + reinterpret_cast<void *>(&map_data)); + if (cells) free(cells); + cells = NULL; + if (map_data.data) free(map_data.data); + map_data.data = NULL; return 0; -#else - PLAYER_WARN("GEOS not installed"); - return -1; -#endif } if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_MAP_REQ_GET_VECTOR, this->map_addr)) { -#ifdef HAVE_GEOS memset(&map_data_vector, 0, sizeof map_data_vector); msg = this->vectormap_dev->Request(this->InQueue, PLAYER_MSGTYPE_REQ, @@ -661,45 +597,47 @@ delete msg; return -1; } - layers_count = vectormap_info->layers_count; - for (ii = 0; ii < layers_count; ii++) - { - layer_names.push_back(string(vectormap_info->layers[ii].name)); - } map_data_vector.minx = vectormap_info->extent.x0; map_data_vector.miny = vectormap_info->extent.y0; map_data_vector.maxx = vectormap_info->extent.x1; map_data_vector.maxy = vectormap_info->extent.y1; - delete msg; - msg = NULL; - for (ii = 0; ii < layers_count; ii++) + for (ii = 0; ii < (vectormap_info->layers_count); ii++) { memset(&layer, 0, sizeof layer); - layer_name = layer_names[ii].c_str(); - layer.name_count = strlen(layer_name) + 1; - layer.name = new char[layer.name_count]; - assert(layer.name); - strcpy(layer.name, layer_name); - msg = this->vectormap_dev->Request(this->InQueue, + layer.name_count = strlen(vectormap_info->layers[ii].name) + 1; + assert((layer.name_count) > 0); + layer.name = reinterpret_cast<char *>(malloc(layer.name_count)); + if (!(layer.name)) + { + PLAYER_ERROR("cannot allocate space for layer.name"); + delete msg; + return -1; + } + strcpy(layer.name, vectormap_info->layers[ii].name); + rep = this->vectormap_dev->Request(this->InQueue, PLAYER_MSGTYPE_REQ, PLAYER_VECTORMAP_REQ_GET_LAYER_DATA, - (void *)(&layer), 0, NULL, true); - delete []layer.name; - if (!msg) + reinterpret_cast<void *>(&layer), 0, NULL, true); + free(layer.name); + layer.name = NULL; + if (!rep) { PLAYER_WARN("failed to acquire layer data"); + delete msg; return -1; } - if ((msg->GetDataSize()) < (sizeof(player_vectormap_layer_data_t))) + if ((rep->GetDataSize()) < (sizeof(player_vectormap_layer_data_t))) { - PLAYER_WARN2("invalid acqired data size %d vs %d", msg->GetDataSize(), sizeof(player_vectormap_layer_data_t)); + PLAYER_WARN2("invalid acqired data size %d vs %d", ... [truncated message content] |
From: <th...@us...> - 2009-06-06 09:01:04
|
Revision: 7798 http://playerstage.svn.sourceforge.net/playerstage/?rev=7798&view=rev Author: thjc Date: 2009-06-06 09:00:59 +0000 (Sat, 06 Jun 2009) Log Message: ----------- applied variation of patch 2794776 adding new functions to camera1394 and ptu46 various other warning fixes Modified Paths: -------------- code/player/trunk/server/drivers/camera/1394/camera1394.cc code/player/trunk/server/drivers/joystick/linuxjoy.cc code/player/trunk/server/drivers/laser/sicklms200.cc code/player/trunk/server/drivers/mixed/p2os/packet.cc code/player/trunk/server/drivers/mixed/p2os/robot_params.h code/player/trunk/server/drivers/mixed/rflex/rflex.cc code/player/trunk/server/drivers/ptz/ptu46.cc code/player/trunk/server/drivers/rfid/acr120u.cc code/player/trunk/server/drivers/sonar/aiotosonar.cc Removed Paths: ------------- code/player/trunk/libplayercore/player_geos.h Deleted: code/player/trunk/libplayercore/player_geos.h =================================================================== --- code/player/trunk/libplayercore/player_geos.h 2009-06-06 08:06:43 UTC (rev 7797) +++ code/player/trunk/libplayercore/player_geos.h 2009-06-06 09:00:59 UTC (rev 7798) @@ -1,18 +0,0 @@ -#ifndef PLAYER_GEOS_H_ -#define PLAYER_GEOS_H_ - -#ifndef GEOS_VERSION_MAJOR -#include <stddef.h> -#include <geos_c.h> -#endif - -// workaround gcc 4.2's confusion over typedeffed constants -#if GEOS_VERSION_MAJOR >= 3 -typedef const struct GEOSCoordSeq_t * const_GEOSCoordSeq; -typedef const struct GEOSGeom_t * const_GEOSGeom; -#else -typedef struct GEOSCoordSeq_t * const_GEOSCoordSeq; -typedef struct GEOSGeom_t * const_GEOSGeom; -#endif - -#endif /* PLAYER_GEOS_H_ */ Modified: code/player/trunk/server/drivers/camera/1394/camera1394.cc =================================================================== --- code/player/trunk/server/drivers/camera/1394/camera1394.cc 2009-06-06 08:06:43 UTC (rev 7797) +++ code/player/trunk/server/drivers/camera/1394/camera1394.cc 2009-06-06 09:00:59 UTC (rev 7798) @@ -31,131 +31,131 @@ /** @defgroup driver_camera1394 camera1394 * @brief Firewire camera capture -The camera1394 driver captures images from IEEE1394 (Firewire, iLink) -cameras. + The camera1394 driver captures images from IEEE1394 (Firewire, iLink) + cameras. -@par Compile-time dependencies + @par Compile-time dependencies -- libraw1394 -- libdc1394_control + - libraw1394 + - libdc1394_control -@par Provides + @par Provides -- @ref interface_camera + - @ref interface_camera -@par Requires + @par Requires -- none + - none -@par Configuration requests + @par Configuration requests -- none + - none -@par Configuration file options + @par Configuration file options -- port (integer) - - Default: 0 - - The 1394 port the camera is attached to. + - port (integer) + - Default: 0 + - The 1394 port the camera is attached to. -- node (integer) - - Default: 0 - - The node within the port + - node (integer) + - Default: 0 + - The node within the port -- framerate (float) - - Default: 15 - - Requested frame rate (frames/second) + - framerate (float) + - Default: 15 + - Requested frame rate (frames/second) -- mode (string) - - Default: "640x480_yuv422" - - Capture mode (size and color layour). Valid modes are: - - "320x240_yuv422" - - "640x480_mono" - - "640x480_yuv422" - - "640x480_rgb" - - "800x600_mono" - - "800x600_yuv422" - will be rescaled to 600x450 - - "1024x768_mono" - - "1024x768_yuv422" - will be rescaled to 512x384 - - "1280x960_mono" - - "1280x960_yuv422" - will be rescaled to 640x480 - - "FORMAT7_MODE0" - only available with libdc1394 >= 2.0 - - Currently, all mono modes will produce 8-bit monochrome images unless - a color decoding option is provided (see bayer). - - All yuv422 modes are converted to RGB24 + - mode (string) + - Default: "640x480_yuv422" + - Capture mode (size and color layour). Valid modes are: + - "320x240_yuv422" + - "640x480_mono" + - "640x480_yuv422" + - "640x480_rgb" + - "800x600_mono" + - "800x600_yuv422" - will be rescaled to 600x450 + - "1024x768_mono" + - "1024x768_yuv422" - will be rescaled to 512x384 + - "1280x960_mono" + - "1280x960_yuv422" - will be rescaled to 640x480 + - "FORMAT7_MODE0" - only available with libdc1394 >= 2.0 + - Currently, all mono modes will produce 8-bit monochrome images unless + a color decoding option is provided (see bayer). + - All yuv422 modes are converted to RGB24 -- force_raw (integer) - - Default: 0 - - Force the driver to use (slow) memory capture instead of DMA transfer - (for buggy 1394 drivers). + - force_raw (integer) + - Default: 0 + - Force the driver to use (slow) memory capture instead of DMA transfer + (for buggy 1394 drivers). -- save (integer) - - Default: 0 - - Debugging option: set this to write each frame as an image file on disk. + - save (integer) + - Default: 0 + - Debugging option: set this to write each frame as an image file on disk. -- bayer (string) - - Default: None. - - Bayer color decoding options for cameras such as the Point Grey Dragonfly and Bummblebee. - Option activates color decoding and specifies the Bayer color pattern. Valid modes are: - - "BGGR" - - "GRBG" - - "RGGB" - - "GBRG" + - bayer (string) + - Default: None. + - Bayer color decoding options for cameras such as the Point Grey Dragonfly and Bummblebee. + Option activates color decoding and specifies the Bayer color pattern. Valid modes are: + - "BGGR" + - "GRBG" + - "RGGB" + - "GBRG" -- method (string) - - Default: None (or "DownSample" if bayer option is specified) - - Determines the algorithm used for Bayer coloro decoding. Valid modes are: - - "DownSample" - - "Nearest" - - "Edge" + - method (string) + - Default: None (or "DownSample" if bayer option is specified) + - Determines the algorithm used for Bayer coloro decoding. Valid modes are: + - "DownSample" + - "Nearest" + - "Edge" -- brightness (string or unsigned int) - - Default: None - - Sets the camera brightness setting. Valid modes are: - - "auto" - - any suitable unsigned integer + - brightness (string or unsigned int) + - Default: None + - Sets the camera brightness setting. Valid modes are: + - "auto" + - any suitable unsigned integer -- exposure (string or unsigned int) - - Default: None - - Sets the camera exposure setting. Valid modes are: - - "auto" - - any suitable unsigned integer + - exposure (string or unsigned int) + - Default: None + - Sets the camera exposure setting. Valid modes are: + - "auto" + - any suitable unsigned integer -- shutter (string or unsigned int) - - Default: None - - Sets the camera shutter setting. Valid modes are: - - "auto" - - any suitable unsigned integer + - shutter (string or unsigned int) + - Default: None + - Sets the camera shutter setting. Valid modes are: + - "auto" + - any suitable unsigned integer -- gain (string or unsigned int) - - Default: None - - Sets the camera gain setting. Valid modes are: - - "auto" - - any suitable unsigned integer + - gain (string or unsigned int) + - Default: None + - Sets the camera gain setting. Valid modes are: + - "auto" + - any suitable unsigned integer -- whitebalance (string) - - Default: None - - Sets the manual camera white balance setting. Only valid option: - - a string containing two suitable blue and red value unsigned integers + - whitebalance (string) + - Default: None + - Sets the manual camera white balance setting. Only valid option: + - a string containing two suitable blue and red value unsigned integers -- dma_buffers - - Default: 4 - - the number of DMA buffers to use + - dma_buffers + - Default: 4 + - the number of DMA buffers to use -- iso_speed (unsigned int) - - Default: 400 - - Sets the data rate of the 1394 bus. Valid rates are 100, 200, 400, 800, 1600, 3200. -@par Example + - iso_speed (unsigned int) + - Default: 400 + - Sets the data rate of the 1394 bus. Valid rates are 100, 200, 400, 800, 1600, 3200. + @par Example -@verbatim -driver -( - name "camera1394" - provides ["camera:0"] -) -@endverbatim + @verbatim + driver + ( + name "camera1394" + provides ["camera:0"] + ) + @endverbatim -@author Nate Koenig, Andrew Howard; major code rewrite by Paul Osmialowski, new...@ki... -*/ + @author Nate Koenig, Andrew Howard; major code rewrite by Paul Osmialowski, new...@ki... + */ /** @} */ #include <errno.h> @@ -169,7 +169,7 @@ #include <camera1394.h> #ifdef HAVE_LIBRAW1394 - #include <libraw1394/raw1394.h> +#include <libraw1394/raw1394.h> #endif #if DC1394_DMA_SETUP_CAPTURE_ARGS == 20 @@ -186,7 +186,6 @@ #define NUM_DMA_BUFFERS 4 - // lots of defines are renames in v2 API, mask this so we dont have to // modify all our code #if DC1394_DMA_SETUP_CAPTURE_ARGS == 20 @@ -283,1123 +282,1305 @@ #endif +const timespec NSLEEP_TIME = { 0, 10000 }; // (0s, 10ms) => max 100Hz + // Driver for detecting laser retro-reflectors. -class Camera1394 : public ThreadedDriver -{ - // Constructor - public: Camera1394( ConfigFile* cf, int section); +class Camera1394: public ThreadedDriver { + // Constructor +public: + Camera1394(ConfigFile* cf, int section); - // Setup/shutdown routines. - private: void SafeCleanup(); +public: + virtual int SetZoom(unsigned int brightness); + virtual int GetZoom(unsigned int* zoom); + virtual int SetFocus(unsigned int focus); + virtual int GetFocus(unsigned int* focus); + virtual int SetIris(unsigned int iris); + virtual int GetIris(unsigned int* iris); + virtual int SetBrightness(unsigned int brightness); + virtual int SetExposure(unsigned int brightness); + virtual int SetShutter(unsigned int brightness); + virtual int SetGain(unsigned int gain); - // Main function for device thread. - private: virtual void Main(); + // Main function for device thread. +private: + virtual void Main(); - private: virtual void MainQuit(); - public: virtual int MainSetup(); +private: + virtual void MainQuit(); + virtual int MainSetup(); + void SafeCleanup(); - // This method will be invoked on each incoming message - public: virtual int ProcessMessage(QueuePointer & resp_queue, - player_msghdr * hdr, - void * data); + // This method will be invoked on each incoming message +public: + virtual int ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr, + void * data); - // Save a frame to memory - private: int GrabFrame(); +private: + // Save a frame to memory + int GrabFrame(); - // Save a frame to disk - private: int SaveFrame( const char *filename ); + // Save a frame to disk + int SaveFrame(const char *filename); - // Update the device data (the data going back to the client). - private: void RefreshData(); + // Update the device data (the data going back to the client). + void RefreshData(); - // Video device - private: unsigned int port; - private: unsigned int node; + // Video device + unsigned int port; + unsigned int node; #ifdef HAVE_LIBRAW1394 - private: raw1394handle_t handle; +private: raw1394handle_t handle; #endif #if LIBDC1394_VERSION == 0200 - private: dc1394camera_t * camera; - // Camera features - private: dc1394featureset_t features; - private: dc1394format7modeset_t modeset; +private: dc1394camera_t * camera; + // Camera features +private: dc1394featureset_t features; +private: dc1394format7modeset_t modeset; #else - private: dc1394_cameracapture camera; - // Camera features - private: dc1394_feature_set features; +private: + dc1394_cameracapture camera; + // Camera features +private: + dc1394_feature_set features; #endif + // Capture method: RAW or VIDEO (DMA) +private: + enum { + methodRaw, methodVideo, methodNone + }; +private: + int method; +private: + bool forceRaw; - // Capture method: RAW or VIDEO (DMA) - private: enum {methodRaw, methodVideo, methodNone}; - private: int method; - private: bool forceRaw; - #if LIBDC1394_VERSION == 0200 - private: dc1394framerate_t frameRate; - private: unsigned int format; - private: dc1394video_mode_t mode; - private: dc1394speed_t iso_speed; +private: dc1394framerate_t frameRate; +private: unsigned int format; +private: dc1394video_mode_t mode; +private: dc1394speed_t iso_speed; #else - private: unsigned int frameRate; - private: unsigned int format; - private: unsigned int mode; - private: unsigned int iso_speed; +private: + unsigned int frameRate; +private: + unsigned int format; +private: + unsigned int mode; +private: + unsigned int iso_speed; #endif - // number of DMA buffers to use - private: unsigned int num_dma_buffers; + // number of DMA buffers to use +private: + unsigned int num_dma_buffers; - // Write frames to disk? - private: int save; + // Write frames to disk? +private: + int save; - // Capture timestamp - private: double frameTime; + // Capture timestamp +private: + double frameTime; - // Data to send to server - private: player_camera_data_t * data; + // Data to send to server +private: + player_camera_data_t * data; - // Bayer Colour Conversion - private: bool DoBayerConversion; - private: bayer_pattern_t BayerPattern; - private: int BayerMethod; + // Bayer Colour Conversion +private: + bool DoBayerConversion; +private: + bayer_pattern_t BayerPattern; +private: + int BayerMethod; - // Camera settings - private: bool setBrightness, setExposure, setWhiteBalance, setShutter, setGain; - private: bool autoBrightness, autoExposure, autoShutter, autoGain; - private: unsigned int brightness, exposure, redBalance, blueBalance, shutter, gain; + // Camera settings +private: + IntProperty MinZoom, MaxZoom, Zoom; + IntProperty MinFocus, MaxFocus, Focus; + IntProperty MinIris, MaxIris, Iris; + IntProperty Brightness, Exposure, RedBalance, BlueBalance, Shutter, Gain; + /* private: bool setFocus, setIris, setBrightness, setExposure, setWhiteBalance, setShutter, setGain; + private: bool autoFocus, autoIris, autoBrightness, autoExposure, autoShutter, autoGain; + private: unsigned int focus, iris, brightness, exposure, redBalance, blueBalance, shutter, gain; + private: unsigned int min_zoom, max_zoom, min_focus, max_focus, min_iris, max_iris;*/ + +private: + int frameno; }; - // Initialization function -Driver* Camera1394_Init( ConfigFile* cf, int section) -{ - return ((Driver*) (new Camera1394( cf, section))); +Driver* Camera1394_Init(ConfigFile* cf, int section) { + return ((Driver*) (new Camera1394(cf, section))); } - // a driver registration function -void camera1394_Register(DriverTable* table) -{ - table->AddDriver("camera1394", Camera1394_Init); +void camera1394_Register(DriverTable* table) { + table->AddDriver("camera1394", Camera1394_Init); } +const int PROPERTY_NOT_SET = -2; +const int PROPERTY_AUTO = -1; //////////////////////////////////////////////////////////////////////////////// // Constructor -Camera1394::Camera1394(ConfigFile* cf, int section) - : ThreadedDriver(cf, - section, - true, - PLAYER_MSGQUEUE_DEFAULT_MAXLEN, - PLAYER_CAMERA_CODE) -{ - float fps; +Camera1394::Camera1394(ConfigFile* cf, int section) : + ThreadedDriver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, + PLAYER_CAMERA_CODE), + MinZoom("min_zoom", PROPERTY_NOT_SET, true, this, cf, section), + MaxZoom("max_zoom", PROPERTY_NOT_SET, true, this, cf, section), + Zoom("zoom", PROPERTY_NOT_SET, false, this, cf, section), + MinFocus("min_focus", PROPERTY_NOT_SET, true, this, cf, section), + MaxFocus("max_focus", PROPERTY_NOT_SET, true, this, cf, section), + Focus("focus", PROPERTY_NOT_SET, false, this, cf, section), + MinIris("min_iris", PROPERTY_NOT_SET, true, this, cf, section), + MaxIris("max_iris", PROPERTY_NOT_SET, true, this, cf, section), + Iris("iris", PROPERTY_NOT_SET, false, this, cf, section), + Brightness("brightness", PROPERTY_NOT_SET, false, this, cf, section), + Exposure("exposure", PROPERTY_NOT_SET, false, this, + cf, section), RedBalance("red_balance", PROPERTY_NOT_SET, false, + this, cf, section), BlueBalance("blue_balance", PROPERTY_NOT_SET, + false, this, cf, section), Shutter("shutter", PROPERTY_NOT_SET, + false, this, cf, section), Gain("gain", PROPERTY_NOT_SET, false, + this, cf, section) { + float fps; - this->data = NULL; + this->data = NULL; #ifdef HAVE_LIBRAW1394 - this->handle = NULL; + this->handle = NULL; #endif - this->method = methodNone; + this->method = methodNone; - // The port the camera is attached to - this->port = cf->ReadInt(section, "port", 0); + // The port the camera is attached to + this->port = cf->ReadInt(section, "port", 0); - // The node inside the port - this->node = cf->ReadInt(section, "node", 0); + // The node inside the port + this->node = cf->ReadInt(section, "node", 0); - // Video frame rate - fps = cf->ReadFloat(section, "framerate", 15); - if (fps < 3.75) - this->frameRate = FRAMERATE_1_875; - else if (fps < 7.5) - this->frameRate = FRAMERATE_3_75; - else if (fps < 15) - this->frameRate = FRAMERATE_7_5; - else if (fps < 30) - this->frameRate = FRAMERATE_15; - else if (fps < 60) - this->frameRate = FRAMERATE_30; - else - this->frameRate = FRAMERATE_60; + // Video frame rate + fps = cf->ReadFloat(section, "framerate", 15); + if (fps < 3.75) + this->frameRate = FRAMERATE_1_875; + else if (fps < 7.5) + this->frameRate = FRAMERATE_3_75; + else if (fps < 15) + this->frameRate = FRAMERATE_7_5; + else if (fps < 30) + this->frameRate = FRAMERATE_15; + else if (fps < 60) + this->frameRate = FRAMERATE_30; + else + this->frameRate = FRAMERATE_60; - // Get uncompressed video - this->format = FORMAT_VGA_NONCOMPRESSED; + // Get uncompressed video + this->format = FORMAT_VGA_NONCOMPRESSED; - // Image size. This determines the capture resolution. There are a limited - // number of options available. At 640x480, a camera can capture at - // _RGB or _MONO or _MONO16. - const char* str; - str = cf->ReadString(section, "mode", "640x480_yuv422"); - /* - if (0==strcmp(str,"160x120_yuv444")) - { - this->mode = MODE_160x120_YUV444; - } - */ - if (0==strcmp(str,"320x240_yuv422")) - { - this->mode = MODE_320x240_YUV422; - } - /* - else if (0==strcmp(str,"640x480_mono16")) - { - this->mode = MODE_640x480_MONO16; - assert(false); - } - else if (0==strcmp(str,"640x480_yuv411")) - { - this->mode = MODE_640x480_YUV411; - } - */ - else if (0==strcmp(str,"640x480_mono")) - { - this->mode = MODE_640x480_MONO; - } - else if (0==strcmp(str,"640x480_yuv422")) - { - this->mode = MODE_640x480_YUV422; - } - else if (0==strcmp(str,"640x480_rgb")) - { - this->mode = MODE_640x480_RGB; - } - else if (0==strcmp(str,"800x600_mono")) - { - this->mode = MODE_800x600_MONO; - this->format = FORMAT_SVGA_NONCOMPRESSED_1; - } - else if (0==strcmp(str,"800x600_yuv422")) - { - this->mode = MODE_800x600_YUV422; - this->format = FORMAT_SVGA_NONCOMPRESSED_1; - } - else if (0==strcmp(str,"1024x768_mono")) - { - this->mode = MODE_1024x768_MONO; - this->format = FORMAT_SVGA_NONCOMPRESSED_1; - } - else if (0==strcmp(str,"1024x768_yuv422")) - { - this->mode = MODE_1024x768_YUV422; - this->format = FORMAT_SVGA_NONCOMPRESSED_1; - } - else if (0==strcmp(str,"1280x960_mono")) - { - this->mode = MODE_1280x960_MONO; - this->format = FORMAT_SVGA_NONCOMPRESSED_2; - } - else if (0==strcmp(str,"1280x960_yuv422")) - { - this->mode = MODE_1280x960_YUV422; - this->format = FORMAT_SVGA_NONCOMPRESSED_2; - } + // Image size. This determines the capture resolution. There are a limited + // number of options available. At 640x480, a camera can capture at + // _RGB or _MONO or _MONO16. + const char* str; + str = cf->ReadString(section, "mode", "640x480_yuv422"); + /* + if (0==strcmp(str,"160x120_yuv444")) + { + this->mode = MODE_160x120_YUV444; + } + */ + if (0 == strcmp(str, "320x240_yuv422")) { + this->mode = MODE_320x240_YUV422; + } + /* + else if (0==strcmp(str,"640x480_mono16")) + { + this->mode = MODE_640x480_MONO16; + assert(false); + } + else if (0==strcmp(str,"640x480_yuv411")) + { + this->mode = MODE_640x480_YUV411; + } + */ + else if (0 == strcmp(str, "640x480_mono")) { + this->mode = MODE_640x480_MONO; + } else if (0 == strcmp(str, "640x480_yuv422")) { + this->mode = MODE_640x480_YUV422; + } else if (0 == strcmp(str, "640x480_rgb")) { + this->mode = MODE_640x480_RGB; + } else if (0 == strcmp(str, "800x600_mono")) { + this->mode = MODE_800x600_MONO; + this->format = FORMAT_SVGA_NONCOMPRESSED_1; + } else if (0 == strcmp(str, "800x600_yuv422")) { + this->mode = MODE_800x600_YUV422; + this->format = FORMAT_SVGA_NONCOMPRESSED_1; + } else if (0 == strcmp(str, "1024x768_mono")) { + this->mode = MODE_1024x768_MONO; + this->format = FORMAT_SVGA_NONCOMPRESSED_1; + } else if (0 == strcmp(str, "1024x768_yuv422")) { + this->mode = MODE_1024x768_YUV422; + this->format = FORMAT_SVGA_NONCOMPRESSED_1; + } else if (0 == strcmp(str, "1280x960_mono")) { + this->mode = MODE_1280x960_MONO; + this->format = FORMAT_SVGA_NONCOMPRESSED_2; + } else if (0 == strcmp(str, "1280x960_yuv422")) { + this->mode = MODE_1280x960_YUV422; + this->format = FORMAT_SVGA_NONCOMPRESSED_2; + } #if LIBDC1394_VERSION == 0200 - else if (0==strcmp(str,"FORMAT7_MODE0")) - { - this->mode = MODE_FORMAT7_0; - this->format = FORMAT_7; - } + else if (0==strcmp(str,"FORMAT7_MODE0")) + { + this->mode = MODE_FORMAT7_0; + this->format = FORMAT_7; + } #endif - else - { - PLAYER_ERROR1("unknown video mode [%s]", str); - this->SetError(-1); - return; - } + else { + PLAYER_ERROR1("unknown video mode [%s]", str); + this->SetError(-1); + return; + } - // Many cameras such as the Pt Grey Dragonfly and Bumblebee devices - // don't do onchip colour conversion. Various Bayer colour encoding - // patterns and decoding methods exist. They are now presented to the - // user as config file options. - // check Bayer colour decoding option - str = cf->ReadString(section, "bayer", "NONE"); - this->DoBayerConversion = false; - if (strcmp(str,"NONE")) - { - if (!strcmp(str,"BGGR")) - { - this->DoBayerConversion = true; - this->BayerPattern = BAYER_PATTERN_BGGR; - } - else if (!strcmp(str,"GRBG")) - { - this->DoBayerConversion = true; - this->BayerPattern = BAYER_PATTERN_GRBG; - } - else if (!strcmp(str,"RGGB")) - { - this->DoBayerConversion = true; - this->BayerPattern = BAYER_PATTERN_RGGB; - } - else if (!strcmp(str,"GBRG")) - { - this->DoBayerConversion = true; - this->BayerPattern = BAYER_PATTERN_GBRG; - } - else - { - PLAYER_ERROR1("unknown bayer pattern [%s]", str); - this->SetError(-1); - return; - } - } - // Set default Bayer decoding method - if (this->DoBayerConversion) - this->BayerMethod = BAYER_DECODING_DOWNSAMPLE; - else - this->BayerMethod = NO_BAYER_DECODING; - // Check for user selected method - str = cf->ReadString(section, "method", "NONE"); - if (strcmp(str,"NONE")) - { - if (!this->DoBayerConversion) - { - PLAYER_ERROR1("bayer method [%s] specified without enabling bayer conversion", str); - this->SetError(-1); - return; - } - if (!strcmp(str,"DownSample")) - { - this->BayerMethod = BAYER_DECODING_DOWNSAMPLE; - } - else if (!strcmp(str,"Nearest")) - { - this->BayerMethod = BAYER_DECODING_NEAREST; - } - else if (!strcmp(str,"Edge")) - { - this->BayerMethod = BAYER_DECODING_EDGE_SENSE; - } - else - { - PLAYER_ERROR1("unknown bayer method [%s]", str); - this->SetError(-1); - return; - } - } + // Many cameras such as the Pt Grey Dragonfly and Bumblebee devices + // don't do onchip colour conversion. Various Bayer colour encoding + // patterns and decoding methods exist. They are now presented to the + // user as config file options. + // check Bayer colour decoding option + str = cf->ReadString(section, "bayer", "NONE"); + this->DoBayerConversion = false; + if (strcmp(str, "NONE")) { + if (!strcmp(str, "BGGR")) { + this->DoBayerConversion = true; + this->BayerPattern = BAYER_PATTERN_BGGR; + } else if (!strcmp(str, "GRBG")) { + this->DoBayerConversion = true; + this->BayerPattern = BAYER_PATTERN_GRBG; + } else if (!strcmp(str, "RGGB")) { + this->DoBayerConversion = true; + this->BayerPattern = BAYER_PATTERN_RGGB; + } else if (!strcmp(str, "GBRG")) { + this->DoBayerConversion = true; + this->BayerPattern = BAYER_PATTERN_GBRG; + } else { + PLAYER_ERROR1("unknown bayer pattern [%s]", str); + this->SetError(-1); + return; + } + } + // Set default Bayer decoding method + if (this->DoBayerConversion) + this->BayerMethod = BAYER_DECODING_DOWNSAMPLE; + else + this->BayerMethod = NO_BAYER_DECODING; + // Check for user selected method + str = cf->ReadString(section, "method", "NONE"); + if (strcmp(str, "NONE")) { + if (!this->DoBayerConversion) { + PLAYER_ERROR1( + "bayer method [%s] specified without enabling bayer conversion", + str); + this->SetError(-1); + return; + } + if (!strcmp(str, "DownSample")) { + this->BayerMethod = BAYER_DECODING_DOWNSAMPLE; + } else if (!strcmp(str, "Nearest")) { + this->BayerMethod = BAYER_DECODING_NEAREST; + } else if (!strcmp(str, "Edge")) { + this->BayerMethod = BAYER_DECODING_EDGE_SENSE; + } else { + PLAYER_ERROR1("unknown bayer method [%s]", str); + this->SetError(-1); + return; + } + } - // Allow the user to set useful camera setting options - // brightness, exposure, redBalance, blueBalance, shutter and gain - // Parse camera settings - default is to leave them alone. - str = cf->ReadString(section, "brightness", "NONE"); - if (strcmp(str,"NONE")) - { - if (!strcmp(str,"auto")) - { - this->setBrightness=true; - this->autoBrightness=true; - } - else - { - this->setBrightness=true; - this->autoBrightness=false; - this->brightness = atoi(str); - } - } - str = cf->ReadString(section, "exposure", "NONE"); - if (strcmp(str,"NONE")) - { - if (!strcmp(str,"auto")) - { - this->setExposure=true; - this->autoExposure=true; - } - else - { - this->setExposure=true; - this->autoExposure=false; - this->exposure = atoi(str); - } - } - str = cf->ReadString(section, "shutter", "NONE"); - if (strcmp(str,"NONE")) - { - if (!strcmp(str,"auto")) - { - this->setShutter=true; - this->autoShutter=true; - } - else - { - this->setShutter=true; - this->autoShutter=false; - this->shutter = atoi(str); - } - } - str = cf->ReadString(section, "gain", "NONE"); - if (strcmp(str,"NONE")) - { - if (!strcmp(str,"auto")) - { - this->setGain=true; - this->autoGain=true; - } - else - { - this->setGain=true; - this->autoGain=false; - this->gain = atoi(str); - } - } - str = cf->ReadString(section, "whitebalance", "NONE"); - if (strcmp(str,"NONE")) - { - if(sscanf(str,"%u %u",&this->blueBalance,&this->redBalance)==2) - this->setWhiteBalance=true; - else - PLAYER_ERROR1("didn't understand white balance values [%s]", str); - } + // Force into raw mode + this->forceRaw = cf->ReadInt(section, "force_raw", 0); - // Force into raw mode - this->forceRaw = cf->ReadInt(section, "force_raw", 0); + // Save frames? + this->save = cf->ReadInt(section, "save", 0); - // Save frames? - this->save = cf->ReadInt(section, "save", 0); + // Number of DMA buffers? + this->num_dma_buffers + = cf->ReadInt(section, "dma_buffers", NUM_DMA_BUFFERS); - // Number of DMA buffers? - this->num_dma_buffers = cf->ReadInt(section, "dma_buffers", NUM_DMA_BUFFERS); - - // ISO Speed? - switch(cf->ReadInt(section, "iso_speed", 400)) { - case 100: - this->iso_speed = DC1394_ISO_SPEED_100; - break; - case 200: - this->iso_speed = DC1394_ISO_SPEED_200; - break; - case 400: - this->iso_speed = DC1394_ISO_SPEED_400; - break; + // ISO Speed? + switch (cf->ReadInt(section, "iso_speed", 400)) { + case 100: + this->iso_speed = DC1394_ISO_SPEED_100; + break; + case 200: + this->iso_speed = DC1394_ISO_SPEED_200; + break; + case 400: + this->iso_speed = DC1394_ISO_SPEED_400; + break; #ifdef DC1394_ISO_SPEED_800 - case 800: - this->iso_speed = DC1394_ISO_SPEED_800; - break; + case 800: + this->iso_speed = DC1394_ISO_SPEED_800; + break; #endif #ifdef DC1394_ISO_SPEED_1600 - case 1600: - this->iso_speed = DC1394_ISO_SPEED_1600; - break; + case 1600: + this->iso_speed = DC1394_ISO_SPEED_1600; + break; #endif #ifdef DC1394_ISO_SPEED_3200 - case 3200: - this->iso_speed = DC1394_ISO_SPEED_3200; - break; + case 3200: + this->iso_speed = DC1394_ISO_SPEED_3200; + break; #endif - default: - PLAYER_ERROR("Unsupported iso_speed"); - this->SetError(-1); - return; - } + default: + PLAYER_ERROR("Unsupported iso_speed"); + this->SetError(-1); + return; + } - return; + return; } //////////////////////////////////////////////////////////////////////////////// // Safe Cleanup -void Camera1394::SafeCleanup() -{ +void Camera1394::SafeCleanup() { #if LIBDC1394_VERSION == 0200 - if (this->camera) - { - //dc1394_cleanup_iso_channels_and_bandwidth(camera); - /* The above function has been removed from libdc1394 without a clear - replacement... - http://sourceforge.net/mailarchive/message.php?msg_id=1196638611.10412.31.camel%40pisces.mit.edu - */ - switch (this->method) - { - case methodRaw: - //dc1394_release_camera(this->camera); - break; - case methodVideo: - //dc1394_dma_unlisten(this->camera); - //dc1394_dma_release_camera(this->camera); - break; - } - dc1394_camera_free(this->camera); - } - this->camera = NULL; + if (this->camera) + { + //dc1394_cleanup_iso_channels_and_bandwidth(camera); + /* The above function has been removed from libdc1394 without a clear + replacement... + http://sourceforge.net/mailarchive/message.php?msg_id=1196638611.10412.31.camel%40pisces.mit.edu + */ + switch (this->method) + { + case methodRaw: + //dc1394_release_camera(this->camera); + break; + case methodVideo: + //dc1394_dma_unlisten(this->camera); + //dc1394_dma_release_camera(this->camera); + break; + } + dc1394_camera_free(this->camera); + } + this->camera = NULL; #else - if (this->handle) - { - switch (this->method) - { - case methodRaw: - dc1394_release_camera(this->handle, &this->camera); - break; - case methodVideo: - dc1394_dma_unlisten(this->handle, &this->camera); - dc1394_dma_release_camera(this->handle, &this->camera); - break; - } - dc1394_destroy_handle(this->handle); - } - this->handle = NULL; + if (this->handle) { + switch (this->method) { + case methodRaw: + dc1394_release_camera(this->handle, &this->camera); + break; + case methodVideo: + dc1394_dma_unlisten(this->handle, &this->camera); + dc1394_dma_release_camera(this->handle, &this->camera); + break; + } + dc1394_destroy_handle(this->handle); + } + this->handle = NULL; #endif - if (this->data) - { - if (this->data->image) delete[](this->data->image); - this->data->image = NULL; - delete (this->data); - } - this->data = NULL; + if (this->data) { + // if (this->data->image) delete[](this->data->image); + if (this->data->image) + free(this->data->image); + this->data->image = NULL; + // delete (this->data); + free(this->data); + } + this->data = NULL; } -//////////////////////////////////////////////////////////////////////////////// -// Set up the device (called by server thread). -int Camera1394::MainSetup() -{ +int Camera1394::SetZoom(unsigned int zoom) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_ZOOM, zoom)) +#else + if (DC1394_SUCCESS + != dc1394_set_zoom(this->handle, this->camera.node, zoom)) +#endif + { + PLAYER_ERROR("Unable to set Zoom value"); + return -1; + } + return 0; +} +int Camera1394::GetZoom(unsigned int* zoom) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_get_value(this->camera, FEATURE_ZOOM, zoom)) +#else + if (DC1394_SUCCESS + != dc1394_get_zoom(this->handle, this->camera.node, zoom)) +#endif + { + PLAYER_ERROR("Unable to get Zoom value"); + return -1; + } + return 0; +} +int Camera1394::SetFocus(unsigned int focus) { + bool autoFocus = focus < 0; #if LIBDC1394_VERSION == 0200 - dc1394speed_t speed; + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_FOCUS,autoFocus ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) #else - unsigned int channel, speed; + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_FOCUS, autoFocus)) #endif + { + PLAYER_ERROR("Unable to set Focus mode"); + this->SafeCleanup(); + return -1; + } + if (!autoFocus) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_FOCUS, focus)) +#else + if (DC1394_SUCCESS != dc1394_set_focus(this->handle, this->camera.node, + focus)) +#endif + { + PLAYER_ERROR("Unable to set Focus value"); + return -1; + } + } + return 0; +} - // Create a handle for the given port (port will be zero on most - // machines) +int Camera1394::GetFocus(unsigned int* focus) { #if LIBDC1394_VERSION == 0200 - // First we try to find a camera - int err; - dc1394_t *d; - dc1394camera_list_t *list; + if (DC1394_SUCCESS != dc1394_feature_get_value(this->camera, FEATURE_FOCUS, focus)) +#else + if (DC1394_SUCCESS != dc1394_get_focus(this->handle, this->camera.node, + focus)) +#endif + { + PLAYER_ERROR("Unable to get Focus value"); + return -1; + } + return 0; +} - d = dc1394_new (); - err = dc1394_camera_enumerate (d, &list); - if (err != DC1394_SUCCESS) - { - PLAYER_ERROR1("Could not get Camera List: %d\n", err); - return -1; - } +int Camera1394::SetIris(unsigned int iris) { + bool autoIris = iris < 0; +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_IRIS,autoIris ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) +#else + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_IRIS, autoIris)) +#endif + { + PLAYER_ERROR("Unable to set Iris mode"); + this->SafeCleanup(); + return -1; + } - if (list->num == 0) - { - PLAYER_ERROR("No cameras found"); - return -1; - } + if (!autoIris) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_IRIS, iris)) +#else + if (DC1394_SUCCESS != dc1394_set_iris(this->handle, this->camera.node, + iris)) +#endif + { + PLAYER_ERROR("Unable to set Iris value"); + return -1; + } + } + return 0; +} - for (int i=0; i < list->num; i++) - { - uint32_t camNode, camGeneration; +int Camera1394::GetIris(unsigned int* iris) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_get_value(this->camera, FEATURE_IRIS, iris)) +#else + if (DC1394_SUCCESS + != dc1394_get_iris(this->handle, this->camera.node, iris)) +#endif + { + PLAYER_ERROR("Unable to set Iris value"); + return -1; + } + return 0; +} - // Create a camera - this->camera = dc1394_camera_new (d, list->ids[this->node].guid); +int Camera1394::SetBrightness(unsigned int brightness) { + bool autoBrightness = brightness < 0; - // Get the node of the camera - dc1394_camera_get_node(this->camera, &camNode, &camGeneration); +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_BRIGHTNESS,autoBrightness ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) +#else + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_BRIGHTNESS, autoBrightness)) +#endif + { + PLAYER_ERROR("Unable to set Brightness mode"); + this->SafeCleanup(); + return -1; + } - // Make sure we have the correct camera - if (camNode == this->node) - break; - else - dc1394_camera_free(this->camera); - } + if (!autoBrightness) { +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_BRIGHTNESS, brightness)) +#else + if (DC1394_SUCCESS != dc1394_set_brightness(this->handle, + this->camera.node, brightness)) +#endif + { + PLAYER_ERROR("Unable to set Brightness value"); + return -1; + } + } + return 0; +} - if (!camera) - { - PLAYER_ERROR1("Failed to initialize camera with guid %llx", - list->ids[0].guid); - this->SafeCleanup(); - return -1; - } +int Camera1394::SetExposure(unsigned int exposure) { + bool autoExposure = exposure < 0; - dc1394_camera_free_list (list); - - //dc1394_cleanup_iso_channels_and_bandwidth(camera); - /* Above has been removed from API. */ - +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_EXPOSURE,autoExposure ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) #else - this->handle = dc1394_create_handle(this->port); - if (this->handle == NULL) - { - PLAYER_ERROR("Unable to acquire a dc1394 handle"); - this->SafeCleanup(); - return -1; - } - - this->camera.node = this->node; - this->camera.port = this->port; + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_EXPOSURE, autoExposure)) #endif + { + PLAYER_ERROR("Unable to set Exposure mode"); + this->SafeCleanup(); + return -1; + } - // apply user config file provided camera settings - if (this->setBrightness) - { + if (!autoExposure) { #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_BRIGHTNESS,this->autoBrightness ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_EXPOSURE, exposure)) #else - if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node,FEATURE_BRIGHTNESS,this->autoBrightness)) + if (DC1394_SUCCESS != dc1394_set_exposure(this->handle, + this->camera.node, exposure)) #endif - { - PLAYER_ERROR("Unable to set Brightness mode"); - this->SafeCleanup(); - return -1; - } - if (!this->autoBrightness) - { + { + PLAYER_ERROR("Unable to set Exposure value"); + return -1; + } + } + return 0; +} + +int Camera1394::SetShutter(unsigned int shutter) { + bool autoShutter = shutter < 0; + #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_BRIGHTNESS,this->brightness)) + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_SHUTTER,autoShutter ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) #else - if (DC1394_SUCCESS != dc1394_set_brightness(this->handle, this->camera.node,this->brightness)) + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_SHUTTER, autoShutter)) #endif - { - PLAYER_ERROR("Unable to set Brightness value"); - this->SafeCleanup(); - return -1; - } - } - } - if (this->setExposure) - { + { + PLAYER_ERROR("Unable to set Shutter mode"); + this->SafeCleanup(); + return -1; + } + if (!autoShutter) { #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_EXPOSURE,this->autoExposure ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_SHUTTER, shutter)) #else - if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node,FEATURE_EXPOSURE,this->autoExposure)) + if (DC1394_SUCCESS != dc1394_set_shutter(this->handle, + this->camera.node, shutter)) #endif - { - PLAYER_ERROR("Unable to set Exposure mode"); - this->SafeCleanup(); - return -1; - } - if (!this->autoExposure) - { + { + PLAYER_ERROR("Unable to set Shutter value"); + return -1; + } + } + return 0; +} + +int Camera1394::SetGain(unsigned int gain) { + bool autoGain = gain < 0; + #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_EXPOSURE,this->exposure)) + if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_GAIN,autoGain ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) #else - if (DC1394_SUCCESS != dc1394_set_exposure(this->handle, this->camera.node,this->exposure)) + if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node, + FEATURE_GAIN, autoGain)) #endif - { - PLAYER_ERROR("Unable to set Exposure value"); - this->SafeCleanup(); - return -1; - } - } - } - if (this->setShutter) - { + { + PLAYER_ERROR("Unable to set Gain mode"); + this->SafeCleanup(); + return -1; + } + if (!autoGain) { #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_SHUTTER,this->autoShutter ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) + if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_GAIN,gain)) #else - if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node,FEATURE_SHUTTER,this->autoShutter)) + if (DC1394_SUCCESS != dc1394_set_gain(this->handle, this->camera.node, + this->gain)) #endif - { - PLAYER_ERROR("Unable to set Shutter mode"); - this->SafeCleanup(); - return -1; + { + PLAYER_ERROR("Unable to Gain value"); + this->SafeCleanup(); + return -1; } - if (!this->autoShutter) - { + } + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set up the device (called by server thread). +int Camera1394::MainSetup() { + #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_SHUTTER,this->shutter)) + dc1394speed_t speed; #else - if (DC1394_SUCCESS != dc1394_set_shutter(this->handle, this->camera.node,this->shutter)) + unsigned int channel, speed; #endif - { - PLAYER_ERROR("Unable to set Shutter value"); - this->SafeCleanup(); - return -1; - } - } - } - if (this->setGain) - { + + // Create a handle for the given port (port will be zero on most + // machines) #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera, FEATURE_GAIN,this->autoGain ? DC1394_FEATURE_MODE_AUTO : DC1394_FEATURE_MODE_MANUAL)) + // First we try to find a camera + int err; + dc1394_t *d; + dc1394camera_list_t *list; + + d = dc1394_new (); + err = dc1394_camera_enumerate (d, &list); + if (err != DC1394_SUCCESS) + { + PLAYER_ERROR1("Could not get Camera List: %d\n", err); + return -1; + } + + if (list->num == 0) + { + PLAYER_ERROR("No cameras found"); + return -1; + } + + for (unsigned i=0; i < list->num; i++) + { + uint32_t camNode, camGeneration; + + // Create a camera + this->camera = dc1394_camera_new (d, list->ids[this->node].guid); + + // Get the node of the camera + dc1394_camera_get_node(this->camera, &camNode, &camGeneration); + + // Make sure we have the correct camera + if (camNode == this->node) + break; + else + dc1394_camera_free(this->camera); + } + + if (!camera) + { + PLAYER_ERROR1("Failed to initialize camera with guid %llx", + list->ids[0].guid); + this->SafeCleanup(); + return -1; + } + + dc1394_camera_free_list (list); + + //dc1394_cleanup_iso_channels_and_bandwidth(camera); + /* Above has been removed from API. */ + #else - if (DC1394_SUCCESS != dc1394_auto_on_off(this->handle, this->camera.node,FEATURE_GAIN,this->autoGain)) + this->handle = dc1394_create_handle(this->port); + if (this->handle == NULL) { + PLAYER_ERROR("Unable to acquire a dc1394 handle"); + this->SafeCleanup(); + return -1; + } + + this->camera.node = this->node; + this->camera.port = this->port; #endif - { - PLAYER_ERROR("Unable to set Gain mode"); - this->SafeCleanup(); - return -1; + + // apply user config file provided camera settings + if (Focus != PROPERTY_NOT_SET) { + if (SetFocus(Focus)) { + this->SafeCleanup(); + return -1; } - if (!this->autoShutter) - { + } + if (Iris != PROPERTY_NOT_SET) { + if (SetIris(Iris)) { + // error + this->SafeCleanup(); + return -1; + } + } + if (Brightness != PROPERTY_NOT_SET) { + if (SetBrightness(Brightness)) { + this->SafeCleanup(); + return -1; + } + } + if (Exposure != PROPERTY_NOT_SET) { + if (SetExposure(Exposure)) { + this->SafeCleanup(); + return -1; + } + } + if (Shutter != PROPERTY_NOT_SET) { + if (SetShutter(Shutter)) { + this->SafeCleanup(); + return -1; + } + } + if (Gain != PROPERTY_NOT_SET) { + if (SetGain(Gain)) { + this->SafeCleanup(); + return -1; + } + } + + if (BlueBalance != PROPERTY_NOT_SET && RedBalance != PROPERTY_NOT_SET) { #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera, FEATURE_GAIN,this->gain)) + if (DC1394_SUCCESS != dc1394_feature_whitebalance_set_value(this->camera,this->BlueBalance,this->RedBalance)) #else - if (DC1394_SUCCESS != dc1394_set_gain(this->handle, this->camera.node,this->gain)) + if (DC1394_SUCCESS != dc1394_set_white_balance(this->handle, + this->camera.node, this->BlueBalance, this->RedBalance)) #endif - { - PLAYER_ERROR("Unable to Gain value"); - this->SafeCleanup(); - return -1; - } - } - } - if (this->setWhiteBalance) - { + { + PLAYER_ERROR("Unable to set White Balance"); + this->SafeCleanup(); + return -1; + } + } + + // Collects the available features for the camera described by node and + // stores them in features. #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_whitebalance_set_value(this->camera,this->blueBalance,this->redBalance)) + if (DC1394_SUCCESS != dc1394_feature_get_all(camera, &this->features)) #else - if (DC1394_SUCCESS != dc1394_set_white_balance(this->handle, this->camera.node,this->blueBalance,this->redBalance)) + if (DC1394_SUCCESS != dc1394_get_camera_feature_set(this->handle, + this->camera.node, &this->features)) #endif - { - PLAYER_ERROR("Unable to set White Balance"); - this->SafeCleanup(); - return -1; - } - } + { + PLAYER_ERROR("Unable to get feature set"); + this->SafeCleanup(); + return -1; + } - // Collects the available features for the camera described by node and - // stores them in features. + uint32_t min_zoom, max_zoom; #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_feature_get_all(camera, &this->features)) + if (DC1394_SUCCESS != dc1394_feature_get_boundaries(camera, FEATURE_ZOOM, &min_zoom, &max_zoom)) #else - if (DC1394_SUCCESS != dc1394_get_camera_feature_set(this->handle, - this->camera.node, - &this->features)) + if ((DC1394_SUCCESS != dc1394_get_min_value(this->handle, + this->camera.node, FEATURE_ZOOM, &min_zoom)) + || (DC1394_SUCCESS != dc1394_get_max_value(this->handle, + this->camera.node, FEATURE_ZOOM, &max_zoom))) #endif - { - PLAYER_ERROR("Unable to get feature set"); - this->SafeCleanup(); - return -1; - } + { + PLAYER_ERROR("Unable to get zoom boundaries"); + this->SafeCleanup(); + return -1; + } + MinZoom = min_zoom; + MaxZoom = max_zoom; - // TODO: need to indicate what formats the camera supports somewhere - // Remove; leave? - + uint32_t min_focus,max_focus; #if LIBDC1394_VERSION == 0200 - // if format 7 requested check that it is supported - if (FORMAT_7==this->format && DC1394_SUCCESS!=dc1394_format7_get_modeset(camera, &modeset)) - { - bool HasMode7 = false; - for (unsigned int i=0;i<DC1394_VIDEO_MODE_FORMAT7_NUM;i++) - { - if (modeset.mode[i].present!=0) - { - HasMode7 = true; - break; - } - } - if (!HasMode7) - { - PLAYER_ERROR("Could not set Format 7"); - this->SafeCleanup(); - return -1; - } - } + if (DC1394_SUCCESS != dc1394_feature_get_boundaries(camera, FEATURE_FOCUS, &min_focus, &max_focus)) +#else + if ((DC1394_SUCCESS != dc1394_get_min_value(this->handle, + this->camera.node, FEATURE_FOCUS, &min_focus)) + || (DC1394_SUCCESS != dc1394_get_max_value(this->handle, + this->camera.node, FEATURE_FOCUS, &max_focus))) #endif + { + PLAYER_ERROR("Unable to get focus boundaries"); + this->SafeCleanup(); + return -1; + } + MinFocus = min_focus; + MaxFocus = max_focus; - // Get the ISO channel and speed of the video + uint32_t min_iris, max_iris; #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_video_get_iso_speed(this->camera, &speed)) + if (DC1394_SUCCESS != dc1394_feature_get_boundaries(camera, FEATURE_IRIS, &min_iris, &max_iris)) #else - if (DC1394_SUCCESS != dc1394_get_iso_channel_and_speed(this->handle, this->camera.node, - &channel, &speed)) + if ((DC1394_SUCCESS != dc1394_get_min_value(this->handle, + this->camera.node, FEATURE_IRIS, &min_iris)) + || (DC1394_SUCCESS != dc1394_get_max_value(this->handle, + this->camera.node, FEATURE_IRIS, &max_iris))) #endif - { - PLAYER_ERROR("Unable to get iso data; is the camera plugged in?"); - this->SafeCleanup(); - return -1; - } + { + PLAYER_ERROR("Unable to get iris boundaries"); + this->SafeCleanup(); + return -1; + } + MinIris = min_iris; + MaxIris = max_iris; + // TODO: need to indicate what formats the camera supports somewhere + // Remove; leave? -#if DC1394_DMA_SETUP_CAPTURE_ARGS == 11 - // Set camera to use DMA, improves performance. - if (!this->forceRaw && - dc1394_dma_setup_capture(this->handle, this->camera.node, channel, - this->format, this->mode, this->iso_speed, - this->frameRate, this->num_dma_buffers, 1, NULL, - &this->camera) == DC1394_SUCCESS) -#elif DC1394_DMA_SETUP_CAPTURE_ARGS == 12 - // Set camera to use DMA, improves performance. - if (!this->forceRaw && - dc1394_dma_setup_capture(this->handle, this->camera.node, channel, - this->format, this->mode, this->iso_speed, - this->frameRate, this->num_dma_buffers, 1, 0, NULL, - &this->camera) == DC1394_SUCCESS) -#elif LIBDC1394_VERSION == 0200 - // Set camera to use DMA, improves performance. - bool DMA_Success = true; - if (!this->forceRaw) - { - // first set parameters that are common between format 7 and other modes - if (DC1394_SUCCESS != dc1394_video_set_framerate(camera,frameRate)) +#if LIBDC1394_VERSION == 0200 + // if format 7 requested check that it is supported + if (FORMAT_7==this->format && DC1394_SUCCESS!=dc1394_format7_get_modeset(camera, &modeset)) { - PLAYER_WARN("1394 failed to set frameRate"); - DMA_Success = false; + bool HasMode7 = false; + for (unsigned int i=0;i<DC1394_VIDEO_MODE_FORMAT7_NUM;i++) + { + if (modeset.mode[i].present!=0) + { + HasMode7 = true; + break; + } + } + if (!HasMode7) + { + PLAYER_ERROR("Could not set Format 7"); + this->SafeCleanup(); + return -1; + } } - if (DC1394_SUCCESS != dc1394_video_set_iso_speed(camera,this->iso_speed)) +#endif + + // Get the ISO channel and speed of the video +#if LIBDC1394_VERSION == 0200 + if (DC1394_SUCCESS != dc1394_video_get_iso_speed(this->camera, &speed)) +#else + if (DC1394_SUCCESS != dc1394_get_iso_channel_and_speed(this->handle, + this->camera.node, &channel, &speed)) +#endif { - PLAYER_WARN("1394 failed to set iso speed"); - DMA_Success = false; + PLAYER_ERROR("Unable to get iso data; is the camera plugged in?"); + this->SafeCleanup(); + return -1; } - if (DC1394_SUCCESS != dc1394_video_set_mode(camera,mode)) + +#if DC1394_DMA_SETUP_CAPTURE_ARGS == 11 + // Set camera to use DMA, improves performance. + if (!this->forceRaw && + dc1394_dma_setup_capture(this->handle, this->camera.node, channel, + this->format, this->mode, this->iso_speed, + this->frameRate, this->num_dma_buffers, 1, NULL, + &this->camera) == DC1394_SUCCESS) +#elif DC1394_DMA_SETUP_CAPTURE_ARGS == 12 + // Set camera to use DMA, improves performance. + if (!this->forceRaw && + dc1394_dma_setup_capture(this->handle, this->camera.node, channel, + this->format, this->mode, this->iso_speed, + this->frameRate, this->num_dma_buffers, 1, 0, NULL, + &this->camera) == DC1394_SUCCESS) +#elif LIBDC1394_VERSION == 0200 + // Set camera to use DMA, improves performance. + bool DMA_Success = true; + if (!this->forceRaw) { - PLAYER_WARN("1394 failed to set mode"); + // first set parameters that are common between format 7 and other modes + if (DC1394_SUCCESS != dc1394_video_set_framerate(camera,frameRate)) + { + PLAYER_WARN("1394 failed to set frameRate"); + DMA_Success = false; + } + if (DC1394_SUCCESS != dc1394_video_set_iso_speed(camera,this->iso_speed)) + { + PLAYER_WARN("1394 failed to set iso speed"); + DMA_Success = false; + } + if (DC1394_SUCCESS != dc1394_video_set_mode(camera,mode)) + { + PLAYER_WARN("1394 failed to set mode"); + DMA_Success = false; + } + + // now start capture + if (DC1394_SUCCESS != dc1394_capture_setup(camera, this->num_dma_buffers, DC1394_CAPTURE_FLAGS_DEFAULT)) DMA_Success = false; } - - // now start capture - if (DC1394_SUCCESS != dc1394_capture_setup(camera, this->num_dma_buffers, DC1394_CAPTURE_FLAGS_DEFAULT)) - DMA_Success = false; - } - if (DMA_Success) + if (DMA_Success) #else - if (0) + if (0) #endif - { - this->method = methodVideo; - } - else - { - PLAYER_WARN("DMA capture failed; falling back on RAW method"); + { + this->method = methodVideo; + } else { + PLAYER_WARN("DMA capture failed; falling back on RAW method"); - // Set camera to use RAW method (fallback) + // Set camera to use RAW method (fallback) #if LIBDC1394_VERSION == 0200 - if (0) + if (0) #else - if (dc1394_setup_capture(this->handle, this->camera.node, channel, - this->format, this->mode, SPEED_400, this->frameRate, - &this->camera) == DC1394_SUCCESS) + if (dc1394_setup_capture(this->handle, this->camera.node, channel, + this->format, this->mode, SPEED_400, this->frameRate, + &this->camera) == DC1394_SUCCESS) #endif - { - this->method = methodRaw; - } - else - { - PLAYER_ERROR("unable to open camera in VIDE0 or RAW modes"); - this->SafeCleanup(); - return -1; - } - } + { + this->method = methodRaw; + } else { + PLAYER_ERROR("unable to open camera in VIDE0 or RAW modes"); + this->SafeCleanup(); + return -1; + } + } - // Start transmitting camera data + // Start transmitting camera data #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_video_set_transmission(this->camera, DC1394_ON)) + if (DC1394_SUCCESS != dc1394_video_set_transmission(this->camera, DC1394_ON)) #else - if (DC1394_SUCCESS != dc1394_start_iso_transmission(this->handle, this->camera.node)) + if (DC1394_SUCCESS != dc1394_start_iso_transmission(this->handle, + this->camera.node)) #endif - { - PLAYER_ERROR("unable to start camera"); - this->SafeCleanup(); - return -1; - } - return 0; + { + PLAYER_ERROR("unable to start camera"); + this->SafeCleanup(); + return -1; + } + return 0; } -void Camera1394::MainQuit() -{ +void Camera1394::MainQuit() { - // Stop transmitting camera data + // Stop transmitting camera data #if LIBDC1394_VERSION == 0200 - if (DC1394_SUCCESS != dc1394_video_set_transmission(this->camera, DC1394_OFF) - || DC1394_SUCCESS != dc1394_capture_stop(this->camera)) + if (DC1394_SUCCESS != dc1394_video_set_transmission(this->camera, DC1394_OFF) + || DC1394_SUCCESS != dc1394_capture_stop(this->camera)) #else - if (dc1394_stop_iso_transmission(this->handle, this->camera.node) != DC1394_SUCCESS) + if (dc1394_stop_iso_transmission(this->handle, this->camera.node) + != DC1394_SUCCESS) #endif - PLAYER_WARN("unable to stop camera"); + PLAYER_WARN("unable to stop camera"); - // Free resources - this->SafeCleanup(); + // Free resources + this->SafeCleanup(); } - //////////////////////////////////////////////////////////////////////////////// // Main function for device thread -void Camera1394::Main() -{ - char filename[255]; - int frameno; +void Camera1394::Main() { + // char filename[255]; + // int frameno; - frameno = 0; - //struct timeval now,old; - while (true) - { + frameno = 0; + //struct timeval now,old; + while (true) { - // Go to sleep for a while (this is a polling loop). - // We shouldn't need to sleep if GrabFrame is blocking. - //nanosleep(&NSLEEP_TIME, NULL); + // Go to sleep for a while (this is a polling loop). + // We shouldn't need to sleep if GrabFrame is blocking. + nanosleep(&NSLEEP_TIME, NULL); - // Test if we are supposed to cancel this thread. - pthread_testcancel(); + // Test if we are supposed to cancel this thread. + pthread_testcancel(); - // Process any pending requests. - ProcessMessages(); + // Process any pending requests. + ProcessMessages(); - // Grab the next frame (blocking) - this->GrabFrame(); + // grab and save frame within RefreshData() + // // Grab the next frame (blocking) + // this->GrabFrame(); - // this should go or be replaced - // Save frames; must be done after writedata (which will byteswap) - if (this->save) - { - //printf("click %d\n", frameno); - snprintf(filename, sizeof(filename), "click-%04d.ppm", frameno++); - this->SaveFrame(filename); - } + // // this should go or be replaced + // // Save frames; must be done after writedata (which will byteswap) + // if (this->save) + // { + // //printf("click %d\n", frameno); + // snprintf(filename, sizeof(filename), "click-%04d.ppm", frameno++); + // this->SaveFrame(filename); + // } - // Write data to server - this->RefreshData(); + // Write data to server + this->RefreshData(); - /* - gettimeofday(&now,NULL); - printf("dt = %lf\n",now.tv_sec-old.tv_sec+(now.tv_usec-old.tv_usec)*1.0e-6); - old=now; - */ - } - printf("Camera1394::main() exited\n"); + /* + gettimeofday(&now,NULL); + printf("dt = %lf\n",now.tv_sec-old.tv_sec+(now.tv_usec-old.tv_usec)*1.0e-6); + old=now; + */ + } + printf("Camera1394::main() exited\n"); } - //////////////////////////////////////////////////////////////////////////////// // Process an incoming message -int Camera1394::ProcessMessage(QueuePointer & resp_queue, - player_msghdr * hdr, - void * data) -{ - assert(hdr); +int Camera1394::ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr, + void * data) { + assert(hdr); - /* We currently don't support any messages, but if we do... - if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, - PLAYER_FIDUCIAL_REQ_GET_GEOM, this->device_addr)) - { - assert(hdr->size == sizeof(player_position2d_data_t)); - ProcessOdom(hdr, *reinterpret_cast<player_position2d_data_t *> (data)); - return(0); + // handle changes in the properties that we can + if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, + PLAYER_SET_INTPROP_REQ, device_addr)) { - } - */ - - return -1; + player_intprop_req_t &req = *reinterpret_cast<player_intprop_req_t*> (data); + if (strcmp(Zoom.GetKey(),req.key)==0) + { + if (SetZoom(req.value)) + { + Publish(device_addr, resp_queue, PLAYER_MSGTYPE_RESP_NACK, hdr->subtype); + return 0; + } + return -1; + } + else if (strcmp(Focus.GetKey(),req.key)==0) + { + if (SetFocus(req.value)) + { + Publish(device_addr, resp_queue, PLAYER_MSGTYPE_RESP_NACK, hdr->subtype); + return 0; + } + return -1; + } + else if (strcmp(Iris.GetKey(),req.key)==0) + { + if (SetIris(req.value)) + { + Publish(device_addr, resp_queue, PLAYER_MSGTYPE_RESP_NACK, hdr->subtype); + return 0; + } + return -1; + } + } + return -1; } //////////////////////////////////////////////////////////////////////////////// // Store an image frame into the 'f... [truncated message content] |
From: <th...@us...> - 2009-06-07 07:44:44
|
Revision: 7807 http://playerstage.svn.sourceforge.net/playerstage/?rev=7807&view=rev Author: thjc Date: 2009-06-07 07:44:40 +0000 (Sun, 07 Jun 2009) Log Message: ----------- applied patch 2135324: Adding VEL_HEAD command to position2d also fixed a number of compiler warnings Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/dev_position2d.c code/player/trunk/client_libs/libplayerc/dev_stereo.c code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/client_libs/libplayerc++/playerc++.h code/player/trunk/client_libs/libplayerc++/position2dproxy.cc code/player/trunk/utils/playercam/playercam.c code/player/trunk/utils/playerprint/playerprint.cc code/player/trunk/utils/playerv/playerv.c code/player/trunk/utils/playerv/pv_dev_actarray.c code/player/trunk/utils/playerv/pv_dev_bumper.c code/player/trunk/utils/playerv/pv_dev_camera.c code/player/trunk/utils/playerv/pv_dev_dio.c code/player/trunk/utils/playerv/pv_dev_gripper.c code/player/trunk/utils/playerv/pv_dev_laser.c code/player/trunk/utils/playerv/pv_dev_map.c code/player/trunk/utils/playerv/pv_dev_sonar.c Modified: code/player/trunk/client_libs/libplayerc/dev_position2d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_position2d.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/client_libs/libplayerc/dev_position2d.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -187,6 +187,22 @@ &cmd, NULL); } +// Set the robot speed and heading +int +playerc_position2d_set_cmd_vel_head(playerc_position2d_t *device, + double vx, double vy, double pa, int state) +{ + player_position2d_cmd_vel_head_t cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.velocity = vx; + cmd.angle = pa; + + return playerc_client_write(device->info.client, &device->info, + PLAYER_POSITION2D_CMD_VEL_HEAD, + &cmd, NULL); +} + // Set the target pose int playerc_position2d_set_cmd_pose_with_vel(playerc_position2d_t *device, Modified: code/player/trunk/client_libs/libplayerc/dev_stereo.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_stereo.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/client_libs/libplayerc/dev_stereo.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -119,17 +119,17 @@ if (device->left_channel.image) memcpy (device->left_channel.image, s_data->left_channel.image, device->left_channel.image_count); else if (device->left_channel.image_count != 0) - PLAYERC_ERR1 ("failed to allocate memory for left image, needed %d bytes\n", sizeof (device->left_channel.image[0]) * device->left_channel.image_count); + PLAYERC_ERR1 ("failed to allocate memory for left image, needed %zd bytes\n", sizeof (device->left_channel.image[0]) * device->left_channel.image_count); if (device->right_channel.image) memcpy (device->right_channel.image, s_data->right_channel.image, device->right_channel.image_count); else if (device->right_channel.image_count != 0) - PLAYERC_ERR1 ("failed to allocate memory for right image, needed %d bytes\n", sizeof (device->right_channel.image[0]) * device->right_channel.image_count); + PLAYERC_ERR1 ("failed to allocate memory for right image, needed %zd bytes\n", sizeof (device->right_channel.image[0]) * device->right_channel.image_count); if (device->disparity.image) memcpy (device->disparity.image, s_data->disparity.image, device->disparity.image_count); else if (device->disparity.image_count != 0) - PLAYERC_ERR1 ("failed to allocate memory for disparity image, needed %d bytes\n", sizeof (device->disparity.image[0]) * device->disparity.image_count); + PLAYERC_ERR1 ("failed to allocate memory for disparity image, needed %zd bytes\n", sizeof (device->disparity.image[0]) * device->disparity.image_count); /* device->pointcloud.points_count = s_data->pointcloud.points_count; device->pointcloud.points = realloc (device->pointcloud.points, device->pointcloud.points_count * sizeof (device->pointcloud.points[0])); Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-07 07:44:40 UTC (rev 7807) @@ -2722,6 +2722,15 @@ player_pose2d_t vel, int state); +/** Set the target speed and heading. vx : forward speed (m/s). vy : sideways + speed (m/s); this field is used by omni-drive robots only. pa : + rotational heading (rad). All speeds and angles are defined in the robot + coordinate system. */ +int playerc_position2d_set_cmd_vel_head(playerc_position2d_t *device, + double vx, double vy, double pa, int state); + + + /** Set the target pose (gx, gy, ga) is the target pose in the odometric coordinate system. */ PLAYERC_EXPORT int playerc_position2d_set_cmd_pose(playerc_position2d_t *device, Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-06-07 07:44:40 UTC (rev 7807) @@ -1844,6 +1844,17 @@ void SetSpeed(player_pose2d_t vel) { return SetSpeed(vel.px, vel.py, vel.pa);} + /// Send a motor command for velocity/heading control mode. + /// Specify the forward and sideways velocity (m/sec), and angular + /// heading (rads). + void SetVelHead(double aXSpeed, double aYSpeed, double aYawHead); + + /// Same as the previous SetVelHead(), but doesn't take the yspeed speed + /// (so use this one for non-holonomic robots). + void SetVelHead(double aXSpeed, double aYawHead) + { return SetVelHead(aXSpeed, 0, aYawHead);} + + /// Send a motor command for position control mode. Specify the /// desired pose of the robot as a player_pose_t. /// desired motion speed as a player_pose_t. Modified: code/player/trunk/client_libs/libplayerc++/position2dproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/position2dproxy.cc 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/client_libs/libplayerc++/position2dproxy.cc 2009-06-07 07:44:40 UTC (rev 7807) @@ -100,7 +100,14 @@ playerc_position2d_set_cmd_vel(mDevice,aXSpeed,aYSpeed,aYawSpeed,1); } +void +Position2dProxy::SetVelHead(double aXSpeed, double aYSpeed, double aYawHead) +{ + scoped_lock_t lock(mPc->mMutex); + playerc_position2d_set_cmd_vel_head(mDevice,aXSpeed,aYSpeed,aYawHead,1); +} + void Position2dProxy::GoTo(player_pose2d_t pos, player_pose2d_t vel) { scoped_lock_t lock(mPc->mMutex); Modified: code/player/trunk/utils/playercam/playercam.c =================================================================== --- code/player/trunk/utils/playercam/playercam.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playercam/playercam.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -120,7 +120,7 @@ int get_options(int argc, char **argv) { - int ch=0, errflg=0; + int ch=0; const char* optflags = "i:h:p:r:b:t:"; while((ch=getopt(argc, argv, optflags))!=-1) @@ -248,8 +248,6 @@ { GdkEventButton *bevent = (GdkEventButton *)event; int x,y,o; - int width, height, rowstride, n_channels; - guchar *pixels, *p; switch ((gint)event->type) { @@ -448,6 +446,8 @@ playerc_client_datamode(g_client,PLAYER_DATAMODE_PULL); playerc_client_set_replace_rule(g_client,-1,-1,PLAYER_MSGTYPE_DATA,-1,1); + + return 0; } int @@ -521,6 +521,7 @@ g_print("ERROR reading player g_client\n"); //exit(-1); } + return 0; } int @@ -538,4 +539,5 @@ } playerc_client_disconnect(g_client); playerc_client_destroy(g_client); + return 0; } Modified: code/player/trunk/utils/playerprint/playerprint.cc =================================================================== --- code/player/trunk/utils/playerprint/playerprint.cc 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerprint/playerprint.cc 2009-06-07 07:44:40 UTC (rev 7807) @@ -121,7 +121,7 @@ int get_options(int argc, char **argv) { - int ch=0, errflg=0; + int ch=0; const char* optflags = "i:h:p:r:t:"; while((ch=getopt(argc, argv, optflags))!=-1) @@ -170,9 +170,9 @@ exit(-1); } - try + try { - + ClientProxy* cp; // connect to Player @@ -193,7 +193,7 @@ // break; case PLAYER_ACTARRAY_CODE: cp = (ClientProxy*)new ActArrayProxy(&client,g_index); - try + try { reinterpret_cast<ActArrayProxy*> (cp)->RequestGeometry(); } Modified: code/player/trunk/utils/playerv/playerv.c =================================================================== --- code/player/trunk/utils/playerv/playerv.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/playerv.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -211,7 +211,7 @@ if(rate == 0.0) { - printf("Setting delivery mode to PLAYER_DATAMODE_PUSH\n", host, port); + printf("Setting delivery mode to PLAYER_DATAMODE_PUSH\n"); // Change the server's data delivery mode. if (playerc_client_set_replace_rule(client, -1, -1, -1, -1, 0) != 0) { Modified: code/player/trunk/utils/playerv/pv_dev_actarray.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_actarray.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_actarray.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -196,8 +196,6 @@ { double value; double min, max; - double ax, ay, bx, by; - double fx, fd; int ii; rtk_fig_t *fig; Modified: code/player/trunk/utils/playerv/pv_dev_bumper.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_bumper.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_bumper.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -1,4 +1,4 @@ -/* +/* * PlayerViewer * Copyright (C) Andrew Howard 2002 * @@ -45,11 +45,10 @@ bumper_t *bumper_create(mainwnd_t *mainwnd, opt_t *opt, playerc_client_t *client, int index, const char *drivername, int subscribe) { - int i; char label[64]; char section[64]; bumper_t *bumper; - + bumper = malloc(sizeof(bumper_t)); bumper->proxy = playerc_bumper_create(client, index); bumper->drivername = strdup(drivername); @@ -78,7 +77,7 @@ if (fig_count <= bumper->fig_count) return; bumper->scan_fig = realloc(bumper->scan_fig,fig_count*sizeof(bumper->scan_fig[0])); - + // Construct figures for (i = bumper->fig_count; i < fig_count; i++) bumper->scan_fig[i] = rtk_fig_create(bumper->mainwnd->canvas, bumper->mainwnd->robot_fig, 1); @@ -90,7 +89,7 @@ void bumper_destroy(bumper_t *bumper) { int i; - + if (bumper->proxy->info.subscribed) playerc_bumper_unsubscribe(bumper->proxy); playerc_bumper_destroy(bumper->proxy); @@ -111,7 +110,7 @@ void bumper_update(bumper_t *bumper) { int i; - + // Update the device subscription if (rtk_menuitem_ischecked(bumper->subscribe_item)) { @@ -122,7 +121,7 @@ // Get the bumper geometry if (playerc_bumper_get_geom(bumper->proxy) != 0) - PRINT_ERR1("get_geom failed : %s", playerc_error_str()); + PRINT_ERR1("get_geom failed : %s", playerc_error_str()); bumper_allocate_figures(bumper, bumper->proxy->pose_count); for (i = 0; i < bumper->proxy->pose_count; i++){ @@ -131,7 +130,7 @@ bumper->proxy->poses[i].pose.px, // convert mm to m bumper->proxy->poses[i].pose.py, bumper->proxy->poses[i].pose.pyaw); // convert deg to rad - + } } } @@ -166,7 +165,7 @@ for (i = 0; i< bumper->proxy->bumper_count; i++) { - rtk_fig_show(bumper->scan_fig[i], 1); + rtk_fig_show(bumper->scan_fig[i], 1); rtk_fig_clear(bumper->scan_fig[i]); // Draw in the bumper, diff colour if its active @@ -191,7 +190,7 @@ else { half_angle = (bumper->proxy->poses[i].length)/radius/2.0 - 0.04; - rtk_fig_ellipse_arc(bumper->scan_fig[i],-radius,0,0,radius*2,radius*2,-half_angle,half_angle); + rtk_fig_ellipse_arc(bumper->scan_fig[i],-radius,0,0,radius*2,radius*2,-half_angle,half_angle); } } } Modified: code/player/trunk/utils/playerv/pv_dev_camera.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_camera.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_camera.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -148,9 +148,7 @@ // Draw the camera scan void camera_draw(camera_t *camera) { - int i; char text[64]; - double ox, oy, dx, dy; int sizex, sizey; double scalex, scaley; Modified: code/player/trunk/utils/playerv/pv_dev_dio.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_dio.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_dio.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -121,7 +121,7 @@ void dio_draw(dio_t *dio) { int i; - char ntext[64], str[1024]; + char str[1024]; uint32_t digin = dio->proxy->digin; uint32_t count = dio->proxy->count; Modified: code/player/trunk/utils/playerv/pv_dev_gripper.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_gripper.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_gripper.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -48,7 +48,6 @@ gripper_t *gripper_create(mainwnd_t *mainwnd, opt_t *opt, playerc_client_t *client, int index, const char *drivername, int subscribe) { - int i; char label[64]; char section[64]; gripper_t *gripper; @@ -82,8 +81,6 @@ // Destroy a gripper device void gripper_destroy(gripper_t *gripper) { - int i; - if( gripper->grip_fig ) { rtk_fig_clear(gripper->grip_fig); @@ -109,7 +106,6 @@ double paddle_center, paddle_length, paddle_width, paddle_pos; double ibbx, obbx, bby; double led_dx; - int i; // Update the device subscription if (rtk_menuitem_ischecked(gripper->subscribe_item)) Modified: code/player/trunk/utils/playerv/pv_dev_laser.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_laser.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_laser.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -1,4 +1,4 @@ -/* +/* * PlayerViewer * Copyright (C) Andrew Howard 2002 * @@ -45,7 +45,7 @@ char label[64]; char section[64]; laser_t *laser; - + laser = malloc(sizeof(laser_t)); laser->proxy = playerc_laser_create(client, index); @@ -75,7 +75,7 @@ // Construct figures laser->scan_fig = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 0); - + return laser; } @@ -102,7 +102,7 @@ rtk_menu_destroy(laser->menu); free(laser->drivername); - + free(laser); } @@ -141,7 +141,7 @@ // Update the configuration stuff if (laser->proxy->info.subscribed) laser_update_config(laser); - + if (laser->proxy->info.subscribed) { // Draw in the laser scan if it has been changed. @@ -165,7 +165,7 @@ int update; double min, max, range_res, res, scanning_frequency; unsigned char intensity; - + min = laser->proxy->scan_start; max = laser->proxy->scan_start + laser->proxy->scan_count*laser->proxy->scan_res; range_res = laser->proxy->range_res; @@ -224,25 +224,23 @@ return; -} +} // Draw the laser scan void laser_draw(laser_t *laser) { int i; - int style; double ax, ay, bx, by; double r, b, res; - int point_count; double (*points)[2]; - rtk_fig_show(laser->scan_fig, 1); + rtk_fig_show(laser->scan_fig, 1); rtk_fig_clear(laser->scan_fig); if (!rtk_menuitem_ischecked(laser->style_item)) { rtk_fig_color_rgb32(laser->scan_fig, COLOR_LASER_OCC); - + // Draw in the range scan for (i = 0; i < laser->proxy->scan_count; i++) { @@ -261,11 +259,11 @@ else { res = laser->proxy->scan_res / 2; - + // Draw in the range scan (empty space) points = calloc(laser->proxy->scan_count,sizeof(double)*2); for (i = 0; i < laser->proxy->scan_count; i++) - { + { r = laser->proxy->scan[i][0]; b = laser->proxy->scan[i][1]; points[i][0] = r * cos(b - res); @@ -275,7 +273,7 @@ rtk_fig_polygon(laser->scan_fig, 0, 0, 0, laser->proxy->scan_count, points, 1); free(points); points = NULL; - + // Draw in the range scan (occupied space) rtk_fig_color_rgb32(laser->scan_fig, COLOR_LASER_OCC); for (i = 0; i < laser->proxy->scan_count; i++) @@ -288,7 +286,7 @@ by = r * sin(b + res); rtk_fig_line(laser->scan_fig, ax, ay, bx, by); } - } + } // Draw in the intensity scan for (i = 0; i < laser->proxy->scan_count; i++) Modified: code/player/trunk/utils/playerv/pv_dev_map.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_map.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_map.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -1,4 +1,4 @@ -/* +/* * PlayerViewer * Copyright (C) Andrew Howard 2002 * @@ -44,7 +44,7 @@ char label[64]; char section[64]; map_t *map; - + map = malloc(sizeof(map_t)); map->proxy = playerc_map_create(client, index); map->drivername = strdup(drivername); @@ -59,10 +59,10 @@ map->continuous_item = rtk_menuitem_create(map->menu, "continuous update", 1); // Set the initial menu state rtk_menuitem_check(map->subscribe_item, subscribe); - + // Construct figures map->fig = rtk_fig_create(mainwnd->canvas, NULL, 1); - + return map; } @@ -77,7 +77,7 @@ rtk_fig_destroy(map->fig); free(map->drivername); free(map); - + return; } @@ -93,7 +93,7 @@ if (playerc_map_subscribe(map->proxy, PLAYER_OPEN_MODE) != 0) PRINT_ERR1("libplayerc error: %s", playerc_error_str()); // download a map - if (playerc_map_get_map( map->proxy ) >= 0) + if (playerc_map_get_map( map->proxy ) >= 0) map_draw( map ); } } @@ -139,17 +139,16 @@ void map_draw(map_t *map) { int x,y; - char ntext[64], text[1024]; double scale = map->proxy->resolution; - rtk_fig_show(map->fig, 1); + rtk_fig_show(map->fig, 1); rtk_fig_clear(map->fig); - + puts( "map draw" ); - rtk_fig_color_rgb32(map->fig, 0xFF0000 ); - rtk_fig_rectangle(map->fig, - 0,0,0, + rtk_fig_color_rgb32(map->fig, 0xFF0000 ); + rtk_fig_rectangle(map->fig, + 0,0,0, map->proxy->width * scale, map->proxy->height * scale, 0 ); @@ -166,7 +165,7 @@ case -1: // empty: draw nothing break; - + case 0: // unknown: draw grey square rtk_fig_color_rgb32(map->fig, 0x808080 ); @@ -177,14 +176,14 @@ scale, scale, 1); break; - case +1: + case +1: // occupied: draw black square - rtk_fig_color_rgb32(map->fig, 0x0 ); - rtk_fig_rectangle(map->fig, - (x - map->proxy->width/2.0) * scale + scale/2.0, - (y - map->proxy->height/2.0) * scale + scale/2.0, - 0, - scale, scale, 1); + rtk_fig_color_rgb32(map->fig, 0x0 ); + rtk_fig_rectangle(map->fig, + (x - map->proxy->width/2.0) * scale + scale/2.0, + (y - map->proxy->height/2.0) * scale + scale/2.0, + 0, + scale, scale, 1); break; default: Modified: code/player/trunk/utils/playerv/pv_dev_sonar.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_sonar.c 2009-06-07 07:21:45 UTC (rev 7806) +++ code/player/trunk/utils/playerv/pv_dev_sonar.c 2009-06-07 07:44:40 UTC (rev 7807) @@ -1,4 +1,4 @@ -/* +/* * PlayerViewer * Copyright (C) Andrew Howard 2002 * @@ -47,11 +47,10 @@ sonar_t *sonar_create(mainwnd_t *mainwnd, opt_t *opt, playerc_client_t *client, int index, const char *drivername, int subscribe) { - int i; char label[64]; char section[64]; sonar_t *sonar; - + sonar = malloc(sizeof(sonar_t)); sonar->proxy = playerc_sonar_create(client, index); sonar->drivername = strdup(drivername); @@ -81,7 +80,7 @@ if (fig_count <= sonar->fig_count) return; sonar->scan_fig = realloc(sonar->scan_fig,fig_count*sizeof(sonar->scan_fig[0])); - + // Construct figures for (i = sonar->fig_count; i < fig_count; i++) sonar->scan_fig[i] = rtk_fig_create(sonar->mainwnd->canvas, sonar->mainwnd->robot_fig, 1); @@ -93,7 +92,7 @@ void sonar_destroy(sonar_t *sonar) { int i; - + if (sonar->proxy->info.subscribed) playerc_sonar_unsubscribe(sonar->proxy); playerc_sonar_destroy(sonar->proxy); @@ -112,8 +111,6 @@ // Update a sonar device void sonar_update(sonar_t *sonar) { - int i; - // Update the device subscription if (rtk_menuitem_ischecked(sonar->subscribe_item)) { @@ -124,7 +121,7 @@ // Get the sonar geometry if (playerc_sonar_get_geom(sonar->proxy) != 0) - PRINT_ERR1("get_geom failed : %s", playerc_error_str()); + PRINT_ERR1("get_geom failed : %s", playerc_error_str()); sonar_update_geom(sonar); } @@ -144,7 +141,7 @@ sonar->proxy->info.freshgeom = 0; sonar_update_geom(sonar); } - + // Draw in the sonar scan if it has been changed. if (sonar->proxy->info.datatime != sonar->datatime) sonar_draw(sonar); @@ -180,7 +177,7 @@ for (i = 0; i < sonar->proxy->scan_count; i++) { - rtk_fig_show(sonar->scan_fig[i], 1); + rtk_fig_show(sonar->scan_fig[i], 1); rtk_fig_clear(sonar->scan_fig[i]); // Draw in the sonar itself @@ -191,7 +188,7 @@ rtk_fig_color_rgb32(sonar->scan_fig[i], COLOR_SONAR_SCAN); dr = sonar->proxy->scan[i]; da = 20 * M_PI / 180 / 2; - + //rtk_fig_line(sonar->scan_fig[i], 0, 0, dr, 0); //rtk_fig_line(sonar->scan_fig[i], dr, -dr * da/2, dr, +dr * da/2); points[0][0] = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-06-08 06:20:37
|
Revision: 7814 http://playerstage.svn.sourceforge.net/playerstage/?rev=7814&view=rev Author: gbiggs Date: 2009-06-08 06:20:28 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Added support for large files, stopped warn floods in MSVC Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/cmake/internal/GeneralCompileOptions.cmake Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-06-08 06:11:07 UTC (rev 7813) +++ code/player/trunk/CMakeLists.txt 2009-06-08 06:20:28 UTC (rev 7814) @@ -20,16 +20,21 @@ SET (PLAYER_API_VERSION 2.2 CACHE STRING "Player API version") MESSAGE (STATUS "${PROJECT_NAME} version ${PLAYER_VERSION}") -# Enable -Wall by default -SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - # Set where to find our internal CMake scripts SET (PLAYER_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of CMake scripts") # Get version components INCLUDE (${PLAYER_CMAKE_DIR}/internal/DissectVersion.cmake) # Determine the operating system in detail INCLUDE (${PLAYER_CMAKE_DIR}/internal/FindOS.cmake) + +# Enable -Wall by default +IF (NOT PLAYER_OS_WIN) + # Using -Wall on Windows causes MSVC to produce thousands of warnings in its + # own standard headers, dramatically slowing down the build. + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +ENDIF (NOT PLAYER_OS_WIN) + # Check the compiler version is OK # INCLUDE (${PLAYER_CMAKE_DIR}/internal/CheckCompiler.cmake) # Setup directories such as install destination Modified: code/player/trunk/cmake/internal/GeneralCompileOptions.cmake =================================================================== --- code/player/trunk/cmake/internal/GeneralCompileOptions.cmake 2009-06-08 06:11:07 UTC (rev 7813) +++ code/player/trunk/cmake/internal/GeneralCompileOptions.cmake 2009-06-08 06:20:28 UTC (rev 7814) @@ -12,3 +12,17 @@ ENDIF (WITH_GTK) OPTION (BUILD_SHARED_LIBS "Build the Player libraries as shared libraries." ON) + +IF (NOT PLAYER_OS_WIN) + OPTION (LARGE_FILE_SUPPORT "Compile with support for large files (>2GB)." OFF) + EXECUTE_PROCESS (COMMAND getconf LFS_CFLAGS OUTPUT_VARIABLE LFS_FLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF (LARGE_FILE_SUPPORT) + MESSAGE (STATUS "Large file support is enabled, flags are ${LFS_FLAGS}") + ADD_DEFINITIONS (${LFS_FLAGS}) + ELSE (LARGE_FILE_SUPPORT) + MESSAGE (STATUS "Large file support is disabled.") + REMOVE_DEFINITIONS (${LFS_FLAGS}) + ENDIF (LARGE_FILE_SUPPORT) +ENDIF (NOT PLAYER_OS_WIN) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-06-08 22:19:12
|
Revision: 7822 http://playerstage.svn.sourceforge.net/playerstage/?rev=7822&view=rev Author: gbiggs Date: 2009-06-08 22:18:09 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Make things compile on windows again. Modified Paths: -------------- code/player/trunk/libplayerwkb/CMakeLists.txt code/player/trunk/libplayerwkb/playerwkb.h code/player/trunk/server/drivers/laser/sickLDMRS.cc code/player/trunk/server/drivers/position/snd/gap_nd_nav.cc code/player/trunk/server/drivers/position/snd/snd.cc code/player/trunk/server/drivers/vectormap/vec2map.cc Modified: code/player/trunk/libplayerwkb/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerwkb/CMakeLists.txt 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/libplayerwkb/CMakeLists.txt 2009-06-08 22:18:09 UTC (rev 7822) @@ -1,3 +1,8 @@ +# Possibly use our own copy of XDR +IF (NOT HAVE_XDR) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) +ENDIF (NOT HAVE_XDR) + SET (playerwkbSrcs playerwkb.c) PLAYER_ADD_LIBRARY (playerwkb ${playerwkbSrcs}) Modified: code/player/trunk/libplayerwkb/playerwkb.h =================================================================== --- code/player/trunk/libplayerwkb/playerwkb.h 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/libplayerwkb/playerwkb.h 2009-06-08 22:18:09 UTC (rev 7822) @@ -1,6 +1,18 @@ #ifndef __PLAYER_WKB_H #define __PLAYER_WKB_H +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERWKB_EXPORT + #elif defined (playerwkb_EXPORTS) + #define PLAYERWKB_EXPORT __declspec (dllexport) + #else + #define PLAYERWKB_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERWKB_EXPORT +#endif + #include <stddef.h> /* size_t typedef and some versions of GEOS CAPI need this */ #include <playerconfig.h> /* this also includes <stdint.h> if needed for types like uint8_t */ @@ -26,9 +38,9 @@ #else -typedef void * playerwkbprocessor_t; +PLAYERWKB_EXPORT typedef void * playerwkbprocessor_t; -enum player_wkb_endians { player_wkb_big = 0, player_wkb_little = 1 }; +PLAYERWKB_EXPORT enum player_wkb_endians { player_wkb_big = 0, player_wkb_little = 1 }; struct PlayerWKBEndians { @@ -37,11 +49,11 @@ #endif -typedef void (* playerwkbcallback_t)(void *, double, double, double, double); +PLAYERWKB_EXPORT typedef void (* playerwkbcallback_t)(void *, double, double, double, double); -playerwkbprocessor_t player_wkb_create_processor(); -void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor); -const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, playerwkbcallback_t callback, void * ptr); +PLAYERWKB_EXPORT playerwkbprocessor_t player_wkb_create_processor(); +PLAYERWKB_EXPORT void player_wkb_destroy_processor(playerwkbprocessor_t wkbprocessor); +PLAYERWKB_EXPORT const uint8_t * player_wkb_process_wkb(playerwkbprocessor_t wkbprocessor, const uint8_t * wkb, size_t wkb_count, playerwkbcallback_t callback, void * ptr); #ifdef __cplusplus } Modified: code/player/trunk/server/drivers/laser/sickLDMRS.cc =================================================================== --- code/player/trunk/server/drivers/laser/sickLDMRS.cc 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/server/drivers/laser/sickLDMRS.cc 2009-06-08 22:18:09 UTC (rev 7822) @@ -93,8 +93,6 @@ #define MESSAGE_LEN 38U -using namespace std; - //extern PlayerTime *GlobalTime; /////////////////////////////////////////////////////////////////////////////// Modified: code/player/trunk/server/drivers/position/snd/gap_nd_nav.cc =================================================================== --- code/player/trunk/server/drivers/position/snd/gap_nd_nav.cc 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/server/drivers/position/snd/gap_nd_nav.cc 2009-06-08 22:18:09 UTC (rev 7822) @@ -24,8 +24,17 @@ #include <assert.h> #include <time.h> #include <math.h> -#include <sys/times.h> #include <vector> +#if defined (WIN32) + #if defined (min) + #undef min + #endif + #if defined (max) + #undef max + #endif +#else + #include <sys/times.h> +#endif #include "dllist.h" @@ -33,7 +42,6 @@ #include "gap_and_valley.h" #include "snd.h" -using namespace std; //using namespace PlayerCc; // Use gDebug to set verbosity of output, -1 for silent, 0 for hardly any output, 5 for normal debug @@ -116,7 +124,7 @@ //double fScanRes = lp.GetScanRes(); //double fMaxRange = lp.GetMaxRange(); - int iNumSectors = fullLP.size(); + int iNumSectors = static_cast<int> (fullLP.size()); int iRisingGap = pRisingGap->m_iSector; double gapDistance = pRisingGap->m_dist; @@ -155,7 +163,7 @@ bool isFilterClear( int iCenterSector, double width, double forwardLength, bool bDoRearCheck, std::vector<double> fullLP, double angRes, bool bPrint ) { - int iCount = fullLP.size(); + int iCount = static_cast<int> (fullLP.size()); //double angRes = lp.GetScanRes(); for( int i = 0; i < iCount; i++ ) { @@ -231,7 +239,7 @@ if( iNumSectors <= 0 || iNumSectors > 100000 || iNumSectors < iNumLPs ) { - cerr<< "ERROR: Invalid number of sectors " << endl; + std::cerr<< "ERROR: Invalid number of sectors " << std::endl; return NULL; } @@ -684,9 +692,9 @@ if( gDebug > 5 ) { - cout<< " Pass " << iPass << ": considering valley "; - cout<< pBestValley->m_pRisingDisc->m_iSector << ", " << pBestValley->m_pOtherDisc->m_iSector; - cout<< endl; + std::cout<< " Pass " << iPass << ": considering valley "; + std::cout<< pBestValley->m_pRisingDisc->m_iSector << ", " << pBestValley->m_pOtherDisc->m_iSector; + std::cout<< std::endl; } } } @@ -719,9 +727,9 @@ if( gDebug > 5 ) { - cout<< " Pass " << iPass << ": considering valley "; - cout<< pBestValley->m_pRisingDisc->m_iSector << ", " << pBestValley->m_pOtherDisc->m_iSector; - cout<< endl; + std::cout<< " Pass " << iPass << ": considering valley "; + std::cout<< pBestValley->m_pRisingDisc->m_iSector << ", " << pBestValley->m_pOtherDisc->m_iSector; + std::cout<< std::endl; } } } @@ -743,7 +751,7 @@ { if (gDebug > 0) std::cout<< "!!! Obstacle inside robot radius !!!"; if (gDebug > 0) std::cout<< " Stopping."; - iSTheta = fullLP.size()/2; + iSTheta = static_cast<int> (fullLP.size()/2); } else if( pBestValley == NULL ) { Modified: code/player/trunk/server/drivers/position/snd/snd.cc =================================================================== --- code/player/trunk/server/drivers/position/snd/snd.cc 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/server/drivers/position/snd/snd.cc 2009-06-08 22:18:09 UTC (rev 7822) @@ -135,35 +135,15 @@ */ /** @} */ - - - - - - - - - - - - - - - - - - - - - - -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> + #include <netinet/in.h> +#endif #include <string.h> #include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <vector> -#include <netinet/in.h> #include <libplayercore/playercore.h> #include "snd.h" Modified: code/player/trunk/server/drivers/vectormap/vec2map.cc =================================================================== --- code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-06-08 19:18:00 UTC (rev 7821) +++ code/player/trunk/server/drivers/vectormap/vec2map.cc 2009-06-08 22:18:09 UTC (rev 7822) @@ -86,8 +86,6 @@ #define EPS 0.0000001 #define MAXFABS(a, b) ((fabs(a) > fabs(b)) ? fabs(a) : fabs(b)) -using namespace std; - class Vec2Map : public ThreadedDriver { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-06-09 23:54:32
|
Revision: 7827 http://playerstage.svn.sourceforge.net/playerstage/?rev=7827&view=rev Author: gbiggs Date: 2009-06-09 23:54:24 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Fixes for Win32 Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/server/drivers/camera/camfilter/camfilter.cc Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-09 23:49:16 UTC (rev 7826) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-06-09 23:54:24 UTC (rev 7827) @@ -2726,7 +2726,7 @@ speed (m/s); this field is used by omni-drive robots only. pa : rotational heading (rad). All speeds and angles are defined in the robot coordinate system. */ -int playerc_position2d_set_cmd_vel_head(playerc_position2d_t *device, +PLAYERC_EXPORT int playerc_position2d_set_cmd_vel_head(playerc_position2d_t *device, double vx, double vy, double pa, int state); Modified: code/player/trunk/server/drivers/camera/camfilter/camfilter.cc =================================================================== --- code/player/trunk/server/drivers/camera/camfilter/camfilter.cc 2009-06-09 23:49:16 UTC (rev 7826) +++ code/player/trunk/server/drivers/camera/camfilter/camfilter.cc 2009-06-09 23:54:24 UTC (rev 7827) @@ -150,9 +150,7 @@ #include <libplayercore/playercore.h> #include <config.h> #if HAVE_JPEG -#include <libplayerjpeg/playerjpeg.h> -#else -#warning JPEG decompression disabled! + #include <libplayerjpeg/playerjpeg.h> #endif class CamFilter : public ThreadedDriver This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-06-20 13:03:17
|
Revision: 7865 http://playerstage.svn.sourceforge.net/playerstage/?rev=7865&view=rev Author: robotos Date: 2009-06-20 13:03:14 +0000 (Sat, 20 Jun 2009) Log Message: ----------- added PAUSE, RESET, SAVE commands to the simulation interface Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/dev_simulation.c code/player/trunk/libplayercore/interfaces/031_simulation.def Modified: code/player/trunk/client_libs/libplayerc/dev_simulation.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_simulation.c 2009-06-20 03:09:09 UTC (rev 7864) +++ code/player/trunk/client_libs/libplayerc/dev_simulation.c 2009-06-20 13:03:14 UTC (rev 7865) @@ -236,3 +236,31 @@ player_simulation_property_req_t_free(resp); return 0; } + +//Pause the simulation if running or resume it if paused +int playerc_simulation_pause(playerc_simulation_t *device ) +{ + return playerc_client_write(device->info.client, &device->info, + PLAYER_SIMULATION_CMD_PAUSE, + NULL, NULL); +} + + +//Reset the current simulation +int playerc_simulation_reset(playerc_simulation_t *device ) +{ + return playerc_client_write(device->info.client, &device->info, + PLAYER_SIMULATION_CMD_RESET, + NULL, NULL); +} + + +//Save the current state of the simulation +int playerc_simulation_save(playerc_simulation_t *device ) +{ + return playerc_client_write(device->info.client, &device->info, + PLAYER_SIMULATION_CMD_SAVE, + NULL, NULL); +} + + Modified: code/player/trunk/libplayercore/interfaces/031_simulation.def =================================================================== --- code/player/trunk/libplayercore/interfaces/031_simulation.def 2009-06-20 03:09:09 UTC (rev 7864) +++ code/player/trunk/libplayercore/interfaces/031_simulation.def 2009-06-20 13:03:14 UTC (rev 7865) @@ -7,8 +7,7 @@ This interface doesn't do much yet. It is in place to later support things like pausing and restarting the simulation clock, saving and loading, -etc. It is documented because it is used by the stg_simulation driver; -required by all stageclient drivers (stg_*). +etc. Note: the Stage and Gazebo developers should confer on the best design for this interface. Suggestions welcome on playerstage-developers. @@ -27,9 +26,14 @@ message { REQ, GET_PROPERTY, 5, player_simulation_property_req_t }; /** Request/reply subtype: get property value */ message { REQ, SET_PROPERTY, 6, player_simulation_property_req_t }; +/** Cmd subtype: pause (if running) /resume (if paused) command */ +message { CMD, PAUSE, 1, NULL }; +/** Cmd subtype: reset simulation command */ +message { CMD, RESET, 2, NULL }; +/** Cmd subtype: save simulation command */ +message { CMD, SAVE, 3, NULL }; - /** @brief Data Just a placeholder for now; data will be added in future. @@ -87,8 +91,6 @@ /** @brief Request/reply: get/set a property of a named simulation object @par To retrieve an property of an object in a simulator, send a @ref - -@par To retrieve an property of an object in a simulator, send a @ref PLAYER_SIMULATION_REQ_GET_PROPERTY request. The server will reply with the value array filled in. The type of the data varies by property and it is up to the caller to cast the data to the correct type: see the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-06-23 11:14:32
|
Revision: 7878 http://playerstage.svn.sourceforge.net/playerstage/?rev=7878&view=rev Author: thjc Date: 2009-06-23 11:14:00 +0000 (Tue, 23 Jun 2009) Log Message: ----------- refactor of remote driver connections and passthrough to use a one to one mapping of subscribers to remote connections This fixes some strange behaviour with drivers that track subscriptions on a per client basis. Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/client.c code/player/trunk/client_libs/libplayerc/error.h code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayercore/configfile.cc code/player/trunk/libplayercore/devicetable.cc code/player/trunk/libplayertcp/CMakeLists.txt code/player/trunk/libplayertcp/playertcp.cc code/player/trunk/libplayertcp/playertcp.h code/player/trunk/server/drivers/shell/passthrough.cc Added Paths: ----------- code/player/trunk/libplayercore/remote_driver.cc code/player/trunk/libplayercore/remote_driver.h code/player/trunk/libplayertcp/tcpremote_driver.cc code/player/trunk/libplayertcp/tcpremote_driver.h code/player/trunk/server/drivers/shell/test/ code/player/trunk/server/drivers/shell/test/test_passthrough.cfg code/player/trunk/server/drivers/shell/test/test_passthrough.py code/player/trunk/server/drivers/shell/test/test_passthrough_split1.cfg code/player/trunk/server/drivers/shell/test/test_passthrough_split2.cfg Removed Paths: ------------- code/player/trunk/libplayertcp/remote_driver.cc code/player/trunk/libplayertcp/remote_driver.h Modified: code/player/trunk/client_libs/libplayerc/client.c =================================================================== --- code/player/trunk/client_libs/libplayerc/client.c 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/client_libs/libplayerc/client.c 2009-06-23 11:14:00 UTC (rev 7878) @@ -907,7 +907,9 @@ rep_header.addr.index != req_header.addr.index || rep_header.subtype != req_header.subtype) { - PLAYERC_ERR("got the wrong kind of reply (not good)."); + PLAYERC_ERR6("got the wrong kind of reply (%d %d %d != %d %d %d).",rep_header.addr.interf, + rep_header.addr.index, rep_header.subtype, req_header.addr.interf, req_header.addr.index, + req_header.subtype); return -1; } if (rep_header.size > 0) Modified: code/player/trunk/client_libs/libplayerc/error.h =================================================================== --- code/player/trunk/client_libs/libplayerc/error.h 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/client_libs/libplayerc/error.h 2009-06-23 11:14:00 UTC (rev 7878) @@ -1,8 +1,8 @@ /* * Player - One Hell of a Robot Server * Copyright (C) Andrew Howard 2002-2003 - * * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -21,8 +21,8 @@ /* * Player - One Hell of a Robot Server * Copyright (C) Andrew Howard 2003 - * * + * * This library 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 @@ -65,12 +65,14 @@ #define PLAYERC_ERR3(msg, a, b, c) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, msg, a, b, c), fprintf(stderr,"playerc error : %s\n",playerc_error_str()) #define PLAYERC_ERR4(msg, a, b, c, d) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, msg, a, b, c, d), fprintf(stderr,"playerc error : %s\n",playerc_error_str()) #define PLAYERC_ERR5(msg, a, b, c, d, e) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, msg, a, b, c, d, e), fprintf(stderr,"playerc error : %s\n",playerc_error_str()) +#define PLAYERC_ERR6(msg, a, b, c, d, e, f) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, msg, a, b, c, d, e, f), fprintf(stderr,"playerc error : %s\n",playerc_error_str()) #define PLAYERC_WARN(msg) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) #define PLAYERC_WARN1(msg, a) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) #define PLAYERC_WARN2(msg, a, b) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a, b), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) #define PLAYERC_WARN3(msg, a, b, c) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a, b, c), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) #define PLAYERC_WARN4(msg, a, b, c, d) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a, b, c, d), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) #define PLAYERC_WARN5(msg, a, b, c, d, e) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a, b, c, d, e), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) +#define PLAYERC_WARN6(msg, a, b, c, d, e, f) snprintf(playerc_error_set_str(), PLAYERC_ERROR_SIZE, "warning : " msg, a, b, c, d, e, f), fprintf(stderr,"playerc warning : %s\n",playerc_error_str()) // DEBUG macros Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-06-23 11:14:00 UTC (rev 7878) @@ -54,7 +54,8 @@ plugins.cc globals.cc property.cpp - threaded_driver.cc) + threaded_driver.cc + remote_driver.cc) # TODO: playerxdr should NOT be linked here; it's a bogus dependency coming # from the fact that message cloning functions are auto-generated into Modified: code/player/trunk/libplayercore/configfile.cc =================================================================== --- code/player/trunk/libplayercore/configfile.cc 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayercore/configfile.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -2063,7 +2063,7 @@ for (i = 0; i < count; i++) { assert(sizeof(str) > strlen(GetFieldValue(prop, i, false))); - strcpy(str, GetFieldValue(prop, i, false)); + strncpy(str, GetFieldValue(prop, i, false),sizeof(str)); memset(tokens, 0, sizeof(tokens)); token_count = 5; Modified: code/player/trunk/libplayercore/devicetable.cc =================================================================== --- code/player/trunk/libplayercore/devicetable.cc 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayercore/devicetable.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -137,6 +137,9 @@ Device* DeviceTable::GetDevice(player_devaddr_t addr, bool lookup_remote) { + if (addr.interf == 0) + return NULL; + Device* thisentry; pthread_mutex_lock(&mutex); for(thisentry=head;thisentry;thisentry=thisentry->next) Added: code/player/trunk/libplayercore/remote_driver.cc =================================================================== --- code/player/trunk/libplayercore/remote_driver.cc (rev 0) +++ code/player/trunk/libplayercore/remote_driver.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -0,0 +1,212 @@ +/* + * Player - One Hell of a Robot Server + * Copyright (C) <insert dates here> + * <insert author's name(s) here> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/******************************************************************** + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ********************************************************************/ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include "remote_driver.h" + +int RemoteDriver::Subscribe(QueuePointer &queue, + player_devaddr_t local_addr) +{ + try + { + // create our connection proxy + if (ConnectionMap[queue].first == NULL) + { + PLAYER_MSG0(9, "Creating new remote connection mapping"); + ConnectionMap[queue].first = CreateConnection(); + } + // register the subscription + ConnectionMap[queue].second.push_back(local_addr); + + Connect(queue, local_addr); + } catch (...) + { + PLAYER_MSG4(4, "Connection to remote device failed: %d %d %d %d",local_addr.host,local_addr.robot,local_addr.interf,local_addr.index); + // ignore exceptions from Unsubscribe here + try + { + Unsubscribe(queue,local_addr); + } catch (...) {} + return -1; + } + return Driver::Subscribe(queue, local_addr); + +} + +void RemoteDriver::Connect(const QueuePointer &queue, const player_devaddr_t &local_addr) +{ + + // if our driver is in a connected state actually connect to the remote end + if (Connected) + { + PLAYER_MSG0(9, "Remote driver connecting to remote device"); + // check if we have a queue yet + if (ConnectionMap[queue].first->subscription_count == 0) + { + QueuePointer RemoteQueue = ConnectionMap[queue].first->Connect(); + QueueMap[RemoteQueue] = queue; + } + // now subscribe to the new address + ConnectionMap[queue].first->Subscribe(local_addr); + } + +} + +int RemoteDriver::Unsubscribe(QueuePointer &queue, player_devaddr_t local_addr) +{ + RemoteDriver::Disconnect(queue, local_addr); + + // remove the subscription record + for (list<player_devaddr_t>::iterator itr = + ConnectionMap[queue].second.begin(); itr + != ConnectionMap[queue].second.end(); ++itr) + { + if (memcmp(&(*itr), &local_addr, sizeof(local_addr)) == 0) + { + ConnectionMap[queue].second.erase(itr); + break; + } + } + // if last subscription from the client remote its connection info + if (ConnectionMap[queue].second.empty()) + { + delete ConnectionMap[queue].first; + ConnectionMap.erase(queue); + } + Driver::Unsubscribe(queue, local_addr); + return 0; +} + +void RemoteDriver::Disconnect(const QueuePointer &queue, const player_devaddr_t &local_addr) +{ + if (Connected) + { + ConnectionMap[queue].first->Unsubscribe(local_addr); + if (ConnectionMap[queue].first->subscription_count == 0) + { + QueuePointer RemoteQueue = ConnectionMap[queue].first->Disconnect(); + QueueMap.erase(RemoteQueue); + } + } +} + +int RemoteDriver::ProcessMessage(QueuePointer & resp_queue, + player_msghdr * hdr, void * data) +{ +/* + PLAYER_MSG4(8, "RemoteDriver recieved message: %d %d %d %d", + hdr->addr.host, hdr->addr.robot, hdr->addr.interf, hdr->addr.index); +*/ + + // silence warning etc while we are not connected + if (!Connected) + { + if (hdr->type == PLAYER_MSGTYPE_REQ) + { + Publish(hdr->addr, resp_queue, PLAYER_MSGTYPE_RESP_NACK, + hdr->subtype); + } + return 0; + } + + // if it is an incoming message post it to the connection object + if (hdr->type == PLAYER_MSGTYPE_REQ || hdr->type == PLAYER_MSGTYPE_CMD) + { + // if it came from a client, forward it to the remote + if (ConnectionMap.count(resp_queue) < 1 || ConnectionMap[resp_queue].first == NULL) + { + PLAYER_ERROR4("RemoteDriver recieved message from a client that was not subscribed to it: %d %d %d %d", + hdr->addr.host, hdr->addr.robot, hdr->addr.interf, hdr->addr.index); + return -1; + } + ConnectionMap[resp_queue].first->PutMsg(hdr, data); + } + else + { + // if it is another type of message then forward it to a client + if (QueueMap.count(resp_queue) > 0) + { + Publish(QueueMap[resp_queue], hdr, data); + } + } + + return 0; +} + +void RemoteDriver::ConnectAll() +{ + if (Connected) + return; + + // we are changing connection state so all subscribed devices from all clients need set up + for (ConnectionMap_t::iterator itr = ConnectionMap.begin(); itr + != ConnectionMap.end(); ++itr) + { + + QueueMap[itr->first] = itr->second.first->Connect(); + // add the reverse mapping as well + QueueMap[QueueMap[itr->first]] = itr->first; + for (list<player_devaddr_t>::iterator d_itr = + itr->second.second.begin(); d_itr != itr->second.second.end(); ++d_itr) + { + Connect(itr->first,*d_itr); + } + } + Connected = true; +} + +void RemoteDriver::DisconnectAll() +{ + if (!Connected) + return; + + // we are changing connection state so all subscribed devices from all clients need disconnected + for (ConnectionMap_t::iterator itr = ConnectionMap.begin(); itr + != ConnectionMap.end(); ++itr) + { + for (list<player_devaddr_t>::iterator d_itr = + itr->second.second.begin(); d_itr != itr->second.second.end(); ++d_itr) + { + Disconnect(itr->first,*d_itr); + } + } +} + Added: code/player/trunk/libplayercore/remote_driver.h =================================================================== --- code/player/trunk/libplayercore/remote_driver.h (rev 0) +++ code/player/trunk/libplayercore/remote_driver.h 2009-06-23 11:14:00 UTC (rev 7878) @@ -0,0 +1,119 @@ +/* + * Player - One Hell of a Robot Server + * Copyright (C) <insert dates here> + * <insert author's name(s) here> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/******************************************************************** + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ********************************************************************/ + +#ifndef REMOTE_DRIVER_H +#define REMOTE_DRIVER_H + +#include <libplayercore/playercore.h> +#include <map> +#include <list> +#include <string.h> + +using namespace std; + +struct PlayerAddressCompare +{ + bool operator()(const player_devaddr_t &lhs, const player_devaddr_t &rhs) const + { + return memcmp(&lhs,&rhs,sizeof(lhs)) < 0; + } + +}; + +struct PlayerQueueCompare +{ + bool operator()(const QueuePointer &lhs, const QueuePointer &rhs) const + { + return lhs.get() < rhs.get(); + } +}; + +typedef list<QueuePointer> QueueList; + +class RemoteConnection +{ +public: + RemoteConnection() : subscription_count(0) {}; + virtual ~RemoteConnection() {if (subscription_count != 0) Disconnect();}; + + virtual QueuePointer Connect() {return ConnectionQueue;}; + virtual QueuePointer Disconnect() {return ConnectionQueue;}; + + virtual void Subscribe(player_devaddr_t addr) {subscription_count++;}; + virtual void Unsubscribe(player_devaddr_t addr) {subscription_count--;}; + + virtual void PutMsg(player_msghdr_t* hdr, void* src) {throw "unimplemented";}; + + int subscription_count; + QueuePointer ConnectionQueue; +}; + +class RemoteDriver: public Driver { +public: + RemoteDriver(ConfigFile *cf=NULL,int section=-1) : Driver(cf,section), Connected(true){}; + virtual ~RemoteDriver() {}; + + virtual int Subscribe(QueuePointer &queue, player_devaddr_t addr); + virtual int Unsubscribe(QueuePointer &queue, player_devaddr_t addr); + virtual int ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr, + void * data); + +protected: + virtual void Connect(const QueuePointer &queue, const player_devaddr_t &addr); + virtual void Disconnect(const QueuePointer &queue, const player_devaddr_t &addr); + + + virtual RemoteConnection *CreateConnection() = 0; + + void ConnectAll(); + void DisconnectAll(); + +private: + typedef pair<RemoteConnection*, list<player_devaddr_t> > ConnectionInfo_t; + typedef map <QueuePointer,ConnectionInfo_t,PlayerQueueCompare> ConnectionMap_t; + ConnectionMap_t ConnectionMap; + + typedef map <QueuePointer,QueuePointer,PlayerQueueCompare> QueueMap_t; + QueueMap_t QueueMap; + + + bool Connected; +}; + +#endif Modified: code/player/trunk/libplayertcp/CMakeLists.txt =================================================================== --- code/player/trunk/libplayertcp/CMakeLists.txt 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayertcp/CMakeLists.txt 2009-06-23 11:14:00 UTC (rev 7878) @@ -27,7 +27,7 @@ IF (INCLUDE_TCP) OPTION (ENABLE_TCP_NODELAY "Turn off Nagel's buffering algorithm (which may increase socket latency when used)" OFF) - SET (playertcpSrcs socket_util.c playertcp.cc remote_driver.cc) + SET (playertcpSrcs socket_util.c playertcp.cc tcpremote_driver.cc) IF (NOT HAVE_POLL) SET (playertcpSrcs ${playertcpSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) ENDIF (NOT HAVE_POLL) Modified: code/player/trunk/libplayertcp/playertcp.cc =================================================================== --- code/player/trunk/libplayertcp/playertcp.cc 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayertcp/playertcp.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -65,7 +65,7 @@ #include "playertcp.h" #include "socket_util.h" -#include "remote_driver.h" +#include "tcpremote_driver.h" #if defined (WIN32) #define snprintf _snprintf @@ -232,6 +232,7 @@ return(this->Listen(&p,1)); } + QueuePointer PlayerTCP::AddClient(struct sockaddr_in* cliaddr, unsigned int local_host, @@ -241,6 +242,20 @@ int* kill_flag, bool have_lock) { + QueuePointer queue(false,PLAYER_MSGQUEUE_DEFAULT_MAXLEN); + return AddClient(cliaddr,local_host,local_port,newsock,send_banner,kill_flag,have_lock,queue); +} + +QueuePointer +PlayerTCP::AddClient(struct sockaddr_in* cliaddr, + unsigned int local_host, + unsigned int local_port, + int newsock, + bool send_banner, + int* kill_flag, + bool have_lock, + QueuePointer queue) +{ if(!have_lock) { Lock(); @@ -285,8 +300,7 @@ fileWatcher->AddFileWatch(this->client_ufds[j].fd); // Create an outgoing queue for this client - this->clients[j].queue = - QueuePointer(false,PLAYER_MSGQUEUE_DEFAULT_MAXLEN); + this->clients[j].queue = queue; // Create a buffer to hold incoming messages this->clients[j].readbuffersize = PLAYERTCP_READBUFFER_SIZE; @@ -596,6 +610,7 @@ if(this->clients[i].queue == q) { this->clients[i].del = 1; + this->clients[i].kill_flag = NULL; break; } } @@ -1402,6 +1417,7 @@ default: PLAYER_WARN1("player interface discarding message of unsupported type %s", msgtype_to_str(hdr->type)); + PLAYER_WARN4("Address: %d %d %d %d",hdr->addr.host,hdr->addr.robot,hdr->addr.interf,hdr->addr.index); resphdr.type = PLAYER_MSGTYPE_RESP_NACK; GlobalTime->GetTimeDouble(&resphdr.timestamp); resphdr.size = 0; Modified: code/player/trunk/libplayertcp/playertcp.h =================================================================== --- code/player/trunk/libplayertcp/playertcp.h 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayertcp/playertcp.h 2009-06-23 11:14:00 UTC (rev 7878) @@ -175,6 +175,14 @@ bool send_banner, int* kill_flag, bool have_lock); + QueuePointer AddClient(struct sockaddr_in* cliaddr, + unsigned int local_host, + unsigned int local_port, + int newsock, + bool send_banner, + int* kill_flag, + bool have_lock, + QueuePointer queue); int Update(int timeout); int Accept(int timeout); void Close(int cli); Deleted: code/player/trunk/libplayertcp/remote_driver.cc =================================================================== --- code/player/trunk/libplayertcp/remote_driver.cc 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayertcp/remote_driver.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -1,541 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) <insert dates here> - * <insert author's name(s) here> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -#include <config.h> - -#if !defined (WIN32) - #include <unistd.h> -#endif -#include <errno.h> -#include <sys/types.h> -#include <fcntl.h> - -#if ENABLE_TCP_NODELAY - #include <netinet/tcp.h> -#endif - -#include <libplayercore/globals.h> -#include <libplayercore/error.h> -#include <libplayerxdr/playerxdr.h> -#include "remote_driver.h" -#include "playertcp_errutils.h" - -#if defined (WIN32) - #define write _write - #define read _read -#endif - -TCPRemoteDriver::TCPRemoteDriver(player_devaddr_t addr, void* arg) - : Driver(NULL, 0, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN), - sock(-1), - setup_timeout (DEFAULT_SETUP_TIMEOUT) -{ - ptcp = reinterpret_cast<PlayerTCP*> (arg); -} - -TCPRemoteDriver::~TCPRemoteDriver() -{ -} - -int -TCPRemoteDriver::Setup() -{ - struct sockaddr_in server; - char banner[PLAYER_IDENT_STRLEN]; - int numread, thisnumread; - double t1, t2; - - packedaddr_to_dottedip(this->ipaddr,sizeof(this->ipaddr), - this->device_addr.host); - - // We can't talk to ourselves - if(this->ptcp->GetHost() == this->device_addr.host && this->ptcp->Listening(this->device_addr.robot)) - { - PLAYER_ERROR4("tried to connect to self (%s:%d:%d:%d)\n", - this->ipaddr, - this->device_addr.robot, - this->device_addr.interf, - this->device_addr.index); - return(-1); - } - - - // Construct socket - this->sock = socket(PF_INET, SOCK_STREAM, 0); - if(this->sock < 0) - { - PLAYER_ERROR1("socket call failed with error [%s]", strerror(errno)); - return(-1); - } - - server.sin_family = AF_INET; - server.sin_addr.s_addr = this->device_addr.host; - server.sin_port = htons(this->device_addr.robot); - - // Connect the socket - if(connect(this->sock, (struct sockaddr*)&server, sizeof(server)) < 0) - { - PLAYER_ERROR3("connect call on [%s:%u] failed with error [%s]", - this->ipaddr, - this->device_addr.robot, - strerror(errno)); - return(-1); - } - - PLAYER_MSG2(2,"connected to: %s:%u\n", - this->ipaddr, this->device_addr.robot); - - // make the socket non-blocking -#if defined (WIN32) - unsigned long setting = 1; - if (ioctlsocket(sock, FIONBIO, &setting) == SOCKET_ERROR) - { - STRERROR(PLAYER_ERROR1, "ioctlsocket error: %s"); - closesocket(sock); - return(-1); - } -#else - if(fcntl(this->sock, F_SETFL, O_NONBLOCK) == -1) - { - PLAYER_ERROR1("fcntl() failed: %s", strerror(errno)); - close(this->sock); - return(-1); - } -#endif - -#if ENABLE_TCP_NODELAY - // Disable Nagel's algorithm for lower latency - int yes = 1; - if( setsockopt(this->sock, IPPROTO_TCP, TCP_NODELAY, &yes, - sizeof(int)) == -1 ) - { - PLAYER_ERROR("failed to enable TCP_NODELAY - setsockopt failed"); - return(-1); - } -#endif - - // Get the banner. - GlobalTime->GetTimeDouble(&t1); - numread=0; - while(numread < (int)sizeof(banner)) - { - thisnumread = recv(this->sock, banner+numread, sizeof(banner)-numread, 0); - if(thisnumread < 0) - { - // ErrNo is zero on solaris if the call would block - if(ErrNo && ErrNo != ERRNO_EAGAIN && ErrNo != ERRNO_EWOULDBLOCK) - { - // Error on the socket -#if defined (WIN32) - LPVOID buffer = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - ErrNo, 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); - PLAYER_ERROR1("recv() failed: %s", reinterpret_cast<LPTSTR> (buffer)); - LocalFree(buffer); -#else - PLAYER_ERROR1("recv() failed: %s", strerror(ErrNo)); -#endif - PLAYER_ERROR("error reading banner from remote device"); - return(-1); - } - } - else if(thisnumread == 0) - { - PLAYER_ERROR("error reading banner from remote device (connection closed by peer)"); - return(-1); - } - else - numread += thisnumread; - GlobalTime->GetTimeDouble(&t2); - if((t2-t1) > this->setup_timeout) - { - PLAYER_ERROR("timed out reading banner from remote server"); - return(-1); - } - } - if(this->SubscribeRemote(PLAYER_OPEN_MODE) < 0) - { -#if defined (WIN32) - closesocket(this->sock); -#else - close(this->sock); -#endif - return(-1); - } - - PLAYER_MSG0(5,"Adding new TCPRemoteDriver to the PlayerTCP Client List"); - - // Add this socket for monitoring - this->kill_flag = 0; - this->queue = this->ptcp->AddClient(NULL, - this->device_addr.host, - this->device_addr.robot, - this->sock, - false, - &this->kill_flag, - pthread_equal (this->ptcp->thread, pthread_self()) != 0 ? true : false); - - PLAYER_MSG0(5,"Adding new TCPRemoteDriver to the PlayerTCP Client List...Success"); - - return(0); -} - -// (un)subscribe to the remote device -int -TCPRemoteDriver::SubscribeRemote(unsigned char mode) -{ - int encode_msglen; - unsigned char buf[512]; - player_msghdr_t hdr; - player_device_req_t req; - double t1, t2; - - int numbytes, thisnumbytes; - - memset(&hdr,0,sizeof(hdr)); - hdr.addr.interf = PLAYER_PLAYER_CODE; - hdr.type = PLAYER_MSGTYPE_REQ; - hdr.subtype = PLAYER_PLAYER_REQ_DEV; - GlobalTime->GetTimeDouble(&hdr.timestamp); - - req.addr = this->device_addr; - req.access = mode; - req.driver_name_count = 0; - - // Encode the body - if((encode_msglen = - player_device_req_pack(buf + PLAYERXDR_MSGHDR_SIZE, - sizeof(buf)-PLAYERXDR_MSGHDR_SIZE, - &req, PLAYERXDR_ENCODE)) < 0) - { - PLAYER_ERROR("failed to encode request"); - return(-1); - } - - // Rewrite the size in the header with the length of the encoded - // body, then encode the header. - hdr.size = encode_msglen; - if(player_msghdr_pack(buf, PLAYERXDR_MSGHDR_SIZE, &hdr, - PLAYERXDR_ENCODE) < 0) - { - PLAYER_ERROR("failed to encode header"); - return(-1); - } - - encode_msglen += PLAYERXDR_MSGHDR_SIZE; - - // Send the request - GlobalTime->GetTimeDouble(&t1); - numbytes = 0; - - while(numbytes < encode_msglen) - { - thisnumbytes = send(this->sock, reinterpret_cast<const char*> (buf+numbytes), encode_msglen-numbytes, 0); - if(thisnumbytes < 0) - { - // ErrNo is zero on solaris if the call would block - if(ErrNo && ErrNo != ERRNO_EAGAIN && ErrNo != ERRNO_EWOULDBLOCK) - { -#if defined (WIN32) - LPVOID buffer = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - ErrNo, 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); - PLAYER_MSG1(2, "send() failed: %s", reinterpret_cast<LPTSTR> (buffer)); - LocalFree(buffer); -#else - PLAYER_MSG1(2,"send() failed: %s", strerror(ErrNo)); -#endif - return(-1); - } - } - else - { - numbytes += thisnumbytes; - } - GlobalTime->GetTimeDouble(&t2); - if((t2-t1) > this->setup_timeout) - { - PLAYER_ERROR("timed out sending subscription request to remote server"); - return(-1); - } - } - - // If we're closing, then stop here; we don't need to hear the response. - // In any case, explicitly unsubscribing is just a courtesy. - if(mode == PLAYER_CLOSE_MODE) - return(0); - - // Receive the response header - GlobalTime->GetTimeDouble(&t1); - numbytes = 0; - while(numbytes < PLAYERXDR_MSGHDR_SIZE) - { - thisnumbytes = recv(this->sock, reinterpret_cast<char*> (buf+numbytes), PLAYERXDR_MSGHDR_SIZE-numbytes, 0); - if(thisnumbytes < 0) - { - // ErrNo is zero on solaris if the call would block - if(ErrNo && ErrNo != ERRNO_EAGAIN && ErrNo != ERRNO_EWOULDBLOCK) - { - // Error on the socket -#if defined (WIN32) - LPVOID buffer = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - ErrNo, 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); - PLAYER_ERROR1("recv() failed: %s", reinterpret_cast<LPTSTR> (buffer)); - LocalFree(buffer); -#else - PLAYER_ERROR1("recv() failed: %s", strerror(ErrNo)); -#endif - PLAYER_ERROR("error reading message header from remote device"); - return(-1); - } - } - else if(thisnumbytes == 0) - { - PLAYER_ERROR("error reading message header from remote device (connection closed by peer)"); - return(-1); - } - else - numbytes += thisnumbytes; - GlobalTime->GetTimeDouble(&t2); - if((t2-t1) > this->setup_timeout) - { - PLAYER_ERROR("timed out reading response header from remote server"); - return(-1); - } - } - - // Decode the header - if(player_msghdr_pack(buf, PLAYERXDR_MSGHDR_SIZE, &hdr, PLAYERXDR_DECODE) < 0) - { - PLAYER_ERROR("failed to decode header"); - return(-1); - } - - // Is it the right kind of message? - if(!Message::MatchMessage(&hdr, - PLAYER_MSGTYPE_RESP_ACK, - PLAYER_PLAYER_REQ_DEV, - hdr.addr)) - { - PLAYER_ERROR("got wrong kind of reply"); - return(-1); - } - - // Receive the response body - GlobalTime->GetTimeDouble(&t1); - numbytes = 0; - while(numbytes < (int)hdr.size) - { - thisnumbytes = recv(this->sock, reinterpret_cast<char*> (buf+PLAYERXDR_MSGHDR_SIZE+numbytes), hdr.size-numbytes, 0); - if(thisnumbytes < 0) - { - // ErrNo is zero on solaris if the call would block - if(ErrNo && ErrNo != ERRNO_EAGAIN && ErrNo != ERRNO_EWOULDBLOCK) - { - // Error on the socket -#if defined (WIN32) - LPVOID buffer = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - ErrNo, 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); - PLAYER_ERROR1("recv() failed: %s", reinterpret_cast<LPTSTR> (buffer)); - LocalFree(buffer); -#else - PLAYER_ERROR1("recv() failed: %s", strerror(ErrNo)); -#endif - PLAYER_ERROR("error reading message body from remote device"); - return(-1); - } - } - else if(thisnumbytes == 0) - { - PLAYER_ERROR("error reading message body from remote device (connection closed by peer)"); - return(-1); - } - else - numbytes += thisnumbytes; - GlobalTime->GetTimeDouble(&t2); - if((t2-t1) > this->setup_timeout) - { - PLAYER_ERROR("timed out reading response body from remote server"); - return(-1); - } - } - - memset(&req,0,sizeof(req)); - // Decode the body - if(player_device_req_pack(buf + PLAYERXDR_MSGHDR_SIZE, - hdr.size, &req, PLAYERXDR_DECODE) < 0) - { - PLAYER_ERROR("failed to decode reply"); - return(-1); - } - - // Did we get the right access? - if(req.access != mode) - { - PLAYER_ERROR("got wrong access"); - return(-1); - } - - // Success! - PLAYER_MSG5(1, "(un)subscribed to/from remote device %s:%d:%d:%d (%s)", - this->ipaddr, - this->device_addr.robot, - this->device_addr.interf, - this->device_addr.index, - req.driver_name); - - return(0); -} - -int -TCPRemoteDriver::Shutdown() -{ - // Have we already been killed? - if(!this->kill_flag) - { - // Unsubscribe - if(this->SubscribeRemote(PLAYER_CLOSE_MODE) < 0) - PLAYER_WARN("failed to unsubscribe from remote device"); - - // Set the delete flag, letting PlayerTCP close the connection and - // clean up. - this->ptcp->DeleteClient(this->queue, - pthread_equal(this->ptcp->thread, pthread_self()) != 0 ? true : false); - } - return(0); -} - -void -TCPRemoteDriver::Update() -{ - if (pthread_equal(this->ptcp->thread, pthread_self())) - { - //this->ptcp->Read(0,true); - this->ptcp->Lock(); - this->ptcp->ReadClient(this->queue); - this->ptcp->Unlock(); - } - this->ProcessMessages(); - if (pthread_equal(this->ptcp->thread, pthread_self())) - this->ptcp->Write(false); -} - -int -TCPRemoteDriver::ProcessMessage(QueuePointer &resp_queue, - player_msghdr * hdr, - void * data) -{ - // Is it data from the remote device? - if(Message::MatchMessage(hdr, - PLAYER_MSGTYPE_DATA, - -1, - this->device_addr)) - { - // Re-publish the message for local consumers - this->Publish(hdr, data); - return(0); - } - // Is it a command for the remote device? - else if(Message::MatchMessage(hdr, - PLAYER_MSGTYPE_CMD, - -1, - this->device_addr)) - { - // Has our connection to the remote device been closed? - if(this->kill_flag) - return(0); - - // Push it onto the outgoing queue - this->Publish(this->queue, hdr, data); - return(0); - } - // Is it a request for the remote device? - else if(Message::MatchMessage(hdr, - PLAYER_MSGTYPE_REQ, - -1, - this->device_addr)) - { - // Has our connection to the remote device been closed? - if(this->kill_flag) - { - // Send a NACK - return(-1); - } - else - { - // Push it onto the outgoing queue - this->Publish(this->queue, hdr, data); - // Store the return address for later use - this->ret_queue = resp_queue; - // Set the message filter to look for the response - this->InQueue->SetFilter(this->device_addr.host, - this->device_addr.robot, - this->device_addr.interf, - this->device_addr.index, - -1, - hdr->subtype); - // No response now; it will come later after we hear back from the - // laser - return(0); - } - } - // Forward response (success or failure) from the laser - else if((Message::MatchMessage(hdr, PLAYER_MSGTYPE_RESP_ACK, - -1, this->device_addr)) || - (Message::MatchMessage(hdr, PLAYER_MSGTYPE_RESP_NACK, - -1, this->device_addr))) - { - // Forward the response - this->Publish(this->ret_queue, hdr, data); - // Clear the filter - this->InQueue->ClearFilter(); - - return(0); - } - else - return(-1); -} - - -Driver* -TCPRemoteDriver::TCPRemoteDriver_Init(player_devaddr_t addr, void* arg) -{ - return((Driver*)(new TCPRemoteDriver(addr, arg))); -} Deleted: code/player/trunk/libplayertcp/remote_driver.h =================================================================== --- code/player/trunk/libplayertcp/remote_driver.h 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/libplayertcp/remote_driver.h 2009-06-23 11:14:00 UTC (rev 7878) @@ -1,86 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) <insert dates here> - * <insert author's name(s) here> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -#ifndef REMOTE_DRIVER_H -#define REMOTE_DRIVER_H - -#if defined (WIN32) - #if defined (PLAYER_STATIC) - #define PLAYERTCP_EXPORT - #elif defined (playertcp_EXPORTS) - #define PLAYERTCP_EXPORT __declspec (dllexport) - #else - #define PLAYERTCP_EXPORT __declspec (dllimport) - #endif -#else - #define PLAYERTCP_EXPORT -#endif - -#include <libplayercore/playercore.h> -#include "playertcp.h" - -#define DEFAULT_SETUP_TIMEOUT 1.0 - -class PLAYERTCP_EXPORT TCPRemoteDriver : public Driver -{ - private: - PlayerTCP* ptcp; - int sock; - QueuePointer queue, ret_queue; - char ipaddr[256]; - int kill_flag; - double setup_timeout; - - int SubscribeRemote(unsigned char mode); - - public: - TCPRemoteDriver(player_devaddr_t addr, void* arg); - virtual ~TCPRemoteDriver(); - - virtual int Setup(); - virtual int Shutdown(); - virtual void Update(); - virtual int ProcessMessage(QueuePointer & resp_queue, - player_msghdr * hdr, - void * data); - - static Driver* TCPRemoteDriver_Init(player_devaddr_t addr, void* arg); -}; - -#endif Added: code/player/trunk/libplayertcp/tcpremote_driver.cc =================================================================== --- code/player/trunk/libplayertcp/tcpremote_driver.cc (rev 0) +++ code/player/trunk/libplayertcp/tcpremote_driver.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -0,0 +1,408 @@ +/* + * Player - One Hell of a Robot Server + * Copyright (C) <insert dates here> + * <insert author's name(s) here> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/******************************************************************** + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ********************************************************************/ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#if ENABLE_TCP_NODELAY +#include <netinet/tcp.h> +#endif + +#include <libplayercore/globals.h> +#include <libplayercore/error.h> +#include <libplayerxdr/playerxdr.h> +#include "tcpremote_driver.h" + +QueuePointer TCPRemoteDriverConnection::Connect() +{ + struct sockaddr_in server; + char banner[PLAYER_IDENT_STRLEN]; + int numread, thisnumread; + double t1, t2; + + // if kill_flag is set then we cant use the ptcp object + if (kill_flag) + return QueuePointer(); + + packedaddr_to_dottedip(this->ipaddr, sizeof(this->ipaddr), host); + + // We can't talk to ourselves + if (this->ptcp->GetHost() == host && this->ptcp->Listening(port)) + { + PLAYER_ERROR3("tried to connect to self (%s:%d:%d)\n", this->ipaddr, + host, port); + throw "Tried to connect to self"; + } + + // Construct socket + this->sock = socket(PF_INET,SOCK_STREAM, 0); + if (this->sock < 0) + { + PLAYER_ERROR1("socket call failed with error [%s]", strerror(errno)); + throw "Connection Failed"; + } + + server.sin_family = PF_INET; + server.sin_addr.s_addr = host; + server.sin_port = htons(port); + + // Connect the socket + if (connect(this->sock, (struct sockaddr*) &server, sizeof(server)) < 0) + { + PLAYER_ERROR3("connect call on [%s:%u] failed with error [%s]", + this->ipaddr, port, strerror(errno)); + close(this->sock); + sock=-1; + throw "Connection Failed"; + } + + PLAYER_MSG2(2, "connected to: %s:%u\n", this->ipaddr, host); + + // make the socket non-blocking + if (fcntl(this->sock, F_SETFL, O_NONBLOCK) == -1) + { + PLAYER_ERROR1("fcntl() failed: %s", strerror(errno)); + close(this->sock); + sock=-1; + throw "Connection Failed"; + } + +#if ENABLE_TCP_NODELAY + // Disable Nagel's algorithm for lower latency + int yes = 1; + if (setsockopt(this->sock, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(int)) + == -1) + { + PLAYER_ERROR("failed to enable TCP_NODELAY - setsockopt failed"); + close(this->sock); + sock=-1; + throw "Connection Failed"; + } +#endif + + // Get the banner. + GlobalTime->GetTimeDouble(&t1); + numread = 0; + while (numread < (int) sizeof(banner)) + { + if ((thisnumread = read(this->sock, banner + numread, sizeof(banner) + - numread)) < 0) + { + if (errno!= EAGAIN) + { + PLAYER_ERROR("error reading banner from remote device"); + close(this->sock); + sock=-1; + throw "Connection Failed"; + } + } + else + numread += thisnumread; + GlobalTime->GetTimeDouble(&t2); + if ((t2 - t1) > this->setup_timeout) + { + PLAYER_ERROR("timed out reading banner from remote server"); + close(this->sock); + sock=-1; + throw "Connection Failed"; + } + } + + PLAYER_MSG0(5, "Adding new TCPRemoteDriver to the PlayerTCP Client List"); + + // Add this socket for monitoring + this->kill_flag = 0; + + // create a place holder queue, but we cant actually add the client connection until we get a subscription + ConnectionQueue = QueuePointer(false,PLAYER_MSGQUEUE_DEFAULT_MAXLEN); + + return ConnectionQueue; +} + +QueuePointer TCPRemoteDriverConnection::Disconnect() +{ + QueuePointer ret=ConnectionQueue; + ConnectionQueue = QueuePointer(); + return ret; +} + +void TCPRemoteDriverConnection::PutMsg(player_msghdr_t* hdr, void* src) +{ + Message msg(*hdr,src,ConnectionQueue); + ConnectionQueue->Push(msg); +} + +void TCPRemoteDriverConnection::Subscribe(player_devaddr_t addr) +{ + if (SubscribeRemote(addr, PLAYER_OPEN_MODE) != 0) + throw "Failed to subscribe"; + + if (kill_flag) + return; + + // we need to do this after the subscription as we directly + // manipulate the socket in our subscribe and unsubscribe + this->ptcp->AddClient(NULL, host, port, this->sock, + false, &this->kill_flag, (this->ptcp->thread == pthread_self()),ConnectionQueue); + +} + +void TCPRemoteDriverConnection::Unsubscribe(player_devaddr_t addr) +{ + // Do this before we unsubscribe as we need direct access to the socket + // Have we already been killed? + if (!this->kill_flag) + { + // Set the delete flag, letting PlayerTCP close the connection and + // clean up. + this->ptcp->DeleteClient(ConnectionQueue, (this->ptcp->thread + == pthread_self())); + kill_flag = 1; + } + + + if (SubscribeRemote(addr, PLAYER_CLOSE_MODE) != 0) + throw "Failed to unsubscribe"; +} + +// (un)subscribe to the remote device +int TCPRemoteDriverConnection::SubscribeRemote(player_devaddr_t addr, + unsigned char mode) +{ + int encode_msglen; + unsigned char buf[512]; + player_msghdr_t hdr; + player_device_req_t req; + double t1, t2; + + int numbytes, thisnumbytes; + + // if we have no socket then we dont need to unsub + if (sock < 0) + return 0; + + memset(&hdr, 0, sizeof(hdr)); + hdr.addr.interf = PLAYER_PLAYER_CODE; + hdr.type = PLAYER_MSGTYPE_REQ; + hdr.subtype = PLAYER_PLAYER_REQ_DEV; + GlobalTime->GetTimeDouble(&hdr.timestamp); + + PLAYER_MSG4(8,"TCPRemote sub for: %d %d %d %d",addr.host, addr.robot,addr.interf,addr.index); + + + req.addr = addr; + req.access = mode; + req.driver_name_count = 0; + + // Encode the body + if ((encode_msglen = player_device_req_pack(buf + PLAYERXDR_MSGHDR_SIZE, + sizeof(buf) - PLAYERXDR_MSGHDR_SIZE, &req, PLAYERXDR_ENCODE)) < 0) + { + PLAYER_ERROR("failed to encode request"); + return (-1); + } + + // Rewrite the size in the header with the length of the encoded + // body, then encode the header. + hdr.size = encode_msglen; + if (player_msghdr_pack(buf, PLAYERXDR_MSGHDR_SIZE, &hdr, PLAYERXDR_ENCODE) + < 0) + { + PLAYER_ERROR("failed to encode header"); + return (-1); + } + + encode_msglen += PLAYERXDR_MSGHDR_SIZE; + + // Send the request + GlobalTime->GetTimeDouble(&t1); + numbytes = 0; + + while (numbytes < encode_msglen) + { + if ((thisnumbytes = write(this->sock, buf + numbytes, encode_msglen + - numbytes)) < 0) + { + if (errno!= EAGAIN) + { + PLAYER_ERROR1("write failed: %s", strerror(errno)); + return (-1); + } + } + else + { + numbytes += thisnumbytes; + } + GlobalTime->GetTimeDouble(&t2); + if ((t2 - t1) > this->setup_timeout) + { + PLAYER_ERROR( + "timed out sending subscription request to remote server"); + return (-1); + } + } + + // If we're closing, then stop here; we don't need to hear the response. + // In any case, explicitly unsubscribing is just a courtesy. + if (mode == PLAYER_CLOSE_MODE) + { + PLAYER_MSG5(5, "unsubscribed from remote device %s:%d:%d:%d (%s)", + this->ipaddr, addr.robot, addr.interf, + addr.index, req.driver_name); + + return (0); + } + + // Receive the response header + GlobalTime->GetTimeDouble(&t1); + numbytes = 0; + while (numbytes < PLAYERXDR_MSGHDR_SIZE) + { + if ((thisnumbytes = read(this->sock, buf + numbytes, + PLAYERXDR_MSGHDR_SIZE - numbytes)) < 0) + { + if (errno!= EAGAIN) + { + PLAYER_ERROR1("read failed: %s", strerror(errno)); + return (-1); + } + } + else + numbytes += thisnumbytes; + GlobalTime->GetTimeDouble(&t2); + if ((t2 - t1) > this->setup_timeout) + { + PLAYER_ERROR("timed out reading response header from remote server"); + return (-1); + } + } + + // Decode the header + if (player_msghdr_pack(buf, PLAYERXDR_MSGHDR_SIZE, &hdr, PLAYERXDR_DECODE) + < 0) + { + PLAYER_ERROR("failed to decode header"); + return (-1); + } + + // Is it the right kind of message? + if (!Message::MatchMessage(&hdr, PLAYER_MSGTYPE_RESP_ACK, + PLAYER_PLAYER_REQ_DEV, hdr.addr)) + { + PLAYER_ERROR4("got wrong kind of reply %d:%d %d:%d",hdr.type,hdr.subtype,hdr.addr.interf,hdr.addr.index); + PLAYER_ERROR4("was trying to subscribe to %d:%d %d:%d",addr.host,addr.robot,addr.interf,addr.index); + return (-1); + } + + // Receive the response body + GlobalTime->GetTimeDouble(&t1); + numbytes = 0; + while (numbytes < (int) hdr.size) + { + if ((thisnumbytes = read(this->sock, buf + PLAYERXDR_MSGHDR_SIZE + + numbytes, hdr.size - numbytes)) < 0) + { + if (errno!= EAGAIN) + { + PLAYER_ERROR1("read failed: %s", strerror(errno)); + return (-1); + } + } + else + numbytes += thisnumbytes; + GlobalTime->GetTimeDouble(&t2); + if ((t2 - t1) > this->setup_timeout) + { + PLAYER_ERROR("timed out reading response body from remote server"); + return (-1); + } + } + + memset(&req, 0, sizeof(req)); + // Decode the body + if (player_device_req_pack(buf + PLAYERXDR_MSGHDR_SIZE, hdr.size, &req, + PLAYERXDR_DECODE) < 0) + { + PLAYER_ERROR("failed to decode reply"); + return (-1); + } + + // Did we get the right access? + if (req.access != mode) + { + PLAYER_ERROR("got wrong access"); + return (-1); + } + + + PLAYER_MSG0(5, + "Adding new TCPRemoteDriver to the PlayerTCP Client List...Success"); + + + // Success! + PLAYER_MSG5(5, "subscribed to remote device %s:%d:%d:%d (%s)", + this->ipaddr, addr.robot, addr.interf, + addr.index, req.driver_name); + + return (0); +} + +TCPRemoteDriver::TCPRemoteDriver(player_devaddr_t addr, void* arg) : + RemoteDriver(NULL, 0) +{ + ptcp = reinterpret_cast<PlayerTCP*> (arg); + host = addr.host; + port = addr.robot; + // no need to call add device, this is done already by device table for remote devices +} + +TCPRemoteDriver::~TCPRemoteDriver() +{ +} + +Driver* +TCPRemoteDriver::TCPRemoteDriver_Init(player_devaddr_t addr, void* arg) +{ + return ((Driver*) (new TCPRemoteDriver(addr, arg))); +} Added: code/player/trunk/libplayertcp/tcpremote_driver.h =================================================================== --- code/player/trunk/libplayertcp/tcpremote_driver.h (rev 0) +++ code/player/trunk/libplayertcp/tcpremote_driver.h 2009-06-23 11:14:00 UTC (rev 7878) @@ -0,0 +1,115 @@ +/* + * Player - One Hell of a Robot Server + * Copyright (C) <insert dates here> + * <insert author's name(s) here> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/******************************************************************** + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ********************************************************************/ + +#ifndef TCPREMOTE_DRIVER_H +#define TCPREMOTE_DRIVER_H + +#include <libplayercore/playercore.h> +#include <libplayercore/remote_driver.h> +#include "playertcp.h" + +#define DEFAULT_SETUP_TIMEOUT 3.0 + +class TCPRemoteDriverConnection: public RemoteConnection +{ +public: + TCPRemoteDriverConnection(PlayerTCP* ptcp, unsigned remote_host, + unsigned short remote_port) : + ptcp(ptcp), host(remote_host), port(remote_port), sock(-1), setup_timeout(DEFAULT_SETUP_TIMEOUT), kill_flag(0) + { + } + ; + + virtual ~TCPRemoteDriverConnection() + { + } + ; + + virtual QueuePointer Connect(); + virtual QueuePointer Disconnect(); + + virtual void Subscribe(player_devaddr_t addr); + virtual void Unsubscribe(player_devaddr_t addr); + + void PutMsg(player_msghdr_t* hdr, void* src); + +private: + int SubscribeRemote(player_devaddr_t addr, unsigned char mode); + + PlayerTCP* ptcp; + unsigned host; + unsigned short port; + char ipaddr[256]; + int sock; + double setup_timeout; + int kill_flag; +}; + +class TCPRemoteDriver: public RemoteDriver +{ +private: + PlayerTCP* ptcp; + unsigned host; + unsigned short port; + // QueuePointer queue, ret_queue; + + virtual RemoteConnection *CreateConnection() + { + return new TCPRemoteDriverConnection(ptcp, host, port); + } + ; + +/* virtual int ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr, + void * data) + { + PLAYER_MSG4(8, "RemoteDriver recieved message: %d %d %d %d", + hdr->addr.host, hdr->addr.robot, hdr->addr.interf, hdr->addr.index); + return RemoteDriver::ProcessMessage(resp_queue,hdr,data); + }*/ + + +public: + TCPRemoteDriver(player_devaddr_t addr, void* arg); + virtual ~TCPRemoteDriver(); + + static Driver* TCPRemoteDriver_Init(player_devaddr_t addr, void* arg); + +}; + +#endif Modified: code/player/trunk/server/drivers/shell/passthrough.cc =================================================================== --- code/player/trunk/server/drivers/shell/passthrough.cc 2009-06-23 08:08:05 UTC (rev 7877) +++ code/player/trunk/server/drivers/shell/passthrough.cc 2009-06-23 11:14:00 UTC (rev 7878) @@ -22,12 +22,12 @@ /* This is the new passthrough driver for Player 2. It does the following: - - From the configuration file, reads requires ["SRC interface"], and provides ["DST interface"] - - When a client connects to our DST interface, it subscribes to the SRC interface, and forwards all packets to the DST interface. - - If the client sends a command to the DST, it gets forwarded to the SRC interfaces, and the ACK, NACK, or SYNCH answers get sent back to the DST interface - - When the client disconnects from our DST interface, we unsubscribe from the SRC interface. - - When forwarding packets, the header gets changed accordingly, specifically: devaddr (host, robot, interface, index) -*/ + - From the configuration file, reads requires ["SRC interface"], and provides ["DST interface"] + - When a client connects to our DST interface, it subscribes to the SRC interface, and forwards all packets to the DST interface. + - If the client sends a command to the DST, it gets forwarded to the SRC interfaces, and the ACK, NACK, or SYNCH answers get sent back to the DST interface + - When the client disconnects from our DST interface, we unsubscribe from the SRC interface. + - When forwarding packets, the header gets changed accordingly, specifically: devaddr (host, robot, interface, index) + */ //Doxygen documentation taken partly from the old Player 1.x passthrough driver, and modified to fit the new one @@ -36,368 +36,376 @@ /** @defgroup driver_passthrough passthrough * @brief General-purpose proxy driver -The @p passthrough driver relays packets between two player interfaces. -It connects as a @e client to an interface, and offers the same interface -to other clients. All communication packets are forwarded between the two. + The @p passthrough driver relays packets between two player interfaces. + It connects as a @e client to an interface, and offers the same interface + to other clients. All communication packets are forwarded between the two. -This is specially useful to aggregate many player devices in a single Player -Server, and control them using only one connection. Probably the most -useful usage is to have a Player Server offering a stable set of interfaces, -that get forwarded to the appropriate Player Servers connected to the hardware. -If a device is moved around to a different computer, the clients don't have to -be reconfigured, since the change is done only in the server running the passthrough -driver. + This is specially useful to aggregate many player devices in a single Player + Server... [truncated message content] |
From: <th...@us...> - 2009-06-27 11:40:27
|
Revision: 7922 http://playerstage.svn.sourceforge.net/playerstage/?rev=7922&view=rev Author: thjc Date: 2009-06-27 11:40:25 +0000 (Sat, 27 Jun 2009) Log Message: ----------- added custom version of UseSwig.cmake that works with +'s in the filename Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt Added Paths: ----------- code/player/trunk/cmake/internal/UseSwig_Player.cmake Modified: code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-06-27 03:07:39 UTC (rev 7921) +++ code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-06-27 11:40:25 UTC (rev 7922) @@ -7,7 +7,8 @@ IF (SWIG_FOUND) MESSAGE (STATUS "Python bindings for C client library will be built") - INCLUDE (${SWIG_USE_FILE}) + #INCLUDE (${SWIG_USE_FILE}) + INCLUDE (${PLAYER_CMAKE_DIR}/internal/UseSwig_Player.cmake) FIND_PACKAGE (PythonLibs) INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) @@ -33,9 +34,7 @@ DEPENDS "${playerc_wrap_prefix}.h") # Copy playerc.i to the build directory - SET (playerc_i_in "${CMAKE_CURRENT_SOURCE_DIR}/playerc.i") - SET (playerc_i "${CMAKE_CURRENT_BINARY_DIR}/playerc.i") - CONFIGURE_FILE (${playerc_i_in} ${playerc_i} COPYONLY) + SET (playerc_i "${CMAKE_CURRENT_SOURCE_DIR}/playerc.i") SWIG_ADD_MODULE (playerc python ${playerc_i}) SWIG_LINK_LIBRARIES (playerc ${PYTHON_LIBRARIES}) Modified: code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-27 03:07:39 UTC (rev 7921) +++ code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-27 11:40:25 UTC (rev 7922) @@ -14,7 +14,8 @@ IF (SWIG_FOUND) MESSAGE (STATUS "Ruby bindings for C client library will be built") - INCLUDE (${SWIG_USE_FILE}) + #INCLUDE (${SWIG_USE_FILE}) + INCLUDE (${PLAYER_CMAKE_DIR}/internal/UseSwig_Player.cmake) INCLUDE_DIRECTORIES (${RUBY_INCLUDE_PATH}) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}) @@ -38,10 +39,7 @@ DEPENDS "${playerc_wrap_prefix}.i" DEPENDS "${playerc_wrap_prefix}.h") - # Copy playerc.i to the build directory - SET (playerc_i_in "${CMAKE_CURRENT_SOURCE_DIR}/playerc.i") - SET (playerc_i "${CMAKE_CURRENT_BINARY_DIR}/playerc.i") - CONFIGURE_FILE (${playerc_i_in} ${playerc_i} COPYONLY) + SET (playerc_i "${CMAKE_CURRENT_SOURCE_DIR}/playerc.i") #If playercr is called simply playerc, all sorts of errors happen #I guess is namespace conflict with Python bindings' playerc Added: code/player/trunk/cmake/internal/UseSwig_Player.cmake =================================================================== --- code/player/trunk/cmake/internal/UseSwig_Player.cmake (rev 0) +++ code/player/trunk/cmake/internal/UseSwig_Player.cmake 2009-06-27 11:40:25 UTC (rev 7922) @@ -0,0 +1,177 @@ +# - SWIG module for CMake +# Defines the following macros: +# SWIG_ADD_MODULE(name language [ files ]) +# - Define swig module with given name and specified language +# SWIG_LINK_LIBRARIES(name [ libraries ]) +# - Link libraries to swig module +# All other macros are for internal use only. +# To get the actual name of the swig module, +# use: ${SWIG_MODULE_name_REAL_NAME}. +# Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify +# special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add +# special flags to all swig calls. +# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify +# where to write all the swig generated module (swig -outdir option) +# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used +# to specify extra dependencies for the generated modules. + +SET(SWIG_CXX_EXTENSION "cxx") +SET(SWIG_EXTRA_LIBRARIES "") + +SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") + +# +# For given swig module initialize variables associated with it +# +MACRO(SWIG_MODULE_INITIALIZE name language) + STRING(TOUPPER "${language}" swig_uppercase_language) + STRING(TOLOWER "${language}" swig_lowercase_language) + SET(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}") + SET(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") + + IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xUNKNOWNx$") + MESSAGE(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") + ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xUNKNOWNx$") + + SET(SWIG_MODULE_${name}_REAL_NAME "${name}") + IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$") + SET(SWIG_MODULE_${name}_REAL_NAME "_${name}") + ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$") + IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPERLx$") + SET(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") + ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPERLx$") +ENDMACRO(SWIG_MODULE_INITIALIZE) + +# +# For a given language, input file, and output file, determine extra files that +# will be generated. This is internal swig macro. +# + +MACRO(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) + GET_SOURCE_FILE_PROPERTY(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename + ${infile} SWIG_MODULE_NAME) + IF(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") + GET_FILENAME_COMPONENT(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) + ENDIF(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") + FOREACH(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) + SET(${outfiles} ${${outfiles}} + "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") + ENDFOREACH(it) +ENDMACRO(SWIG_GET_EXTRA_OUTPUT_FILES) + +# +# Take swig (*.i) file and add proper custom commands for it +# +MACRO(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) + SET(swig_full_infile ${infile}) + GET_FILENAME_COMPONENT(swig_source_file_path "${infile}" PATH) + GET_FILENAME_COMPONENT(swig_source_file_name_we "${infile}" NAME_WE) + GET_SOURCE_FILE_PROPERTY(swig_source_file_generated ${infile} GENERATED) + GET_SOURCE_FILE_PROPERTY(swig_source_file_cplusplus ${infile} CPLUSPLUS) + GET_SOURCE_FILE_PROPERTY(swig_source_file_flags ${infile} SWIG_FLAGS) + IF("${swig_source_file_flags}" STREQUAL "NOTFOUND") + SET(swig_source_file_flags "") + ENDIF("${swig_source_file_flags}" STREQUAL "NOTFOUND") + + # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir + IF(CMAKE_SWIG_OUTDIR) + SET(swig_outdir ${CMAKE_SWIG_OUTDIR}) + ELSE(CMAKE_SWIG_OUTDIR) + SET(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) + ENDIF(CMAKE_SWIG_OUTDIR) + SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE} + swig_extra_generated_files + "${swig_outdir}" + "${infile}") + # add the language into the name of the file (i.e. TCL_wrap) + # this allows for the same .i file to be wrapped into different languages + SET(swig_generated_file_fullname + "${swig_outdir}/${swig_source_file_name_we}${SWIG_MODULE_${name}_LANGUAGE}_wrap") + + IF(swig_source_file_cplusplus) + SET(swig_generated_file_fullname + "${swig_generated_file_fullname}.${SWIG_CXX_EXTENSION}") + ELSE(swig_source_file_cplusplus) + SET(swig_generated_file_fullname + "${swig_generated_file_fullname}.c") + ENDIF(swig_source_file_cplusplus) + + #MESSAGE("Full path to source file: ${infile}") + #MESSAGE("Full path to the output file: ${swig_generated_file_fullname}") + GET_DIRECTORY_PROPERTY(cmake_include_directories INCLUDE_DIRECTORIES) + SET(swig_include_dirs) + FOREACH(it ${cmake_include_directories}) + SET(swig_include_dirs ${swig_include_dirs} "-I${it}") + ENDFOREACH(it) + + SET(swig_special_flags) + # default is c, so add c++ flag if it is c++ + IF(swig_source_file_cplusplus) + SET(swig_special_flags ${swig_special_flags} "-c++") + ENDIF(swig_source_file_cplusplus) + SET(swig_extra_flags) + IF(SWIG_MODULE_${name}_EXTRA_FLAGS) + SET(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) + ENDIF(SWIG_MODULE_${name}_EXTRA_FLAGS) + ADD_CUSTOM_COMMAND( + OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files} + COMMAND "${SWIG_EXECUTABLE}" + ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" + ${swig_source_file_flags} + ${CMAKE_SWIG_FLAGS} + -outdir ${swig_outdir} + ${swig_special_flags} + ${swig_extra_flags} + ${swig_include_dirs} + -o "${swig_generated_file_fullname}" + "${infile}" + MAIN_DEPENDENCY "${swig_source_file_fullname}" + DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS} + COMMENT "Swig source") + SET_SOURCE_FILES_PROPERTIES("${swig_generated_file_fullname}" ${swig_extra_generated_files} + PROPERTIES GENERATED 1) + SET(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files}) +ENDMACRO(SWIG_ADD_SOURCE_TO_MODULE) + +# +# Create Swig module +# +MACRO(SWIG_ADD_MODULE name language) + SWIG_MODULE_INITIALIZE(${name} ${language}) + SET(swig_dot_i_sources) + SET(swig_other_sources) + FOREACH(it ${ARGN}) + IF(${it} MATCHES ".*\\.i$") + SET(swig_dot_i_sources ${swig_dot_i_sources} "${it}") + ELSE(${it} MATCHES ".*\\.i$") + SET(swig_other_sources ${swig_other_sources} "${it}") + ENDIF(${it} MATCHES ".*\\.i$") + ENDFOREACH(it) + + SET(swig_generated_sources) + FOREACH(it ${swig_dot_i_sources}) + SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it}) + SET(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}") + ENDFOREACH(it) + GET_DIRECTORY_PROPERTY(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) + SET_DIRECTORY_PROPERTIES(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}") + ADD_LIBRARY(${SWIG_MODULE_${name}_REAL_NAME} + MODULE + ${swig_generated_sources} + ${swig_other_sources}) + SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} + PROPERTIES PREFIX "") +ENDMACRO(SWIG_ADD_MODULE) + +# +# Like TARGET_LINK_LIBRARIES but for swig modules +# +MACRO(SWIG_LINK_LIBRARIES name) + IF(SWIG_MODULE_${name}_REAL_NAME) + TARGET_LINK_LIBRARIES(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN}) + ELSE(SWIG_MODULE_${name}_REAL_NAME) + MESSAGE(SEND_ERROR "Cannot find Swig library \"${name}\".") + ENDIF(SWIG_MODULE_${name}_REAL_NAME) +ENDMACRO(SWIG_LINK_LIBRARIES name) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-06-28 11:22:46
|
Revision: 7925 http://playerstage.svn.sourceforge.net/playerstage/?rev=7925&view=rev Author: thjc Date: 2009-06-28 11:22:43 +0000 (Sun, 28 Jun 2009) Log Message: ----------- install playerxdrgen set ruby install path relative to the project install prefix Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt code/player/trunk/libplayerxdr/CMakeLists.txt Modified: code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-28 01:27:22 UTC (rev 7924) +++ code/player/trunk/client_libs/libplayerc/bindings/ruby/CMakeLists.txt 2009-06-28 11:22:43 UTC (rev 7925) @@ -54,7 +54,9 @@ #TODO: find ruby in windows, check install dir is correct - SET (RUBY_BINDINGS_INSTALL_DIR ${RUBY_SITELIB_DIR} CACHE PATH "Ruby bindings installation directory under $RUBY_SITELIB_DIR") + STRING(REPLACE "/usr/" "" ruby_relative_sitelib_dir ${RUBY_SITELIB_DIR}) + STRING(REPLACE "local/" "" ruby_relative_sitelib_dir ${ruby_relative_sitelib_dir}) + SET (RUBY_BINDINGS_INSTALL_DIR ${ruby_relative_sitelib_dir} CACHE PATH "Ruby bindings installation directory under $RUBY_SITELIB_DIR") MARK_AS_ADVANCED (RUBY_BINDINGS_INSTALL_DIR) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/playercr.so Modified: code/player/trunk/libplayerxdr/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerxdr/CMakeLists.txt 2009-06-28 01:27:22 UTC (rev 7924) +++ code/player/trunk/libplayerxdr/CMakeLists.txt 2009-06-28 11:22:43 UTC (rev 7925) @@ -68,3 +68,5 @@ PLAYER_MAKE_PKGCONFIG ("playerxdr" "Player XDR messaging library - part of the Player Project" "" "" "" "${xdrLibFlag}") PLAYER_INSTALL_HEADERS (playerxdr ${playerxdr_h} functiontable.h) + +INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/playerxdrgen.py RENAME playerxdrgen DESTINATION bin) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-07-02 23:50:08
|
Revision: 7942 http://playerstage.svn.sourceforge.net/playerstage/?rev=7942&view=rev Author: gbiggs Date: 2009-07-02 23:50:06 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Applied patch #2811396 Modified Paths: -------------- code/player/trunk/rtk2/rtk_fig.c code/player/trunk/utils/pmap/rmap.cpp Modified: code/player/trunk/rtk2/rtk_fig.c =================================================================== --- code/player/trunk/rtk2/rtk_fig.c 2009-07-02 23:45:31 UTC (rev 7941) +++ code/player/trunk/rtk2/rtk_fig.c 2009-07-02 23:50:06 UTC (rev 7942) @@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include <float.h> #include "rtk.h" #include "rtkprivate.h" @@ -508,10 +509,10 @@ rtk_region_set_empty(fig->region); // Reset the figure bounding box. - fig->min_x = +DBL_MAX/2; - fig->min_y = +DBL_MAX/2; - fig->max_x = -DBL_MAX/2; - fig->max_y = -DBL_MAX/2; + fig->min_x = +DBL_MAX / 2.0; + fig->min_y = +DBL_MAX / 2.0; + fig->max_x = -DBL_MAX / 2.0; + fig->max_y = -DBL_MAX / 2.0; // Recalculate strokes for (i = 0; i < fig->stroke_count; i++) Modified: code/player/trunk/utils/pmap/rmap.cpp =================================================================== --- code/player/trunk/utils/pmap/rmap.cpp 2009-07-02 23:45:31 UTC (rev 7941) +++ code/player/trunk/utils/pmap/rmap.cpp 2009-07-02 23:50:06 UTC (rev 7942) @@ -28,6 +28,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <float.h> #include <gsl/gsl_multimin.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-07-12 10:53:41
|
Revision: 8000 http://playerstage.svn.sourceforge.net/playerstage/?rev=8000&view=rev Author: gbiggs Date: 2009-07-12 10:53:35 +0000 (Sun, 12 Jul 2009) Log Message: ----------- Make Player (probably) work on Windows; plugins should work in Windows now; several other Windows fixes. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/CMake_Todo.txt code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt code/player/trunk/cmake/UsePlayerPlugin.cmake.in code/player/trunk/examples/CMakeLists.txt code/player/trunk/examples/libplayerc++/CMakeLists.txt code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in code/player/trunk/examples/libplayerc++/args.h code/player/trunk/examples/libplayerc++/clientgraphics.cc code/player/trunk/examples/libplayerc++/clientgraphics3d.cc code/player/trunk/examples/libplayerc++/goto.cc code/player/trunk/examples/libplayerc++/grip.cc code/player/trunk/examples/libplayerc++/speech.cc code/player/trunk/examples/libplayerc++/speech_cpp_client.cc code/player/trunk/examples/plugins/CMakeLists.txt code/player/trunk/examples/plugins/exampledriver/exampledriver.cc code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt code/player/trunk/examples/plugins/exampleinterface/eginterf_client.h code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc code/player/trunk/examples/plugins/multidriver/multidriver.cc code/player/trunk/examples/plugins/opaquedriver/opaquedriver.cc code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayercore/playercore.h code/player/trunk/libplayercore/playerinterfacegen.py code/player/trunk/libplayercore/plugins.cc code/player/trunk/libplayercore/plugins.h code/player/trunk/libplayercore/remote_driver.h code/player/trunk/libplayertcp/CMakeLists.txt code/player/trunk/libplayertcp/tcpremote_driver.cc code/player/trunk/libplayertcp/tcpremote_driver.h code/player/trunk/libplayerwkb/CMakeLists.txt code/player/trunk/libplayerxdr/CMakeLists.txt code/player/trunk/libplayerxdr/playerxdrgen.py code/player/trunk/replace/CMakeLists.txt code/player/trunk/replace/dirname.c code/player/trunk/replace/getopt.c code/player/trunk/replace/replace.h code/player/trunk/replace/round.c code/player/trunk/replace/rpc/xdr.h code/player/trunk/server/CMakeLists.txt code/player/trunk/server/drivers/laser/laserposeinterpolator.cc code/player/trunk/server/drivers/planner/wavefront/CMakeLists.txt code/player/trunk/server/drivers/shell/passthrough.cc code/player/trunk/server/drivers/shell/readlog.cc code/player/trunk/server/libplayerdrivers/CMakeLists.txt code/player/trunk/utils/playerprint/CMakeLists.txt code/player/trunk/utils/playerprop/CMakeLists.txt code/player/trunk/win32_todo.txt Added Paths: ----------- code/player/trunk/server/drivers/planner/wavefront/test/ code/player/trunk/server/drivers/planner/wavefront/test/CMakeLists.txt Removed Paths: ------------- code/player/trunk/server/drivers/planner/wavefront/Makefile.test Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -65,6 +65,11 @@ INCLUDE_DIRECTORIES (${PLAYER_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYER_EXTRA_LIB_DIRS}) +IF (PLAYER_OS_WIN) + # This is pretty much a universal include on Windows + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) +ENDIF (PLAYER_OS_WIN) + ADD_SUBDIRECTORY (client_libs) ADD_SUBDIRECTORY (libplayercore) ADD_SUBDIRECTORY (libplayerxdr) @@ -84,17 +89,9 @@ ENDIF (PLAYER_OS_WIN) MESSAGE (STATUS "") -#SET (PLAYERCORE_INT_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories for playercore" FORCE) -#SET (PLAYERCORE_INT_LINK_DIRS "" CACHE INTERNAL "Library directories to link playercore to" FORCE) SET (PLAYERCORE_INT_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link playercore to" FORCE) -#SET (PLAYERCORE_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playercore" FORCE) -#SET (PLAYERCORE_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playercore" FORCE) SET (PLAYERCORE_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playercore" FORCE) -#SET (PLAYERC_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playerc" FORCE) -#SET (PLAYERC_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playerc" FORCE) SET (PLAYERC_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playerc" FORCE) -#SET (PLAYERCC_EXTRA_INCLUDE_DIRS "" CACHE INTERNAL "Extra include directories with playercc" FORCE) -#SET (PLAYERCC_EXTRA_LINK_DIRS "" CACHE INTERNAL "Library directories to link in with playercc" FORCE) SET (PLAYERCC_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to with playercc" FORCE) # Create packages Modified: code/player/trunk/CMake_Todo.txt =================================================================== --- code/player/trunk/CMake_Todo.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/CMake_Todo.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,7 +1,4 @@ - Java bindings for core, xdr, tcp, etc -- Figure out why it always rebuilds driverregistry.c. Make it stop. - dist tarballs, packages, etc - add in the extra_dist files to the source one, make the debian one -- Drivers being disabled by a check used to correctly force their option to off. Figure out why this broke. Fix it. - Figure out why C++ tests and C++ examples don't link properly when building as static libs, even though the server and utils do. -- Add CMakeLists equivalent of the wavefront driver's Makefile.test (and get rid of Makefile.test) - PLAYER_PROCESS_ARGUMENTS should not need to have arguments enclosed in quotes. Fix this. Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -56,13 +56,13 @@ dev_wifi.c dev_wsn.c) IF (NOT HAVE_GETTIMEOFDAY) - SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/gettimeofday.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_GETTIMEOFDAY) IF (NOT HAVE_POLL) - SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_POLL) IF (NOT HAVE_NANOSLEEP) - SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_NANOSLEEP) IF (HAVE_M) @@ -86,7 +86,8 @@ LINK_DIRECTORIES (${PLAYERC_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) -TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror playerwkb ${PLAYERC_EXTRA_LINK_LIBRARIES}) +TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror playerwkb + ${playerreplaceLib} ${PLAYERC_EXTRA_LINK_LIBRARIES}) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (playerc playerjpeg) ENDIF (HAVE_JPEG) @@ -101,5 +102,5 @@ LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERC_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playerc" "Andrew Howard's Player C client library - part of the Player Project" - "playerxdr playererror playerwkb" "" "${pkgconfigCFlags}" - "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") + "playerxdr playererror playerwkb ${playerreplaceLib}" "" + "${pkgconfigCFlags}" "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -203,7 +203,7 @@ wsnproxy.cc) IF (NOT HAVE_NANOSLEEP) - SET (playerccSrcs ${playerccSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_NANOSLEEP) IF (HAVE_M) @@ -218,7 +218,8 @@ INCLUDE_DIRECTORIES (${PLAYERCC_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playerc++ ${playerccSrcs} ${playercppconfig_h}) - TARGET_LINK_LIBRARIES (playerc++ playerwkb playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (playerc++ playerwkb playerxdr playerutils playerc + ${playerreplaceLib} ${PLAYERCC_EXTRA_LINK_LIBRARIES}) SET (pkgconfigCFlags) SET (pkgconfigLinkDirs) @@ -228,8 +229,8 @@ LIST_TO_STRING_WITH_PREFIX (pkgconfigLinkLibs "-l" ${PLAYERCC_EXTRA_LINK_LIBRARIES}) PLAYER_MAKE_PKGCONFIG ("playerc++" "C++ wrapper for libplayerc - part of the Player Project" - "playerwkb playerxdr playerc" "" "${pkgconfigCFlags}" - "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") + "playerwkb playerxdr playerc ${playerreplaceLib}" "" + "${pkgconfigCFlags}" "${pkgconfigLinkDirs} ${pkgconfigLinkLibs}") CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerC++.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerC++.cmake @ONLY) PLAYER_INSTALL_HEADERS (playerc++ ${playercppconfig_h} Modified: code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -30,15 +30,17 @@ test_ranger.cc) IF (NOT HAVE_USLEEP) - SET (testsSrcs ${testsSrcs} ${PROJECT_SOURCE_DIR}/replace/usleep.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_USLEEP) IF (NOT HAVE_ROUND) - SET (testsSrcs ${testsSrcs} ${PROJECT_SOURCE_DIR}/replace/round.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_ROUND) LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) ADD_EXECUTABLE (playerc++_test ${testsSrcs}) - TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror playerwkb ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr + playererror playerwkb ${playerreplaceLib} + ${PLAYERCC_EXTRA_LINK_LIBRARIES}) ENDIF (BUILD_CC_TESTS) ENDIF (BUILD_PLAYERCC_BOOST) ENDIF (BUILD_PLAYERCC) Modified: code/player/trunk/cmake/UsePlayerPlugin.cmake.in =================================================================== --- code/player/trunk/cmake/UsePlayerPlugin.cmake.in 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/cmake/UsePlayerPlugin.cmake.in 2009-07-12 10:53:35 UTC (rev 8000) @@ -206,6 +206,8 @@ IF (PLUGIN_PLAYERC_LINK_LIBS) TARGET_LINK_LIBRARIES (${_interfName} ${PLUGIN_PLAYERC_LINK_LIBS}) ENDIF (PLUGIN_PLAYERC_LINK_LIBS) + GET_SOURCE_FILE_PROPERTY (currentCFlags ${xdr_c} COMPILE_FLAGS) + SET_SOURCE_FILES_PROPERTIES (${xdr_c} PROPERTIES COMPILE_FLAGS "-Dplayerxdr_EXPORTS ${currentCFlags}") # Get the current cflags for each source file, and add the global ones # (this allows the user to specify individual cflags for each source file Modified: code/player/trunk/examples/CMakeLists.txt =================================================================== --- code/player/trunk/examples/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -2,11 +2,9 @@ OPTION (BUILD_EXAMPLES "Build the libplayerc, libplayerc++ and plugin examples" ON) IF (BUILD_EXAMPLES) - IF (NOT PLAYER_OS_WIN) - ADD_SUBDIRECTORY (plugins) - ADD_SUBDIRECTORY (libplayerc) - ADD_SUBDIRECTORY (libplayerc++) - ENDIF (NOT PLAYER_OS_WIN) + ADD_SUBDIRECTORY (plugins) + ADD_SUBDIRECTORY (libplayerc) + ADD_SUBDIRECTORY (libplayerc++) ENDIF (BUILD_EXAMPLES) MESSAGE (STATUS "====================") MESSAGE (STATUS "") Modified: code/player/trunk/examples/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/examples/libplayerc++/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -7,12 +7,18 @@ SET (exampleBoostSrcs example1.cc example3.cc goto.cc speech_cpp_client.cc) SET (exampleBoostSigSrcs example2.cc) + IF (NOT HAVE_GETOPT) + SET (playerreplaceLib playerreplace) + ENDIF (NOT HAVE_GETOPT) + ADD_DEFINITIONS (${PLAYERCC_DEFINITIONS}) INCLUDE_DIRECTORIES (${PLAYERCC_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYERCC_EXTRA_LINK_DIRS}) MACRO (PLAYERCPP_ADD_EXAMPLE _name) ADD_EXECUTABLE (${_name} ${ARGN}) - TARGET_LINK_LIBRARIES (${_name} playerc++ playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (${_name} playerc++ playerc playerxdr playererror + ${playerreplaceLib} ${PLAYERC_EXTRA_LINK_LIBRARIES} + ${PLAYERCC_EXTRA_LINK_LIBRARIES}) IF (PLAYER_OS_SOLARIS) TARGET_LINK_LIBRARIES (${_name} rt) ENDIF (PLAYER_OS_SOLARIS) @@ -34,18 +40,18 @@ INSTALL (FILES ${exampleSrcs} DESTINATION share/${PROJECT_NAME_LOWER}/examples/libplayerc++) IF (BUILD_PLAYERCC_BOOST) - IF (USE_BOOST_THREAD OR USE_BOOST_SIGNALS) - PLAYERCPP_ADD_EXAMPLE (example1 example1.cc) - PLAYERCPP_ADD_EXAMPLE (example3 example3.cc) - PLAYERCPP_ADD_EXAMPLE (goto goto.cc) - PLAYERCPP_ADD_EXAMPLE (speech_cpp_client speech_cpp_client.cc) - INSTALL (FILES ${exampleBoostSrcs} DESTINATION share/${PROJECT_NAME_LOWER}/examples/libplayerc++) - ENDIF (USE_BOOST_THREAD OR USE_BOOST_SIGNALS) + IF (HAVE_BOOST_THREAD AND USE_BOOST_THREAD AND HAVE_BOOST_SIGNALS AND USE_BOOST_SIGNALS) + PLAYERCPP_ADD_EXAMPLE (example1 example1.cc) + PLAYERCPP_ADD_EXAMPLE (example3 example3.cc) + PLAYERCPP_ADD_EXAMPLE (goto goto.cc) + PLAYERCPP_ADD_EXAMPLE (speech_cpp_client speech_cpp_client.cc) + INSTALL (FILES ${exampleBoostSrcs} DESTINATION share/${PROJECT_NAME_LOWER}/examples/libplayerc++) + ENDIF (HAVE_BOOST_THREAD AND USE_BOOST_THREAD AND HAVE_BOOST_SIGNALS AND USE_BOOST_SIGNALS) - IF (USE_BOOST_SIGNALS) - PLAYERCPP_ADD_EXAMPLE (example2 example2.cc) - INSTALL (FILES ${exampleBoostSigSrcs} DESTINATION share/${PROJECT_NAME_LOWER}/examples/libplayerc++) - ENDIF (USE_BOOST_SIGNALS) + IF (HAVE_BOOST_SIGNALS AND USE_BOOST_SIGNALS) + PLAYERCPP_ADD_EXAMPLE (example2 example2.cc) + INSTALL (FILES ${exampleBoostSigSrcs} DESTINATION share/${PROJECT_NAME_LOWER}/examples/libplayerc++) + ENDIF (HAVE_BOOST_SIGNALS AND USE_BOOST_SIGNALS) ENDIF (BUILD_PLAYERCC_BOOST) # Install the example CMakeLists.txt Modified: code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in =================================================================== --- code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/CMakeLists.txt.example.in 2009-07-12 10:53:35 UTC (rev 8000) @@ -5,33 +5,38 @@ SET (CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules) INCLUDE (UsePlayerC++) +SET (HAVE_GETOPT @HAVE_GETOPT@) +IF (NOT HAVE_GETOPT) + SET (replaceLib "-lplayerreplace") +ENDIF (NOT HAVE_GETOPT) + IF (PLAYER_OS_SOLARIS) SET (rtLibFlag -lrt) ENDIF (PLAYER_OS_SOLARIS) -PLAYER_ADD_PLAYERCPP_CLIENT (camera SOURCES camera.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (example0 SOURCES example0.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (example4 SOURCES example4.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (grip SOURCES grip.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (clientgraphics SOURCES clientgraphics.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (clientgraphics3d SOURCES clientgraphics3d.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (laserobstacleavoid SOURCES laserobstacleavoid.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (ptz SOURCES ptz.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (randomwalk SOURCES randomwalk.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (sonarobstacleavoid SOURCES sonarobstacleavoid.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (speech SOURCES speech.cc) -PLAYER_ADD_PLAYERCPP_CLIENT (wallfollow SOURCES wallfollow.cc) +PLAYER_ADD_PLAYERCPP_CLIENT (camera SOURCES camera.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (example0 SOURCES example0.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (example4 SOURCES example4.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (grip SOURCES grip.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (clientgraphics SOURCES clientgraphics.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (clientgraphics3d SOURCES clientgraphics3d.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (laserobstacleavoid SOURCES laserobstacleavoid.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (ptz SOURCES ptz.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (randomwalk SOURCES randomwalk.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (sonarobstacleavoid SOURCES sonarobstacleavoid.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (speech SOURCES speech.cc LINKFLAGS ${replaceLib}) +PLAYER_ADD_PLAYERCPP_CLIENT (wallfollow SOURCES wallfollow.cc LINKFLAGS ${replaceLib}) -SET (HAVE_BOOST_THREADS @USE_BOOST_THREADS@) -SET (HAVE_BOOST_SIGNALS @USE_BOOST_SIGNALS@) +SET (HAVE_BOOST_THREADS @HAVE_BOOST_THREADS@) +SET (HAVE_BOOST_SIGNALS @HAVE_BOOST_SIGNALS@) IF (HAVE_BOOST_THREADS OR HAVE_BOOST_SIGNALS) - PLAYER_ADD_PLAYERCPP_CLIENT (example1 SOURCES example1.cc LINKFLAGS ${rtLibFlag}) - PLAYER_ADD_PLAYERCPP_CLIENT (example3 SOURCES example3.cc) - PLAYER_ADD_PLAYERCPP_CLIENT (goto SOURCES goto.cc LINKFLAGS ${rtLibFlag}) - PLAYER_ADD_PLAYERCPP_CLIENT (speech_cpp_client SOURCES speech_cpp_client.cc LINKFLAGS ${rtLibFlag}) + PLAYER_ADD_PLAYERCPP_CLIENT (example1 SOURCES example1.cc LINKFLAGS ${rtLibFlag} LINKFLAGS ${replaceLib}) + PLAYER_ADD_PLAYERCPP_CLIENT (example3 SOURCES example3.cc LINKFLAGS ${replaceLib}) + PLAYER_ADD_PLAYERCPP_CLIENT (goto SOURCES goto.cc LINKFLAGS ${rtLibFlag} LINKFLAGS ${replaceLib}) + PLAYER_ADD_PLAYERCPP_CLIENT (speech_cpp_client SOURCES speech_cpp_client.cc LINKFLAGS ${rtLibFlag} LINKFLAGS ${replaceLib}) ENDIF (HAVE_BOOST_THREADS OR HAVE_BOOST_SIGNALS) IF (HAVE_BOOST_SIGNALS) - PLAYER_ADD_PLAYERCPP_CLIENT (example2 SOURCES example2.cc) + PLAYER_ADD_PLAYERCPP_CLIENT (example2 SOURCES example2.cc LINKFLAGS ${replaceLib}) ENDIF (HAVE_BOOST_SIGNALS) Modified: code/player/trunk/examples/libplayerc++/args.h =================================================================== --- code/player/trunk/examples/libplayerc++/args.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/args.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -2,7 +2,12 @@ #include <cstring> #include <libplayerc++/playerc++.h> #include <iostream> -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif +#if !HAVE_GETOPT + #include <replace.h> +#endif std::string gHostname(PlayerCc::PLAYER_HOSTNAME); uint32_t gPort(PlayerCc::PLAYER_PORTNUM); Modified: code/player/trunk/examples/libplayerc++/clientgraphics.cc =================================================================== --- code/player/trunk/examples/libplayerc++/clientgraphics.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/clientgraphics.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -48,7 +48,7 @@ } - sleep(1); + usleep(1000000); player_color_t col; memset( &col, 0, sizeof(col)); @@ -73,7 +73,7 @@ usleep(300000); } - sleep(1); + usleep(1000000); gp.Clear(); Modified: code/player/trunk/examples/libplayerc++/clientgraphics3d.cc =================================================================== --- code/player/trunk/examples/libplayerc++/clientgraphics3d.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/clientgraphics3d.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -49,7 +49,7 @@ } - sleep(1); + usleep(1000000); player_color_t col; memset( &col, 0, sizeof(col)); @@ -79,7 +79,7 @@ usleep(300000); } - sleep(1); + usleep(1000000); gp.Clear(); Modified: code/player/trunk/examples/libplayerc++/goto.cc =================================================================== --- code/player/trunk/examples/libplayerc++/goto.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/goto.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -10,7 +10,9 @@ #include <iostream> #include <stdlib.h> // for atof() -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <math.h> #include <string> Modified: code/player/trunk/examples/libplayerc++/grip.cc =================================================================== --- code/player/trunk/examples/libplayerc++/grip.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/grip.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -5,7 +5,9 @@ */ #include <libplayerc++/playerc++.h> -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <stdlib.h> #include <iostream> Modified: code/player/trunk/examples/libplayerc++/speech.cc =================================================================== --- code/player/trunk/examples/libplayerc++/speech.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/speech.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,7 +1,9 @@ #include <libplayerc++/playerc++.h> #include "args.h" #include <iostream> -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif int main(int argc, char** argv) { parse_args(argc, argv); Modified: code/player/trunk/examples/libplayerc++/speech_cpp_client.cc =================================================================== --- code/player/trunk/examples/libplayerc++/speech_cpp_client.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/libplayerc++/speech_cpp_client.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,6 +1,8 @@ #include <libplayerc++/playerc++.h> #include <iostream> -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <boost/signal.hpp> #include <boost/bind.hpp> Modified: code/player/trunk/examples/plugins/CMakeLists.txt =================================================================== --- code/player/trunk/examples/plugins/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,4 +1,4 @@ ADD_SUBDIRECTORY (exampledriver) ADD_SUBDIRECTORY (multidriver) ADD_SUBDIRECTORY (opaquedriver) -ADD_SUBDIRECTORY (exampleinterface) \ No newline at end of file +ADD_SUBDIRECTORY (exampleinterface) Modified: code/player/trunk/examples/plugins/exampledriver/exampledriver.cc =================================================================== --- code/player/trunk/examples/plugins/exampledriver/exampledriver.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/exampledriver/exampledriver.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -31,7 +31,9 @@ #include <config.h> */ -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <string.h> #include <libplayercore/playercore.h> Modified: code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -27,6 +27,8 @@ INCLUDE_DIRECTORIES (${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/client_libs ${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY (example SHARED ${example_interface_h} ${example_xdr_h} ${example_xdr_c} eginterf_client.c ${example_functiontable_c}) TARGET_LINK_LIBRARIES (example playerc) +GET_SOURCE_FILE_PROPERTY (currentCFlags ${example_xdr_c} COMPILE_FLAGS) +SET_SOURCE_FILES_PROPERTIES (${example_xdr_c} PROPERTIES COMPILE_FLAGS "-Dplayerxdr_EXPORTS ${currentCFlags}") ADD_LIBRARY (example_driver SHARED ${example_interface_h} ${example_xdr_h} eginterf_driver.cc) TARGET_LINK_LIBRARIES (example_driver playercore) ADD_EXECUTABLE (example_client example_client.c ${example_interface_h}) Modified: code/player/trunk/examples/plugins/exampleinterface/eginterf_client.h =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/eginterf_client.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/exampleinterface/eginterf_client.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -7,6 +7,24 @@ extern "C" { #endif +// If you want your plugin interface to be usable on Windows, this block is +// important. Make sure to replace EXAMPLE with the exact name of your +// interface as specified in the interfName argument of +// PLAYER_ADD_PLUGIN_INTERFACE() in your CMakeLists.txt file, but in captital +// letters, all throughout this file. Also ensure that the "example" in +// "example_EXPORTS" is replaced with the exact name of your interface. +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define EXAMPLE_EXPORT + #elif defined (example_EXPORTS) + #define EXAMPLE_EXPORT __declspec (dllexport) + #else + #define EXAMPLE_EXPORT __declspec (dllimport) + #endif +#else + #define EXAMPLE_EXPORT +#endif + typedef struct { /* Device info; must be at the start of all device structures. */ @@ -18,17 +36,17 @@ int value; } eginterf_t; -eginterf_t *eginterf_create (playerc_client_t *client, int index); +EXAMPLE_EXPORT eginterf_t *eginterf_create (playerc_client_t *client, int index); -void eginterf_destroy (eginterf_t *device); +EXAMPLE_EXPORT void eginterf_destroy (eginterf_t *device); -int eginterf_subscribe (eginterf_t *device, int access); +EXAMPLE_EXPORT int eginterf_subscribe (eginterf_t *device, int access); -int eginterf_unsubscribe (eginterf_t *device); +EXAMPLE_EXPORT int eginterf_unsubscribe (eginterf_t *device); -int eginterf_cmd (eginterf_t *device, char value); +EXAMPLE_EXPORT int eginterf_cmd (eginterf_t *device, char value); -int eginterf_req (eginterf_t *device, int blah); +EXAMPLE_EXPORT int eginterf_req (eginterf_t *device, int blah); #ifdef __cplusplus } Modified: code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -3,7 +3,9 @@ * driver example for details of how it works. */ -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <string.h> #include <stdlib.h> #include <time.h> @@ -62,7 +64,7 @@ { puts("EgInterfDriver initialising"); - srandom (time (NULL)); + srand (static_cast<unsigned int> (time (NULL))); puts("EgInterfDriver ready"); @@ -96,7 +98,7 @@ printf ("EgInterfDriver: Sending data:\n"); for (int ii = 0; ii < reinterpret_cast<player_eginterf_cmd*> (data)->doStuff; ii++) { - double temp = (((double) random ()) / RAND_MAX) * 10.0f; + double temp = (((double) rand ()) / RAND_MAX) * 10.0f; resp.stuff[ii] = temp; printf ("\t%f\n", resp.stuff[ii]); } Modified: code/player/trunk/examples/plugins/multidriver/multidriver.cc =================================================================== --- code/player/trunk/examples/plugins/multidriver/multidriver.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/multidriver/multidriver.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -35,9 +35,11 @@ #include <config.h> */ -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> + #include <netinet/in.h> +#endif #include <string.h> -#include <netinet/in.h> #include <libplayercore/playercore.h> Modified: code/player/trunk/examples/plugins/opaquedriver/opaquedriver.cc =================================================================== --- code/player/trunk/examples/plugins/opaquedriver/opaquedriver.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/examples/plugins/opaquedriver/opaquedriver.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -31,7 +31,9 @@ #include <config.h> */ -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <string.h> #include <math.h> Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -71,10 +71,10 @@ PLAYERCORE_ADD_INT_LINK_LIB (rt) SET (playercoreLinkLibs ${playercoreLinkLibs} "rt") ELSE (HAVE_CLOCK_GETTIME) - SET (playercoreSrcs ${playercoreSrcs} ${PROJECT_SOURCE_DIR}/replace/clock_gettime.c) + SET (playerreplaceLib playerreplace) ENDIF (HAVE_CLOCK_GETTIME) IF (NOT HAVE_GETTIMEOFDAY) - SET (playercoreSrcs ${playercoreSrcs} ${PROJECT_SOURCE_DIR}/replace/gettimeofday.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_GETTIMEOFDAY) IF (HAVE_LIBLTDL) IF (PLAYER_OS_QNX) @@ -86,13 +86,15 @@ ENDIF (PLAYER_OS_QNX) ENDIF (HAVE_LIBLTDL) IF (NOT HAVE_DIRNAME) - SET (playercoreSrcs ${playercoreSrcs} ${PROJECT_SOURCE_DIR}/replace/dirname.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_DIRNAME) INCLUDE_DIRECTORIES (${PLAYERCORE_INT_INCLUDE_DIRS} ${PLAYERCORE_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYERCORE_INT_LINK_DIRS} ${PLAYERCORE_EXTRA_LINK_DIRS}) PLAYER_ADD_LIBRARY (playercore ${playercoreSrcs} ${player_interfaces_h} ${playerxdr_h}) -TARGET_LINK_LIBRARIES (playercore ${PLAYERCORE_INT_LINK_LIBRARIES} ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) +TARGET_LINK_LIBRARIES (playercore ${playerreplaceLib} + ${PLAYERCORE_INT_LINK_LIBRARIES} + ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) SET (pkgconfigCFlags) SET (pkgconfigLinkDirs) SET (pkgconfigLinkLibs) Modified: code/player/trunk/libplayercore/playercore.h =================================================================== --- code/player/trunk/libplayercore/playercore.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/playercore.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -53,7 +53,6 @@ #include <libplayercore/player.h> #include <libplayercore/playercommon.h> #include <libplayercore/playertime.h> -#include <libplayercore/plugins.h> #include <libplayercore/wallclocktime.h> #include <libplayercore/addr_util.h> #include <libplayercore/property.h> Modified: code/player/trunk/libplayercore/playerinterfacegen.py =================================================================== --- code/player/trunk/libplayercore/playerinterfacegen.py 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/playerinterfacegen.py 2009-07-12 10:53:35 UTC (rev 8000) @@ -141,7 +141,19 @@ {0,0,0,NULL,NULL,NULL} }; -playerxdr_function_t* player_plugininterf_gettable (void) +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLUGINTF_EXPORT + #elif defined (%(interface_name)s_EXPORTS) + #define PLUGINTF_EXPORT __declspec (dllexport) + #else + #define PLUGINTF_EXPORT __declspec (dllimport) + #endif +#else + #define PLUGINTF_EXPORT +#endif + +PLUGINTF_EXPORT playerxdr_function_t* player_plugininterf_gettable (void) { return %(interface_name)s_ftable; } Modified: code/player/trunk/libplayercore/plugins.cc =================================================================== --- code/player/trunk/libplayercore/plugins.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/plugins.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -40,7 +40,11 @@ #include <string.h> #include <stdlib.h> -#if !defined WIN32 +#if defined WIN32 + #include <direct.h> + #include <vector> + #include <string> +#else #include <unistd.h> #endif @@ -58,7 +62,7 @@ #include "plugins.h" // Try to load a given plugin, using a particular search algorithm. -// Returns true on success and false on failure. +// Returns a handle on success and NULL on failure. lt_dlhandle LoadPlugin(const char* pluginname, const char* cfgfile) { @@ -139,11 +143,88 @@ } return handle; +#elif defined (WIN32) + std::vector<std::string> paths; + if(pluginname[0] == '/' || pluginname[0] == '~') + { + lt_dlhandle handle = LoadLibrary( pluginname ); + if (handle == NULL) + { + LPVOID buffer = NULL; + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL ); + PLAYER_ERROR2( "Failed to load plugin with absolute path %s: %s\n", pluginname, reinterpret_cast<LPTSTR> (buffer) ); + LocalFree( buffer ); + return NULL; + } + return handle; + } + else + { + // Add the various search paths to the list + + // start with $PLAYERPATH, if set + char playerpath[PATH_MAX]; + size_t size = PATH_MAX; + errno_t err; + if( (err = _dupenv_s(reinterpret_cast<char**> (&playerpath), &size, "PLAYERPATH")) != 0) + PLAYER_WARN1 ("Error getting PLAYERPATH environment variable: %d", errno); + else if( playerpath != NULL ) + paths.push_back( playerpath ); + + // add the working directory + char workingdir[PATH_MAX]; + if( _getcwd( workingdir, PATH_MAX )) + paths.push_back( workingdir ); + +/* if(cfgfile) + { + //TODO + // Note that dirname() modifies the contents on some + // platforms, so we need to make a copy of the filename. + char* tmp = strdup(cfgfile); + assert(tmp); + char* cfgdir = dirname(tmp); + if( SetDllDirectory( cfgdir ) ) + PLAYER_ERROR1( "failed to add config file directory %s to the plugin path", cfgdir ); + free(tmp); + }*/ + + // add $PLAYER_INSTALL_PREFIX/lib + char installdir[ PATH_MAX ]; + strncpy_s( installdir, PATH_MAX, PLAYER_INSTALL_PREFIX, PATH_MAX); + strncat_s( installdir, PATH_MAX, "/lib/", PATH_MAX); + paths.push_back( installdir ); + + for (std::vector<std::string>::const_iterator ii = paths.begin (); ii != paths.end (); ii++) + { + if( SetDllDirectory( ii->c_str() ) == 0) + { + LPVOID buffer = NULL; + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL ); + PLAYER_ERROR2( "Failed to add search path %s: %s\n", ii->c_str(), reinterpret_cast<LPTSTR> (buffer) ); + LocalFree( buffer ); + continue; + } + lt_dlhandle handle = LoadLibrary( pluginname ); + if (handle == NULL) + { + LPVOID buffer = NULL; + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL ); + PLAYER_ERROR2( "Failed to load plugin with using path %s: %s\n", ii->c_str(), reinterpret_cast<LPTSTR> (buffer) ); + LocalFree( buffer ); + continue; + } + return handle; + } + return NULL; + } #else PLAYER_ERROR("Sorry, no support for shared libraries, so can't load plugins."); PLAYER_ERROR("You should install libltdl, which is part of GNU libtool, then re-compile player."); - PLAYER_ERROR("If you're on Windows, wait a little while as plugin loading is still under development."); return 0; #endif } @@ -178,10 +259,40 @@ } else return(false); +#elif defined (WIN32) + DriverPluginInitFn initfunc; + // Invoke the initialization function + if(handle != NULL) + { + PLAYER_MSG0(1, "invoking player_driver_init()..."); + + initfunc = reinterpret_cast<DriverPluginInitFn>(GetProcAddress(handle,"player_driver_init")); + if( !initfunc ) + { + LPVOID buffer = NULL; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); + PLAYER_ERROR1("failed to resolve player_driver_init: %s\n", reinterpret_cast<LPTSTR> (buffer)); + LocalFree(buffer); + return(false); + } + + int initfunc_result = 0; + if( (initfunc_result = (*initfunc)(driverTable)) != 0) + { + PLAYER_ERROR1("error returned by player_driver_init: %d", initfunc_result); + return(false); + } + + PLAYER_MSG0(1, "success"); + + return(true); + } + else + return(false); #else PLAYER_ERROR("Sorry, no support for shared libraries, so can't load plugins."); PLAYER_ERROR("You should install libltdl, which is part of GNU libtool, then re-compile player."); - PLAYER_ERROR("If you're on Windows, wait a little while as plugin loading is still under development."); return(false); #endif } @@ -217,10 +328,41 @@ } else return(NULL); +#elif defined (WIN32) + InterfPluginInitFn initfunc; + playerxdr_function_t *flist; + + // Invoke the initialization function + if(handle != NULL) + { + PLAYER_MSG0(1, "invoking player_plugininterf_gettable()..."); + + initfunc = reinterpret_cast<InterfPluginInitFn>(GetProcAddress(handle,"player_plugininterf_gettable")); + if( !initfunc ) + { + LPVOID buffer = NULL; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast<LPTSTR> (&buffer), 0, NULL); + PLAYER_ERROR1("failed to resolve player_plugininterf_gettable: %s\n", reinterpret_cast<LPTSTR> (buffer)); + LocalFree(buffer); + return(false); + } + + if( (flist = (*initfunc)()) == NULL) + { + PLAYER_ERROR("player_plugininterf_gettable returned NULL"); + return(NULL); + } + + PLAYER_MSG0(1, "success"); + + return(flist); + } + else + return(NULL); #else PLAYER_ERROR("Sorry, no support for shared libraries, so can't load plugins."); PLAYER_ERROR("You should install libltdl, which is part of GNU libtool, then re-compile player."); - PLAYER_ERROR("If you're on Windows, wait a little while as plugin loading is still under development."); return(NULL); #endif } Modified: code/player/trunk/libplayercore/plugins.h =================================================================== --- code/player/trunk/libplayercore/plugins.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/plugins.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -52,6 +52,9 @@ #if HAVE_LIBLTDL #include <ltdl.h> +#elif defined (WIN32) + #include <Windows.h> + #define lt_dlhandle HMODULE #else #define lt_dlhandle int #endif Modified: code/player/trunk/libplayercore/remote_driver.h =================================================================== --- code/player/trunk/libplayercore/remote_driver.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayercore/remote_driver.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -40,6 +40,18 @@ #ifndef REMOTE_DRIVER_H #define REMOTE_DRIVER_H +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERCORE_EXPORT + #elif defined (playercore_EXPORTS) + #define PLAYERCORE_EXPORT __declspec (dllexport) + #else + #define PLAYERCORE_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERCORE_EXPORT +#endif + #include <libplayercore/playercore.h> #include <map> #include <list> @@ -66,7 +78,7 @@ typedef list<QueuePointer> QueueList; -class RemoteConnection +class PLAYERCORE_EXPORT RemoteConnection { public: RemoteConnection() : subscription_count(0) {}; @@ -84,7 +96,7 @@ QueuePointer ConnectionQueue; }; -class RemoteDriver: public Driver { +class PLAYERCORE_EXPORT RemoteDriver: public Driver { public: RemoteDriver(ConfigFile *cf=NULL,int section=-1) : Driver(cf,section,false), Connected(true){}; virtual ~RemoteDriver() {}; Modified: code/player/trunk/libplayertcp/CMakeLists.txt =================================================================== --- code/player/trunk/libplayertcp/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayertcp/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -29,16 +29,17 @@ SET (playertcpSrcs socket_util.c playertcp.cc tcpremote_driver.cc) IF (NOT HAVE_POLL) - SET (playertcpSrcs ${playertcpSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_POLL) IF (NOT HAVE_COMPRESSBOUND) - SET (playertcpSrcs ${playertcpSrcs} ${PROJECT_SOURCE_DIR}/replace/compressBound.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_COMPRESSBOUND) IF (NOT HAVE_NANOSLEEP) - SET (playertcpSrcs ${playertcpSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_NANOSLEEP) PLAYER_ADD_LIBRARY (playertcp ${playertcpSrcs}) - TARGET_LINK_LIBRARIES (playertcp playercore playererror playerutils playerxdr ${SOCKET_LIBS}) + TARGET_LINK_LIBRARIES (playertcp playercore playererror playerutils + playerxdr ${playerreplaceLib} ${SOCKET_LIBS}) IF (PLAYER_OS_WIN) TARGET_LINK_LIBRARIES (playertcp Ws2_32) ENDIF (PLAYER_OS_WIN) @@ -56,7 +57,8 @@ SET (rtLibFlag -lrt) ENDIF (PLAYER_OS_SOLARIS) PLAYER_MAKE_PKGCONFIG ("playertcp" "Player TCP messaging library - part of the Player Project" - "playererror playercore" "" "" "${zLibFlag} ${rtLibFlag} ${SOCKET_LIBS_FLAGS}") + "playererror playercore ${playerreplaceLib}" "" "" + "${zLibFlag} ${rtLibFlag} ${SOCKET_LIBS_FLAGS}") PLAYER_INSTALL_HEADERS (playertcp playertcp.h playertcp_errutils.h) ENDIF (INCLUDE_TCP) @@ -64,13 +66,14 @@ IF (INCLUDE_UDP) SET (playerudpSrcs playerudp.cc) IF (NOT HAVE_POLL) - SET(playerudpSrcs ${playerudpSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_POLL) IF (NOT HAVE_COMPRESSBOUND) - SET (playerudpSrcs ${playerudpSrcs} ${PROJECT_SOURCE_DIR}/replace/compressBound.c) + SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_COMPRESSBOUND) PLAYER_ADD_LIBRARY (playerudp ${playerudpSrcs}) - TARGET_LINK_LIBRARIES (playerudp playercore playererror playerutils playerxdr ${SOCKET_LIBS}) + TARGET_LINK_LIBRARIES (playerudp playercore playererror playerutils + playerxdr ${playerreplaceLib} ${SOCKET_LIBS}) IF (PLAYER_OS_WIN) TARGET_LINK_LIBRARIES (playerudp Ws2_32) ENDIF (PLAYER_OS_WIN) @@ -85,7 +88,8 @@ SET (zLibFlag) ENDIF (HAVE_Z) PLAYER_MAKE_PKGCONFIG ("playerudp" "Player UDP messaging library - part of the Player Project" - "playererror playercore" "" "" "${zLibFlag} ${SOCKET_LIBS_FLAGS}") + "playererror playercore ${playerreplaceLib}" "" "" + "${zLibFlag} ${SOCKET_LIBS_FLAGS}") PLAYER_INSTALL_HEADERS (playertcp playerudp.h playertcp_errutils.h) ENDIF (INCLUDE_UDP) Modified: code/player/trunk/libplayertcp/tcpremote_driver.cc =================================================================== --- code/player/trunk/libplayertcp/tcpremote_driver.cc 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayertcp/tcpremote_driver.cc 2009-07-12 10:53:35 UTC (rev 8000) @@ -42,8 +42,10 @@ #include <errno.h> #include <sys/types.h> -#include <unistd.h> #include <fcntl.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #if ENABLE_TCP_NODELAY #include <netinet/tcp.h> @@ -53,6 +55,7 @@ #include <libplayercore/error.h> #include <libplayerxdr/playerxdr.h> #include "tcpremote_driver.h" +#include "playertcp_errutils.h" QueuePointer TCPRemoteDriverConnection::Connect() { @@ -60,6 +63,11 @@ char banner[PLAYER_IDENT_STRLEN]; int numread, thisnumread; double t1, t2; +#if defined (WIN32) + unsigned long setting = 1; +#else + int flags; /* temp for old socket access flags */ +#endif // if kill_flag is set then we cant use the ptcp object if (kill_flag) @@ -76,12 +84,15 @@ } // Construct socket - this->sock = socket(PF_INET,SOCK_STREAM, 0); - if (this->sock < 0) - { - PLAYER_ERROR1("socket call failed with error [%s]", strerror(errno)); - throw "Connection Failed"; - } +#if defined (WIN32) + if((this->sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) +#else + if((this->sock = socket(PF_INET, SOCK_STREAM, 0)) == -1) +#endif + { + STRERROR (PLAYER_ERROR1, "socket() failed; socket not created: %s"); + throw "Connection failed"; + } server.sin_family = PF_INET; server.sin_addr.s_addr = host; @@ -92,7 +103,11 @@ { PLAYER_ERROR3("connect call on [%s:%u] failed with error [%s]", this->ipaddr, port, strerror(errno)); - close(this->sock); +#if defined (WIN32) + closesocket(this->sock); +#else + close(this->sock); +#endif sock=-1; throw "Connection Failed"; } @@ -100,13 +115,39 @@ PLAYER_MSG2(2, "connected to: %s:%u\n", this->ipaddr, host); // make the socket non-blocking - if (fcntl(this->sock, F_SETFL, O_NONBLOCK) == -1) - { - PLAYER_ERROR1("fcntl() failed: %s", strerror(errno)); - close(this->sock); - sock=-1; - throw "Connection Failed"; - } +#if defined (WIN32) + if (ioctlsocket(sock, FIONBIO, &setting) == SOCKET_ERROR) + { + STRERROR(PLAYER_ERROR1, "ioctlsocket error: %s"); + closesocket(sock); + sock=INVALID_SOCKET; + throw "Connection failed"; + } +#else + /* + * get the current access flags + */ + if((flags = fcntl(sock, F_GETFL)) == -1) + { + perror("create_and_bind_socket():fcntl() while getting socket " + "access flags; socket not created."); + close(sock); + sock=-1; + throw "Connection failed"; + } + /* + * OR the current flags with O_NONBLOCK (so we won't block), + * and write them back + */ + if(fcntl(sock, F_SETFL, flags | O_NONBLOCK ) == -1) + { + perror("create_and_bind_socket():fcntl() failed while setting socket " + "access flags; socket not created."); + close(sock); + sock=-1; + throw "Connection failed"; + } +#endif // defined (WIN32) #if ENABLE_TCP_NODELAY // Disable Nagel's algorithm for lower latency @@ -126,13 +167,17 @@ numread = 0; while (numread < (int) sizeof(banner)) { - if ((thisnumread = read(this->sock, banner + numread, sizeof(banner) - - numread)) < 0) + if ((thisnumread = recv(this->sock, banner + numread, sizeof(banner) + - numread, 0)) < 0) { if (errno!= EAGAIN) { PLAYER_ERROR("error reading banner from remote device"); - close(this->sock); +#if defined (WIN32) + closesocket(this->sock); +#else + close(this->sock); +#endif sock=-1; throw "Connection Failed"; } @@ -143,7 +188,11 @@ if ((t2 - t1) > this->setup_timeout) { PLAYER_ERROR("timed out reading banner from remote server"); - close(this->sock); +#if defined (WIN32) + closesocket(this->sock); +#else + close(this->sock); +#endif sock=-1; throw "Connection Failed"; } @@ -184,7 +233,7 @@ // we need to do this after the subscription as we directly // manipulate the socket in our subscribe and unsubscribe this->ptcp->AddClient(NULL, host, port, this->sock, - false, &this->kill_flag, (this->ptcp->thread == pthread_self()),ConnectionQueue); + false, &this->kill_flag, pthread_equal(this->ptcp->thread, pthread_self()),ConnectionQueue); } @@ -196,8 +245,8 @@ { // Set the delete flag, letting PlayerTCP close the connection and // clean up. - this->ptcp->DeleteClient(ConnectionQueue, (this->ptcp->thread - == pthread_self())); + this->ptcp->DeleteClient(ConnectionQueue, pthread_equal(this->ptcp->thread, + pthread_self())); kill_flag = 1; } @@ -219,7 +268,11 @@ int numbytes, thisnumbytes; // if we have no socket then we dont need to unsub +#if defined (WIN32) + if (sock == INVALID_SOCKET) +#else if (sock < 0) +#endif return 0; memset(&hdr, 0, sizeof(hdr)); @@ -261,8 +314,8 @@ while (numbytes < encode_msglen) { - if ((thisnumbytes = write(this->sock, buf + numbytes, encode_msglen - - numbytes)) < 0) + if ((thisnumbytes = send(this->sock, reinterpret_cast<const char*> (buf + numbytes), encode_msglen + - numbytes, 0)) < 0) { if (errno!= EAGAIN) { @@ -299,8 +352,8 @@ numbytes = 0; while (numbytes < PLAYERXDR_MSGHDR_SIZE) { - if ((thisnumbytes = read(this->sock, buf + numbytes, - PLAYERXDR_MSGHDR_SIZE - numbytes)) < 0) + if ((thisnumbytes = recv(this->sock, reinterpret_cast<char*> (buf + numbytes), + PLAYERXDR_MSGHDR_SIZE - numbytes, 0)) < 0) { if (errno!= EAGAIN) { @@ -340,8 +393,8 @@ numbytes = 0; while (numbytes < (int) hdr.size) { - if ((thisnumbytes = read(this->sock, buf + PLAYERXDR_MSGHDR_SIZE - + numbytes, hdr.size - numbytes)) < 0) + if ((thisnumbytes = recv(this->sock, reinterpret_cast<char*> (buf + PLAYERXDR_MSGHDR_SIZE + + numbytes), hdr.size - numbytes, 0)) < 0) { if (errno!= EAGAIN) { Modified: code/player/trunk/libplayertcp/tcpremote_driver.h =================================================================== --- code/player/trunk/libplayertcp/tcpremote_driver.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayertcp/tcpremote_driver.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -44,20 +44,46 @@ #include <libplayercore/remote_driver.h> #include "playertcp.h" +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERTCP_EXPORT + #elif defined (playertcp_EXPORTS) + #define PLAYERTCP_EXPORT __declspec (dllexport) + #else + #define PLAYERTCP_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERTCP_EXPORT +#endif + #define DEFAULT_SETUP_TIMEOUT 3.0 -class TCPRemoteDriverConnection: public RemoteConnection +class PLAYERTCP_EXPORT TCPRemoteDriverConnection: public RemoteConnection { public: TCPRemoteDriverConnection(PlayerTCP* ptcp, unsigned remote_host, unsigned short remote_port) : ptcp(ptcp), host(remote_host), port(remote_port), sock(-1), setup_timeout(DEFAULT_SETUP_TIMEOUT), kill_flag(0) { +#if defined (WIN32) + // Initialise Windows sockets API (this can safely be done as many times as we like) + WSADATA info; + int result; + if ((result = WSAStartup (MAKEWORD (2, 2), &info)) != 0) + { + PLAYER_ERROR1 ("Failed to initialise Windows sockets API with error %d", result); + } +#endif } ; virtual ~TCPRemoteDriverConnection() { +#if defined (WIN32) + // Clean up the Windows sockets API (this can safely be done as many times as we like) + if (WSACleanup () != 0) + PLAYER_ERROR1 ("Failed to clean up Windows sockets API with error %s", WSAGetLastError ()); +#endif } ; @@ -76,12 +102,16 @@ unsigned host; unsigned short port; char ipaddr[256]; - int sock; +#if defined (WIN32) + SOCKET sock; +#else + int sock; +#endif double setup_timeout; int kill_flag; }; -class TCPRemoteDriver: public RemoteDriver +class PLAYERTCP_EXPORT TCPRemoteDriver: public RemoteDriver { private: PlayerTCP* ptcp; Modified: code/player/trunk/libplayerwkb/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerwkb/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayerwkb/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,7 +1,7 @@ # Possibly use our own copy of XDR -IF (NOT HAVE_XDR) - INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) -ENDIF (NOT HAVE_XDR) +#IF (NOT HAVE_XDR) +#INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) +#ENDIF (NOT HAVE_XDR) SET (playerwkbSrcs playerwkb.c) PLAYER_ADD_LIBRARY (playerwkb ${playerwkbSrcs}) Modified: code/player/trunk/libplayerxdr/CMakeLists.txt =================================================================== --- code/player/trunk/libplayerxdr/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayerxdr/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -34,20 +34,13 @@ COMMENT "Generating functiontable_gen.h") IF (NOT HAVE_XDR) - SET (replaceSrcs ${PROJECT_SOURCE_DIR}/replace/xdr.c - ${PROJECT_SOURCE_DIR}/replace/xdr_array.c - ${PROJECT_SOURCE_DIR}/replace/xdr_float.c - ${PROJECT_SOURCE_DIR}/replace/xdr_intXX_t.c - ${PROJECT_SOURCE_DIR}/replace/xdr_mem.c - ${PROJECT_SOURCE_DIR}/replace/xdr_sizeof.c) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) ENDIF (NOT HAVE_XDR) SET (playerxdrSrcs ${playerxdr_h} ${playerxdr_c} functiontable.c - ${functiontable_gen_h} - ${replaceSrcs}) + ${functiontable_gen_h}) IF (PLAYER_OS_QNX) SET (xdrLibFlag -lrpc) @@ -65,6 +58,9 @@ TARGET_LINK_LIBRARIES (playerxdr rpc) PLAYERCORE_ADD_INT_LINK_LIB (rpc) ENDIF (PLAYER_OS_QNX) +IF (NOT HAVE_XDR) + TARGET_LINK_LIBRARIES (playerxdr playerreplace) +ENDIF (NOT HAVE_XDR) PLAYER_MAKE_PKGCONFIG ("playerxdr" "Player XDR messaging library - part of the Player Project" "" "" "" "${xdrLibFlag}") PLAYER_INSTALL_HEADERS (playerxdr ${playerxdr_h} functiontable.h) Modified: code/player/trunk/libplayerxdr/playerxdrgen.py =================================================================== --- code/player/trunk/libplayerxdr/playerxdrgen.py 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/libplayerxdr/playerxdrgen.py 2009-07-12 10:53:35 UTC (rev 8000) @@ -9,6 +9,7 @@ import string import sys import os +import os.path USAGE = 'USAGE: playerxdrgen.y [-distro] <interface-spec.h> [<extra_interface-spec.h>] <pack.c> <pack.h>' @@ -536,7 +537,7 @@ #include <stdlib.h> """ % {"headerfilename":headerfilename}) else: - ifndefsymbol = '_' + infilenames[0].replace('.','_').replace('/','_').upper() + '_XDR_' + ifndefsymbol = '_' + os.path.split (infilenames[0])[1].replace('.','_').replace('/','_').upper() + '_XDR_' headerfile.write('#ifndef ' + ifndefsymbol + '\n') headerfile.write('#define ' + ifndefsymbol + '\n\n') headerfile.write('#include <libplayerxdr/playerxdr.h>\n\n') Modified: code/player/trunk/replace/CMakeLists.txt =================================================================== --- code/player/trunk/replace/CMakeLists.txt 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/replace/CMakeLists.txt 2009-07-12 10:53:35 UTC (rev 8000) @@ -1,3 +1,5 @@ +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + IF (PLAYER_OS_WIN) INSTALL (FILES rpc/xdr.h rpc/types.h DESTINATION ${PLAYER_INCLUDE_INSTALL_DIR}/rpc) INSTALL (FILES replace.h DESTINATION ${PLAYER_INCLUDE_INSTALL_DIR}) @@ -3,2 +5,66 @@ ENDIF (PLAYER_OS_WIN) +IF (NOT HAVE_XDR) + SET (replaceSrcs ${replaceSrcs} + xdr.c + xdr_array.c + xdr_float.c + xdr_intXX_t.c + xdr_mem.c + xdr_sizeof.c) + SET (ws2_32lib Ws2_32) +ENDIF (NOT HAVE_XDR) + +IF (NOT HAVE_GETOPT) + SET (replaceSrcs ${replaceSrcs} getopt.c) +ENDIF (NOT HAVE_GETOPT) + +IF (NOT HAVE_DIRNAME) + SET (replaceSrcs ${replaceSrcs} dirname.c) +ENDIF (NOT HAVE_DIRNAME) + +IF (NOT HAVE_CLOCK_GETTIME) + SET (replaceSrcs ${replaceSrcs} clock_gettime.c) +ENDIF (NOT HAVE_CLOCK_GETTIME) + +IF (NOT HAVE_GETTIMEOFDAY) + SET (replaceSrcs ${replaceSrcs} gettimeofday.c) +ENDIF (NOT HAVE_GETTIMEOFDAY) + +IF (NOT HAVE_CFMAKERAW) + SET (replaceSrcs ${replaceSrcs} cfmakeraw.c) +ENDIF (NOT HAVE_CFMAKERAW) + +IF (NOT HAVE_ROUND) + SET (replaceSrcs ${replaceSrcs} round.c) +ELSEIF (NOT HAVE_ROUND) + IF (NOT HAVE_RINT) + SET (replaceSrcs ${replaceSrcs} round.c) + ENDIF (NOT HAVE_RINT) +ENDIF (NOT HAVE_ROUND) + +IF (NOT HAVE_USLEEP) + SET (replaceSrcs ${replaceSrcs} usleep.c) +ENDIF (NOT HAVE_USLEEP) + +IF (NOT HAVE_NANOSLEEP) + SET (replaceSrcs ${replaceSrcs} nanosleep.c) +ENDIF (NOT HAVE_NANOSLEEP) + +IF (NOT HAVE_POLL) + SET (replaceSrcs ${replaceSrcs} poll.c) + SET (ws2_32lib Ws2_32) +ENDIF (NOT HAVE_POLL) + +IF (NOT HAVE_COMPRESSBOUND) + SET (replaceSrcs ${replaceSrcs} compressBound.c) +ENDIF (NOT HAVE_COMPRESSBOUND) + +IF (replaceSrcs) + PLAYER_ADD_LIBRARY (playerreplace ${replaceSrcs}) + IF (NOT HAVE_XDR OR NOT HAVE_POLL) + TARGET_LINK_LIBRARIES (playerreplace Ws2_32) + ENDIF (NOT HAVE_XDR OR NOT HAVE_POLL) + PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "${ws2_32Lib}" "" "" "") +ENDIF (replaceSrcs) + Modified: code/player/trunk/replace/dirname.c =================================================================== --- code/player/trunk/replace/dirname.c 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/replace/dirname.c 2009-07-12 10:53:35 UTC (rev 8000) @@ -27,6 +27,8 @@ #include <string.h> +#include "replace/replace.h" + char * dirname (char *path) { Modified: code/player/trunk/replace/getopt.c =================================================================== --- code/player/trunk/replace/getopt.c 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/replace/getopt.c 2009-07-12 10:53:35 UTC (rev 8000) @@ -4,6 +4,8 @@ #include <stdio.h> #include <string.h> +#include "replace/replace.h" + char *optarg = NULL; int optind = 1, opterr = 1, optopt = 0; Modified: code/player/trunk/replace/replace.h =================================================================== --- code/player/trunk/replace/replace.h 2009-07-11 22:58:34 UTC (rev 7999) +++ code/player/trunk/replace/replace.h 2009-07-12 10:53:35 UTC (rev 8000) @@ -32,6 +32,18 @@ extern "C" { #endif +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERREPLACE_EXPORT + #elif defined (playerreplace_EXPORTS) + #define PLAYERREPLACE_EXPORT __declspec (dllexport) + #else + #define PLAYERREPLACE_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERREPLACE_EXPORT +#endif + #if !defined (PATH_MAX) // Windows limits the maximum path length to 260 #define PATH_MAX 260 @@ -77,13 +89,13 @@ an event to occur; if TIMEOUT is -1, block until an event occurs. Returns the number of file descriptors with events, zero if timed out, or -1 for errors. */ -int poll (struct pollfd *fds, unsigned long int nfds, int timeout); +PLAYERREPLACE_EXPORT int poll (struct pollfd *fds, unsigned long int nfds, int timeout); #else #include <sys/poll.h> /* for poll(2) */ #endif // !HAVE_POLL #if !HAVE_DIRNAME - char * dirname (char *path); +PLAYERREPLACE_EXPORT char * dirname (char *path); #else #include <libgen.h> // for dirname(3) #endif // !HAVE_DIRNAME @@ -94,21 +106,21 @@ #endif // !HAVE_CFMAKERAW && !WIN32 #if !HAVE_ROUND - double round (double x); +PLAYERREPLACE_EXPORT double round (double x); #endif // !HAVE_ROUND #if !HAVE_RINT - double rint (double x); +PLAYERREPLACE_EXPORT double rint (double x); #endif #if !HAVE_COMPRESSBO... [truncated message content] |
From: <th...@us...> - 2009-07-13 10:34:44
|
Revision: 8003 http://playerstage.svn.sourceforge.net/playerstage/?rev=8003&view=rev Author: thjc Date: 2009-07-13 10:34:37 +0000 (Mon, 13 Jul 2009) Log Message: ----------- big code refactoring (Part 1 of 2) Create a new libplayerinterface library which contains libplayerxdr and the interface related parts of core. This gets rid of the circular dependency between core and libplayerxdr that we have been hacking around since the interface definitions were automatically parsed. It also means that client libraries etc no longer have a dependency on core, which now is only responsible for the server core. This should make things easier if anyone wants to create a player compatible application/server without using anything but the interfaces from player. Currently utils are also in with libplayerinterface. Refactor part two will split the utilties into their own library. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake code/player/trunk/client_libs/libplayerc/bindings/ruby/playerc.i code/player/trunk/client_libs/libplayerc/dev_blackboard.c code/player/trunk/client_libs/libplayerc/dev_laser.c code/player/trunk/client_libs/libplayerc/dev_vectormap.c code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/client_libs/libplayerc/test/test_simulation.c code/player/trunk/client_libs/libplayerc/utils.c code/player/trunk/client_libs/libplayerc++/playerc++.h code/player/trunk/cmake/internal/ProcessInterfaces.cmake code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt code/player/trunk/examples/plugins/exampleinterface/eginterf_client.c code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayercore/configfile.cc code/player/trunk/libplayercore/device.cc code/player/trunk/libplayercore/devicetable.cc code/player/trunk/libplayercore/driver.cc code/player/trunk/libplayercore/driver.h code/player/trunk/libplayercore/filewatcher.cc code/player/trunk/libplayercore/message.cc code/player/trunk/libplayercore/playercore.h code/player/trunk/libplayercore/plugins.cc code/player/trunk/libplayercore/plugins.h code/player/trunk/libplayercore/property.cpp code/player/trunk/libplayercore/threaded_driver.cc code/player/trunk/libplayerinterface/CMakeLists.txt code/player/trunk/libplayerinterface/functiontable.c code/player/trunk/libplayerinterface/functiontable.h code/player/trunk/libplayerinterface/playerxdrgen.py code/player/trunk/libplayertcp/bindings/java/playertcp_java.i code/player/trunk/libplayertcp/playertcp.cc code/player/trunk/libplayertcp/playerudp.cc code/player/trunk/libplayertcp/socket_util.c code/player/trunk/libplayertcp/tcpremote_driver.cc code/player/trunk/libplayerwkb/playerwkb.c code/player/trunk/server/drivers/base/imagebase.cc code/player/trunk/server/drivers/base/imagebase.h code/player/trunk/server/drivers/blackboard/localbb/localbb.cpp code/player/trunk/server/drivers/blobfinder/artoolkitplus/artoolkitplus.cc code/player/trunk/server/drivers/blobfinder/cmvision/P2CMV.cc code/player/trunk/server/drivers/camera/1394/camera1394.cc code/player/trunk/server/drivers/camera/compress/cameracompress.cc code/player/trunk/server/drivers/camera/compress/camerauncompress.cc code/player/trunk/server/drivers/camera/sphere/sphere_mixed.h code/player/trunk/server/drivers/camera/uvc/cameraUVC.h code/player/trunk/server/drivers/camera/v4l/camerav4l.cc code/player/trunk/server/drivers/fiducial/laserbar.cc code/player/trunk/server/drivers/health/statgrab/statgrab_health.cpp code/player/trunk/server/drivers/joystick/linuxjoy.cc code/player/trunk/server/drivers/laser/lasercspace.cc code/player/trunk/server/drivers/laser/laserposeinterpolator.cc code/player/trunk/server/drivers/laser/lasertransform.h code/player/trunk/server/drivers/laser/sicklms200.cc code/player/trunk/server/drivers/laser/sicklms400.cc code/player/trunk/server/drivers/localization/amcl/amcl.cc code/player/trunk/server/drivers/localization/amcl/amcl_fiducial.cc code/player/trunk/server/drivers/localization/amcl/amcl_laser.cc code/player/trunk/server/drivers/localization/amcl/amcl_odom.cc code/player/trunk/server/drivers/localization/amcl/map/map_range.c code/player/trunk/server/drivers/localization/amcl/map/map_store.c code/player/trunk/server/drivers/localization/amcl/models/gps.c code/player/trunk/server/drivers/localization/amcl/models/imu.c code/player/trunk/server/drivers/localization/amcl/models/sonar.c code/player/trunk/server/drivers/localization/amcl/pf/pf.c code/player/trunk/server/drivers/localization/amcl/pf/pf_kdtree.c code/player/trunk/server/drivers/map/mapfile.cc code/player/trunk/server/drivers/mixed/garcia/garcia_mixed.h code/player/trunk/server/drivers/mixed/irobot/create/create_comms.c code/player/trunk/server/drivers/mixed/khepera/khepera.cc code/player/trunk/server/drivers/mixed/p2os/kinecalc.cc code/player/trunk/server/drivers/mixed/p2os/p2os.cc code/player/trunk/server/drivers/mixed/p2os/sip.cc code/player/trunk/server/drivers/mixed/reb/reb.cc code/player/trunk/server/drivers/mixed/rflex/rflex.cc code/player/trunk/server/drivers/mixed/rmp/segwayrmp.cc code/player/trunk/server/drivers/planner/wavefront/plan.c code/player/trunk/server/drivers/planner/wavefront/plan_control.c code/player/trunk/server/drivers/planner/wavefront/plan_waypoint.c code/player/trunk/server/drivers/planner/wavefront/wavefront.cc code/player/trunk/server/drivers/pointcloud3d/laserptzcloud.cc code/player/trunk/server/drivers/position/bumpersafe/bumpersafe.cc code/player/trunk/server/drivers/position/lasersafe/lasersafe.cc code/player/trunk/server/drivers/ranger/fromranger.h code/player/trunk/server/drivers/ranger/toranger.h code/player/trunk/server/drivers/rfid/rfi341_protocol.cc code/player/trunk/server/drivers/rfid/sickrfi341.cc code/player/trunk/server/drivers/rfid/skyetekM1.cc code/player/trunk/server/drivers/shell/kartowriter.cc code/player/trunk/server/drivers/shell/readlog.cc code/player/trunk/server/drivers/vectormap/dbconn.h code/player/trunk/server/drivers/vectormap/postgis.cc code/player/trunk/server/server.cc code/player/trunk/utils/playernav/gui.c code/player/trunk/utils/pmap/lodo_driver.cc Added Paths: ----------- code/player/trunk/libplayerinterface/ code/player/trunk/libplayerinterface/addr_util.c code/player/trunk/libplayerinterface/addr_util.h code/player/trunk/libplayerinterface/error.c code/player/trunk/libplayerinterface/error.h code/player/trunk/libplayerinterface/interface_util.c code/player/trunk/libplayerinterface/interface_util.h code/player/trunk/libplayerinterface/interfaces/ code/player/trunk/libplayerinterface/player.h code/player/trunk/libplayerinterface/playercommon.h code/player/trunk/libplayerinterface/playerinterfacegen.py Removed Paths: ------------- code/player/trunk/libplayercore/addr_util.c code/player/trunk/libplayercore/addr_util.h code/player/trunk/libplayercore/error.c code/player/trunk/libplayercore/error.h code/player/trunk/libplayercore/interface_util.c code/player/trunk/libplayercore/interface_util.h code/player/trunk/libplayercore/interfaces/ code/player/trunk/libplayercore/player.h code/player/trunk/libplayercore/playercommon.h code/player/trunk/libplayercore/playerinterfacegen.py code/player/trunk/libplayerxdr/ Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/CMakeLists.txt 2009-07-13 10:34:37 UTC (rev 8003) @@ -70,9 +70,9 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) ENDIF (PLAYER_OS_WIN) +ADD_SUBDIRECTORY (libplayerinterface) ADD_SUBDIRECTORY (client_libs) ADD_SUBDIRECTORY (libplayercore) -ADD_SUBDIRECTORY (libplayerxdr) ADD_SUBDIRECTORY (config) # Example config files ADD_SUBDIRECTORY (libplayerwkb) ADD_SUBDIRECTORY (libplayerjpeg) Modified: code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2009-07-13 10:34:37 UTC (rev 8003) @@ -396,8 +396,8 @@ // Include Player header so we can pick up some constants and generate // wrapper code for structs -%include "libplayercore/player.h" -%include "libplayercore/player_interfaces.h" +%include "libplayerinterface/player.h" +%include "libplayerinterface/player_interfaces.h" // Use this for regular c-bindings; Modified: code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/bindings/python/setup.py.cmake 2009-07-13 10:34:37 UTC (rev 8003) @@ -12,10 +12,9 @@ # bindings. module = Extension('_playerc', sources = ['playerc.i'], - include_dirs = [srcdir + '/../..', top_srcdir, top_builddir, top_builddir + '/libplayercore', top_builddir + '/client_libs'], + include_dirs = [srcdir + '/../..', top_srcdir, top_builddir, top_builddir + '/libplayerinterface', top_builddir + '/client_libs'], library_dirs = [builddir + '/../../.libs', - top_builddir + '/libplayerxdr/.libs', - top_builddir + '/libplayercore/.libs', + top_builddir + '/libplayerinterface/.libs', top_builddir + '/libplayerjpeg/.libs'], libraries = ['playerxdr', 'playerc', 'playerjpeg', 'jpeg', 'playererror', 'playerwkb']) Modified: code/player/trunk/client_libs/libplayerc/bindings/ruby/playerc.i =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/ruby/playerc.i 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/bindings/ruby/playerc.i 2009-07-13 10:34:37 UTC (rev 8003) @@ -480,8 +480,8 @@ // Include Player header so we can pick up some constants and generate // wrapper code for structs -%include "libplayercore/player.h" -%include "libplayercore/player_interfaces.h" +%include "libplayerinterface/player.h" +%include "libplayerinterface/player_interfaces.h" //TODO: service discovering, needs wrapping //%include "libplayersd/playersd.h" Modified: code/player/trunk/client_libs/libplayerc/dev_blackboard.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_blackboard.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/dev_blackboard.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -50,7 +50,7 @@ #include "playerc.h" #include "error.h" -#include <libplayerxdr/playerxdr.h> +#include <libplayerinterface/playerxdr.h> #if !defined (WIN32) #include <sys/time.h> #endif Modified: code/player/trunk/client_libs/libplayerc/dev_laser.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -48,7 +48,7 @@ #include <stdlib.h> #include <string.h> -#include <libplayercore/playercommon.h> +#include <libplayerinterface/playercommon.h> #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_vectormap.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -58,7 +58,7 @@ #include "playerc.h" #include "error.h" -#include <libplayerxdr/playerxdr.h> +#include <libplayerinterface/playerxdr.h> #include <libplayerwkb/playerwkb.h> #if defined (WIN32) Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -60,12 +60,12 @@ #include <playerconfig.h> /* Get the message structures from Player*/ -#include <libplayercore/playercommon.h> -#include <libplayercore/player.h> -#include <libplayercore/error.h> -#include <libplayercore/interface_util.h> -#include <libplayerxdr/playerxdr.h> -#include <libplayerxdr/functiontable.h> +#include <libplayerinterface/playercommon.h> +#include <libplayerinterface/player.h> +#include <libplayerinterface/error.h> +#include <libplayerinterface/interface_util.h> +#include <libplayerinterface/playerxdr.h> +#include <libplayerinterface/functiontable.h> #include <libplayerwkb/playerwkb.h> #if defined (WIN32) #include <winsock2.h> Modified: code/player/trunk/client_libs/libplayerc/test/test_simulation.c =================================================================== --- code/player/trunk/client_libs/libplayerc/test/test_simulation.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/test/test_simulation.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -5,7 +5,7 @@ # CVS: $Id$ **************************************************************************/ -#include <libplayercore/playercommon.h> +#include <libplayerinterface/playercommon.h> #include "test.h" #include "playerc.h" Modified: code/player/trunk/client_libs/libplayerc/utils.c =================================================================== --- code/player/trunk/client_libs/libplayerc/utils.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc/utils.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -44,7 +44,7 @@ **************************************************************************/ #include <string.h> -#include <libplayerxdr/functiontable.h> +#include <libplayerinterface/functiontable.h> #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -61,7 +61,7 @@ #include "libplayerc++/playerclient.h" #include "libplayerc++/playererror.h" #include "libplayerc++/clientproxy.h" -#include "libplayercore/interface_util.h" +#include "libplayerinterface/interface_util.h" #if defined (WIN32) #if defined (PLAYER_STATIC) Modified: code/player/trunk/cmake/internal/ProcessInterfaces.cmake =================================================================== --- code/player/trunk/cmake/internal/ProcessInterfaces.cmake 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/cmake/internal/ProcessInterfaces.cmake 2009-07-13 10:34:37 UTC (rev 8003) @@ -9,7 +9,7 @@ MACRO (PROCESS_INTERFACES options directory outputFile) # FILE (GLOB INTERFACE_DEPENDENCIES ${directory}/*.def) ADD_CUSTOM_COMMAND (OUTPUT ${outputFile} - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayercore/playerinterfacegen.py ${options} ${directory} > ${outputFile} + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerinterface/playerinterfacegen.py ${options} ${directory} > ${outputFile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${ARGN}) ENDMACRO (PROCESS_INTERFACES outputFile directory) Modified: code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/examples/plugins/exampleinterface/CMakeLists.txt 2009-07-13 10:34:37 UTC (rev 8003) @@ -5,13 +5,13 @@ SET (example_interface_h ${CMAKE_CURRENT_BINARY_DIR}/example_interface.h) ADD_CUSTOM_COMMAND (OUTPUT ${example_interface_h} - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayercore/playerinterfacegen.py --plugin 128_example.def > ${example_interface_h} + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerinterface/playerinterfacegen.py --plugin 128_example.def > ${example_interface_h} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) SET (example_functiontable_c ${CMAKE_CURRENT_BINARY_DIR}/example_functiontable.c) ADD_CUSTOM_COMMAND (OUTPUT ${example_functiontable_c} - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayercore/playerinterfacegen.py --plugin --functiontable 128_example.def > ${example_functiontable_c} + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerinterface/playerinterfacegen.py --plugin --functiontable 128_example.def > ${example_functiontable_c} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ) @@ -19,7 +19,7 @@ SET (example_xdr_h ${CMAKE_CURRENT_BINARY_DIR}/example_xdr.h) SET (example_xdr_c ${CMAKE_CURRENT_BINARY_DIR}/example_xdr.c) ADD_CUSTOM_COMMAND (OUTPUT ${example_xdr_h} ${example_xdr_c} - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerxdr/playerxdrgen.py ${example_interface_h} ${example_xdr_c} ${example_xdr_h} + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerinterface/playerxdrgen.py ${example_interface_h} ${example_xdr_c} ${example_xdr_h} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/example_interface.h ) @@ -32,7 +32,7 @@ ADD_LIBRARY (example_driver SHARED ${example_interface_h} ${example_xdr_h} eginterf_driver.cc) TARGET_LINK_LIBRARIES (example_driver playercore) ADD_EXECUTABLE (example_client example_client.c ${example_interface_h}) -TARGET_LINK_LIBRARIES (example_client playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} example) +TARGET_LINK_LIBRARIES (example_client playerc playerinterface playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} example) SET (exampleCMakeLists_in ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.example.in) SET (exampleCMakeLists ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt.example) Modified: code/player/trunk/examples/plugins/exampleinterface/eginterf_client.c =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/eginterf_client.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/examples/plugins/exampleinterface/eginterf_client.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -14,7 +14,7 @@ #include <string.h> #include <stdlib.h> #include <libplayerc/playerc.h> -#include <libplayercore/error.h> +#include <libplayerinterface/error.h> #include "example_interface.h" #include "example_xdr.h" Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,40 +1,9 @@ -INCLUDE (${PLAYER_CMAKE_DIR}/internal/ProcessInterfaces.cmake) - # The Python interpreter is necessary to compile this library INCLUDE (FindPythonInterp) IF (NOT PYTHONINTERP_FOUND) MESSAGE (FATAL_ERROR "No Python interpreter found. Cannot continue.") ENDIF (NOT PYTHONINTERP_FOUND) -FILE (GLOB interfaceFiles ${PROJECT_SOURCE_DIR}/libplayercore/interfaces/*.def) - -SET (player_interfaces_h "${CMAKE_CURRENT_BINARY_DIR}/player_interfaces.h") -SET (interface_table_h "${CMAKE_CURRENT_BINARY_DIR}/interface_table.h") -PROCESS_INTERFACES ("" ${CMAKE_CURRENT_SOURCE_DIR}/interfaces ${player_interfaces_h} ${interfaceFiles}) -ADD_CUSTOM_TARGET (player_interfaces ALL - DEPENDS ${player_interfaces_h} - COMMENT "Generating player_interfaces.h") -PROCESS_INTERFACES ("--utils" ${CMAKE_CURRENT_SOURCE_DIR}/interfaces ${interface_table_h} ${player_interfaces_h}) -ADD_CUSTOM_TARGET (interface_table ALL - DEPENDS ${interface_table_h} - COMMENT "Generating interface_table.h") - -# For now, we're generating our own copy of playerxdr.h (and .c as a side-effect) here. -# This can be fixed when the cross-directory dependency with libplayerxdr is removed. -SET (playerxdr_h "${CMAKE_CURRENT_BINARY_DIR}/playerxdr.h") -SET (playerxdr_c "${CMAKE_CURRENT_BINARY_DIR}/playerxdr.c") -ADD_CUSTOM_COMMAND (OUTPUT ${playerxdr_h} ${playerxdr_c} - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/libplayerxdr/playerxdrgen.py -distro ${CMAKE_CURRENT_SOURCE_DIR}/player.h ${playerxdr_c} ${playerxdr_h} ${CMAKE_CURRENT_BINARY_DIR}/player_interfaces.h - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${interfaceFiles} ${CMAKE_CURRENT_BINARY_DIR}/player_interfaces.h) - -# Include from the binary dir to get player_interfaces.h and interface_table.h -INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) -# Possibly use our own copy of XDR -IF (NOT HAVE_XDR) - INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) -ENDIF (NOT HAVE_XDR) - IF (NOT PTHREAD_INCLUDE_DIR STREQUAL "") PLAYERCORE_ADD_INCLUDE_DIR (${PTHREAD_INCLUDE_DIR}) ENDIF (NOT PTHREAD_INCLUDE_DIR STREQUAL "") @@ -57,12 +26,6 @@ threaded_driver.cc remote_driver.cc) -# TODO: playerxdr should NOT be linked here; it's a bogus dependency coming -# from the fact that message cloning functions are auto-generated into -# playerxdr and used here. Those functions should go into a separate -# library. -PLAYERCORE_ADD_INT_LINK_LIB (playerutils playererror playerxdr) - IF (NOT PLAYER_OS_QNX) PLAYERCORE_ADD_LINK_LIB (${PTHREAD_LIB}) ENDIF (NOT PLAYER_OS_QNX) @@ -89,9 +52,12 @@ SET (playerreplaceLib playerreplace) ENDIF (NOT HAVE_DIRNAME) +PLAYERCORE_ADD_INT_LINK_DIR (${CMAKE_BINARY_DIR}/libplayerinterface) +PLAYERCORE_ADD_INT_LINK_LIB (playerutils playererror playerinterface) + INCLUDE_DIRECTORIES (${PLAYERCORE_INT_INCLUDE_DIRS} ${PLAYERCORE_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYERCORE_INT_LINK_DIRS} ${PLAYERCORE_EXTRA_LINK_DIRS}) -PLAYER_ADD_LIBRARY (playercore ${playercoreSrcs} ${player_interfaces_h} ${playerxdr_h}) +PLAYER_ADD_LIBRARY (playercore ${playercoreSrcs}) TARGET_LINK_LIBRARIES (playercore ${playerreplaceLib} ${PLAYERCORE_INT_LINK_LIBRARIES} ${PLAYERCORE_EXTRA_LINK_LIBRARIES}) @@ -107,38 +73,17 @@ CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerPlugin.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerPlugin.cmake @ONLY) -SET (playererrorSrcs error.c) -PLAYER_ADD_LIBRARY (playererror ${playererrorSrcs}) -PLAYER_MAKE_PKGCONFIG ("playererror" "Player error reporting library - part of the Player Project" - "" "" "" "") - -SET (playerutilsSrcs interface_util.c - addr_util.c) -PLAYER_ADD_LIBRARY (playerutils ${playerutilsSrcs} ${interface_table_h}) -TARGET_LINK_LIBRARIES (playerutils playererror) -IF (PLAYER_OS_WIN) - TARGET_LINK_LIBRARIES (playerutils Ws2_32) -ENDIF (PLAYER_OS_WIN) -PLAYER_MAKE_PKGCONFIG ("playerutils" "Player utilities library - part of the Player Project" - "" "" "" "") - -PLAYER_INSTALL_HEADERS (playercore addr_util.h +PLAYER_INSTALL_HEADERS (playercore configfile.h device.h devicetable.h driver.h drivertable.h - error.h filewatcher.h globals.h - interface_util.h message.h - playercommon.h - ${playerconfig_h} playercore.h - player.h - ${player_interfaces_h} playertime.h plugins.h property.h Deleted: code/player/trunk/libplayercore/addr_util.c =================================================================== --- code/player/trunk/libplayercore/addr_util.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/addr_util.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,119 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) <insert dates here> - * <insert author's name(s) here> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ -#include <config.h> - -#include <stdio.h> -#include <string.h> -#include <assert.h> -#include <sys/types.h> -#if defined WIN32 - #include <Winsock2.h> - #define snprintf _snprintf -#else - #include <unistd.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <netdb.h> -#endif - -#include <libplayercore/error.h> // for error macros -#include "addr_util.h" - -void -packedaddr_to_dottedip(char* dest, size_t len, uint32_t addr) -{ - int mask = 0xff; - int swappedaddr; - - swappedaddr = htonl(addr); - - assert(len >= (size_t)16); - - snprintf(dest, 16,"%u.%u.%u.%u", - swappedaddr>>24 & mask, - swappedaddr>>16 & mask, - swappedaddr>>8 & mask, - swappedaddr>>0 & mask); -} - -int -hostname_to_packedaddr(uint32_t* dest, const char* hostname) -{ -#if HAVE_GETADDRINFO - int retval; - struct addrinfo* addr = NULL; -#else - struct sockaddr_in saddr; - struct hostent* entp; -#endif - char host[256]; - - memset(host,0,sizeof(host)); - if(!hostname) - { - if(gethostname(host,sizeof(host)) == -1) - { - PLAYER_ERROR("couldn't get hostname"); - return(-1); - } - } - else - strncpy(host,hostname,sizeof(host)); - // Make sure host is NULL-terminated - host[sizeof(host)-1] = '\0'; - -#if HAVE_GETADDRINFO - if((retval = getaddrinfo(host,NULL,NULL,&addr))) - { - printf("getaddrinfo() failed: %s", gai_strerror(retval)); - return(-1); - } - *dest = ((struct sockaddr_in*)addr->ai_addr)->sin_addr.s_addr; - freeaddrinfo(addr); -#else - if((entp = gethostbyname(host)) == NULL) - { - printf("gethostbyname() failed"); - return(-1); - } - *dest = ((struct in_addr*)entp->h_addr_list[0])->s_addr; -#endif - return(0); -} - Deleted: code/player/trunk/libplayercore/addr_util.h =================================================================== --- code/player/trunk/libplayercore/addr_util.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/addr_util.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,66 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) <insert dates here> - * <insert author's name(s) here> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ -#ifndef _ADDR_UTIL_H -#define _ADDR_UTIL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <playerconfig.h> - -#if defined (WIN32) - #if defined (PLAYER_STATIC) - #define PLAYERUTILS_EXPORT - #elif defined (playerutils_EXPORTS) - #define PLAYERUTILS_EXPORT __declspec (dllexport) - #else - #define PLAYERUTILS_EXPORT __declspec (dllimport) - #endif -#else - #define PLAYERUTILS_EXPORT -#endif - -PLAYERUTILS_EXPORT void packedaddr_to_dottedip(char* dest, size_t len, uint32_t addr); -PLAYERUTILS_EXPORT int hostname_to_packedaddr(uint32_t* dest, const char* hostname); - -#ifdef __cplusplus -} -#endif -#endif Modified: code/player/trunk/libplayercore/configfile.cc =================================================================== --- code/player/trunk/libplayercore/configfile.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/configfile.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -55,18 +55,19 @@ #include <replace/replace.h> -#include <libplayercore/player.h> -#include <libplayercore/playercommon.h> -#include <libplayercore/error.h> +#include <libplayerinterface/player.h> +#include <libplayerinterface/playercommon.h> +#include <libplayerinterface/error.h> +#include <libplayerinterface/interface_util.h> +#include <libplayerinterface/addr_util.h> + #include <libplayercore/configfile.h> -#include <libplayercore/interface_util.h> #include <libplayercore/driver.h> #include <libplayercore/drivertable.h> #include <libplayercore/devicetable.h> #include <libplayercore/globals.h> #include <libplayercore/plugins.h> -#include <libplayercore/addr_util.h> -#include <libplayerxdr/functiontable.h> +#include <libplayerinterface/functiontable.h> #if defined WIN32 #define snprintf _snprintf Modified: code/player/trunk/libplayercore/device.cc =================================================================== --- code/player/trunk/libplayercore/device.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/device.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -53,15 +53,14 @@ #endif #include <assert.h> +#include <libplayerinterface/error.h> +#include <libplayerinterface/interface_util.h> #include <libplayercore/driver.h> #include <libplayercore/device.h> #include <libplayercore/message.h> -#include <libplayercore/error.h> #include <libplayercore/playertime.h> #include <libplayercore/devicetable.h> #include <libplayercore/globals.h> -#include <libplayercore/error.h> -#include <libplayercore/interface_util.h> // Constructor Device::Device(player_devaddr_t addr, Driver *device) : Modified: code/player/trunk/libplayercore/devicetable.cc =================================================================== --- code/player/trunk/libplayercore/devicetable.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/devicetable.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -45,10 +45,10 @@ #include <string.h> // for strncpy(3) #include <stdlib.h> // for atoi(3) -#include <libplayercore/error.h> +#include <libplayerinterface/error.h> +#include <libplayerinterface/interface_util.h> +#include <libplayerinterface/addr_util.h> #include <libplayercore/devicetable.h> -#include <libplayercore/interface_util.h> -#include <libplayercore/addr_util.h> #if defined WIN32 #define strdup _strdup Modified: code/player/trunk/libplayercore/driver.cc =================================================================== --- code/player/trunk/libplayercore/driver.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/driver.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -59,13 +59,13 @@ #include <libplayercore/playertime.h> #include <libplayercore/driver.h> #include <libplayercore/device.h> -#include <libplayercore/error.h> +#include <libplayerinterface/error.h> #include <libplayercore/devicetable.h> #include <libplayercore/configfile.h> #include <libplayercore/globals.h> #include <libplayercore/filewatcher.h> #include <libplayercore/property.h> -#include <libplayercore/interface_util.h> +#include <libplayerinterface/interface_util.h> // Default constructor for single-interface drivers. Specify the // interface code and buffer sizes. Modified: code/player/trunk/libplayercore/driver.h =================================================================== --- code/player/trunk/libplayercore/driver.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/driver.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -61,9 +61,9 @@ #include <pthread.h> -#include <libplayercore/playercommon.h> +#include <libplayerinterface/playercommon.h> #include <libplayercore/message.h> -#include <libplayercore/player.h> +#include <libplayerinterface/player.h> #include <libplayercore/property.h> //using namespace std; Deleted: code/player/trunk/libplayercore/error.c =================================================================== --- code/player/trunk/libplayercore/error.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/error.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,70 +0,0 @@ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -/*************************************************************************** - * Desc: Error handling macros - * Author: Andrew Howard - * Date: 13 May 2002 - * CVS: $Id$ - **************************************************************************/ - -#include <stdarg.h> - -#include <libplayercore/error.h> - -// User-selected msg level: 0 for the most important messages (always -// printed); 9 for the least important. -int msgLevel; - -// File for logging messages -FILE *msgFile; -void (*ErrorPrint)(int msgType, int level, const char *file, int line, const char *fmt, ...) = DefaultErrorPrint; - - -// Initialize error logging -void -ErrorInit(int _msgLevel, FILE * logfile) -{ - msgLevel = _msgLevel; - msgFile = logfile; -} - -#define MSG_MAX 1024 - -// Function for printing and logging errors. -void DefaultErrorPrint(int msgType, int level, const char *file, int line, const char *fmt, ...) -{ - va_list ap; - - if (level <= msgLevel) - { - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - } - if (msgFile) - { - char msgBuf[MSG_MAX]; - va_start(ap, fmt); - vsnprintf(msgBuf, MSG_MAX, fmt, ap); - va_end(ap); - fprintf(msgFile, "%s:%d %s", file, line, msgBuf); - } - - return; -} Deleted: code/player/trunk/libplayercore/error.h =================================================================== --- code/player/trunk/libplayercore/error.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/error.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,113 +0,0 @@ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -/*************************************************************************** - * Desc: Error handling macros - * Author: Andrew Howard - * Date: 13 May 2002 - * CVS: $Id$ - **************************************************************************/ - -#ifndef ERROR_HH -#define ERROR_HH - -#include <stdio.h> -#include <errno.h> - -#include <playerconfig.h> - -#if defined (WIN32) - #if defined (PLAYER_STATIC) - #define PLAYERERROR_EXPORT - #elif defined (playererror_EXPORTS) - #define PLAYERERROR_EXPORT __declspec (dllexport) - #else - #define PLAYERERROR_EXPORT __declspec (dllimport) - #endif -#else - #define PLAYERERROR_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/// @internal Initialize error logging -PLAYERERROR_EXPORT void ErrorInit(int _msgLevel, FILE * logfile); - -/// @internal Function for print and logging errors. Do not call this -/// function directly; use the macros below. -PLAYERERROR_EXPORT void DefaultErrorPrint(int msgType, int level, const char *file, int line, const char *fmt, ...); - -PLAYERERROR_EXPORT extern void (*ErrorPrint)(int msgType, int level, const char *file, int line, const char *fmt, ...); -PLAYERERROR_EXPORT extern int msgLevel; - -// File for logging messages -PLAYERERROR_EXPORT extern FILE *msgFile; - -#ifdef __cplusplus -} -#endif - - -/// @internal Message types (internal use only; code should use the macros) -#define PLAYER_ERR_ERR 0 -#define PLAYER_ERR_WARN 1 -#define PLAYER_ERR_MSG 2 -#define PLAYER_ERR_DBG 2 - -/** @ingroup libplayererror - @{ */ - -/// Error message macros -#define PLAYER_ERROR(msg) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n") -#define PLAYER_ERROR1(msg, a) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a) -#define PLAYER_ERROR2(msg, a, b) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b) -#define PLAYER_ERROR3(msg, a, b, c) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c) -#define PLAYER_ERROR4(msg, a, b, c,d) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c, d) -#define PLAYER_ERROR5(msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c, d, e) - -/// Warning message macros -#define PLAYER_WARN(msg) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n") -#define PLAYER_WARN1(msg, a) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a) -#define PLAYER_WARN2(msg, a, b) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b) -#define PLAYER_WARN3(msg, a, b, c) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c) -#define PLAYER_WARN4(msg, a, b, c, d) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d) -#define PLAYER_WARN5(msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e) -#define PLAYER_WARN6(msg, a, b, c, d, e, f) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e, f) -#define PLAYER_WARN7(msg, a, b, c, d, e, f, g) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e, f, g) - -/// General messages. Use level to indicate the message importance -/// - 0 : important -/// - 1 : informative -/// - 2+ : diagnostic -/// All messages are recorded in the log file, but only the more important -/// messages are printed on the console. Use the command line option to -/// dictate which messages will be printed. -#define PLAYER_MSG0(level, msg) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n") -#define PLAYER_MSG1(level, msg, a) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a) -#define PLAYER_MSG2(level, msg, a, b) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b) -#define PLAYER_MSG3(level, msg, a, b, c) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c) -#define PLAYER_MSG4(level, msg, a, b, c, d) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d) -#define PLAYER_MSG5(level, msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e) -#define PLAYER_MSG6(level, msg, a, b, c, d, e, f) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e, f) -#define PLAYER_MSG7(level, msg, a, b, c, d, e, f, g) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e, f, g) - -/** @} */ - -#endif Modified: code/player/trunk/libplayercore/filewatcher.cc =================================================================== --- code/player/trunk/libplayercore/filewatcher.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/filewatcher.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -5,9 +5,11 @@ * Author: tcollett */ +#include <libplayerinterface/error.h> + + #include <libplayercore/filewatcher.h> #include <libplayercore/message.h> -#include <libplayercore/error.h> #include <stdlib.h> #include <assert.h> #include <math.h> Deleted: code/player/trunk/libplayercore/interface_util.c =================================================================== --- code/player/trunk/libplayercore/interface_util.c 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/interface_util.c 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,310 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) 2000 - * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#if defined WIN32 - #define snprintf _snprintf - #define strdup _strdup -#endif - -#include <libplayercore/player.h> // for interface constants -#include <libplayercore/interface_util.h> // for player_interface_t type - -#include "interface_table.h" - -static player_interface_t* itable; -static unsigned int itable_len; - -/* - * A string table of the message types, used to print type strings in error - * messages instead of type codes. - * Must be kept in numerical order with respect to the numeric values of the - * PLAYER_MSGTYPE_ #defines. - */ -static char* msgTypeStrTable[7]= -{ - "", // nothing - "data", // PLAYER_MSGTYPE_DATA - "command", // PLAYER_MSGTYPE_CMD - "request", // PLAYER_MSGTYPE_REQ - "resp_ack", // PLAYER_MSGTYPE_RESP_ACK - "sync", // PLAYER_MSGTYPE_SYNCH - "resp_nack", // PLAYER_MSGTYPE_RESP_NACK - -}; - -/* - * Initialises the interface names/codes table. - */ -int itable_init (void) -{ - unsigned int ii; - - // An indirect way of avoiding duplicate initialization. It would - // probably be better to delete the old table, but there may be some - // pointers hanging around that refer to the old table. - if(itable) - return(0); - - for (itable_len = 0; interfaces[itable_len].interf; itable_len++); - - if ((itable = (player_interface_t*) calloc (itable_len, sizeof (player_interface_t))) == NULL) - { - printf ("itable_init: Failed to allocate memory for interface table\n"); - return -1; - } - - for (ii = 0; ii < itable_len; ii++) - { - itable[ii].interf = interfaces[ii].interf; - itable[ii].name = strdup (interfaces[ii].name); - } - - return 0; -} - -/* - * Grows the interface table to newSize, filling each interface between the - * old end and the new end with (0xFFFF, "nointerfXX"). - */ -int itable_grow (int newSize) -{ - int ii; - - if ((itable = (player_interface_t*) realloc (itable, (newSize * sizeof (player_interface_t)))) == NULL) - { - printf("itable_grow: Failed to reallocate table memory\n"); - return -1; - } - // Fill in from the old end to the new end with undefined interfaces - for (ii = itable_len; ii < newSize; ii++) - { - itable[ii].interf = 0xFFFF; - if ((itable[ii].name = (char*) malloc (12)) == NULL) - { - printf("itable_grow: Failed to allocate memory for name\n"); - return -1; - } - snprintf (itable[ii].name, 12, "nointerf%d", ii); - } - // Set the new length - itable_len = newSize; - return 0; -} - -/* - * Destroys the interface names/codes table. - */ -void itable_destroy (void) -{ - unsigned int ii; - - for (ii = 0; ii < itable_len; ii++) - { - if (itable[ii].name != NULL) - free (itable[ii].name); - } - free (itable); -} - -/* - * Add a new interface to the interface table. - */ -int itable_add (const char *name, unsigned int code, int replace) -{ - if(code < itable_len) - { - // It's already in the table. Did the caller say to replace? - if(!replace) - { - // Nope; return an error - return(-1); - } - else - { - // Yes; replace - if ((itable[code].name = strdup (name)) == NULL) - { - printf("itable_add: Failed to allocate memory for name\n"); - return -1; - } - - return 0; - } - } - else - { - // Not in the table; add it - if (itable_grow (code + 1) < 0) - { - printf ("itable_add: Failed to grow interface table\n"); - return -1; - } - itable[code].interf = code; - if ((itable[code].name = strdup (name)) == NULL) - { - printf("itable_add: Failed to allocate memory for name\n"); - return -1; - } - return 0; - } - return 0; -} - -/* - * looks through the array of available interfaces for one which the given - * name. if found, interface is filled out (the caller must provide storage) - * and zero is returned. otherwise, -1 is returned. - */ -int -lookup_interface(const char* name, player_interface_t* interf) -{ - unsigned int i; - for(i=0; i<itable_len; i++) - { - if(!strcmp(name, itable[i].name)) - { - *interf = itable[i]; - return 0; - } - } - return -1; -} - -/* - * looks through the array of available interfaces for one which the given - * code. if found, interface is filled out (the caller must provide storage) - * and zero is returned. otherwise, -1 is returned. - */ -int -lookup_interface_code(int code, player_interface_t* interf) -{ - unsigned int i; - for(i=0; i<itable_len; i++) - { - if(code == itable[i].interf) - { - *interf = itable[i]; - return 0; - } - } - return -1; -} - -/* - * looks through the array of interfaces, starting at startpos, for the first - * entry that has the given code, and return the name. - * leturns 0 when the end of the * array is reached. - */ -const char* -lookup_interface_name(unsigned int startpos, int code) -{ - unsigned int i; - if(startpos > itable_len) - return 0; - for(i = startpos; i<itable_len; i++) - { - if(code == itable[i].interf) - { - return itable[i].name; - } - } - return 0; -} - -/* - * Returns the name of an interface given its code. The result string must - * not be altered. - */ -const char* interf_to_str(uint16_t code) -{ -// static char unknownstring[15]; - if (code < itable_len) - { - if (itable[code].interf != 0xFFFF) - return itable[code].name; - } -// snprintf (unknownstring, 15, "unknown[%d]", code); - return "unknown"; -} - -/* - * Returns the code for an interface, given a string. - */ -uint16_t -str_to_interf(const char *name) -{ - unsigned int ii; - for(ii=0; ii<itable_len; ii++) - { - if(!strcmp(name, itable[ii].name)) - return itable[ii].interf; - } - return 0xFFFF; -} - -/* - * Returns the name of a message type given its code. The result string must - * not be altered. - */ -const char* msgtype_to_str(uint8_t code) -{ -// static char unknownstring[13]; - if (code > 0 && code < 7) - return msgTypeStrTable[code]; -// snprintf (unknownstring, 15, "unknown[%d]", code); - return "unknown"; -} - -/* - * Returns the code for a message type, given a string. - */ -uint8_t -str_to_msgtype(const char *name) -{ - unsigned int ii; - for(ii=1; ii < 7; ii++) - { - if(!strcmp(name, msgTypeStrTable[ii])) - return ii; - } - return 0xFF; -} Deleted: code/player/trunk/libplayercore/interface_util.h =================================================================== --- code/player/trunk/libplayercore/interface_util.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/interface_util.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,156 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) 2000 - * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ********************************************************************/ - -/** @defgroup libplayerutils libplayerutils - * @brief Player utility library - -This library provides miscellaneous utilities functions -*/ - -/** @ingroup libplayerutils -@{ */ - -#ifndef _INTERFACE_UTIL_H -#define _INTERFACE_UTIL_H - -#if defined (WIN32) - #if defined (PLAYER_STATIC) - #define PLAYERUTILS_EXPORT - #elif defined (playerutils_EXPORTS) - #define PLAYERUTILS_EXPORT __declspec (dllexport) - #else - #define PLAYERUTILS_EXPORT __declspec (dllimport) - #endif -#else - #define PLAYERUTILS_EXPORT -#endif - -#include <playerconfig.h> // for uint16_t type - -#ifdef __cplusplus -extern "C" { -#endif - -// available interfaces are stored in an array of these, defined in -// interface_util.c -typedef struct -{ - uint16_t interf; - char* name; -} player_interface_t; - -/* - * Initialises the interface names/codes table. - */ -PLAYERUTILS_EXPORT int itable_init (void); - -/* - * Grows the interface table to newSize, filling each interface between the - * old end and the new end with (0xFFFF, "nointerfXX"). - */ -PLAYERUTILS_EXPORT int itable_grow (int newSize); - -/* - * Destroys the interface names/codes table. - */ -PLAYERUTILS_EXPORT void itable_destroy (void); - -/* - * Add a new interface to the interface table. - */ -PLAYERUTILS_EXPORT int itable_add (const char *name, unsigned int code, int replace); - -/* - * looks through the array of available interfaces for one which the given - * name. if found, interface is filled out (the caller must provide storage) - * and zero is returned. otherwise, -1 is returned. - */ -PLAYERUTILS_EXPORT int lookup_interface(const char* name, player_interface_t* interf); - -/* - * looks through the array of available interfaces for one which the given - * code. if found, interface is filled out (the caller must provide storage) - * and zero is returned. otherwise, -1 is returned. - */ -PLAYERUTILS_EXPORT int -lookup_interface_code(int code, player_interface_t* interf); - -/* - * looks through the array of interfaces, starting at startpos, for the first - * entry that has the given code, and returns the name. - * returns 0 if the device is not found. - */ -PLAYERUTILS_EXPORT const char* -lookup_interface_name(unsigned int startpos, int code); - -/* - * Returns the name of an interface given its code. The result string must - * not be altered. - */ -PLAYERUTILS_EXPORT const char* -interf_to_str(uint16_t code); - -/* - * Returns the code for an interface, given a string. If the name is not found, - * 0xFFFF is returned. - */ -PLAYERUTILS_EXPORT uint16_t -str_to_interf(const char *name); - -/* - * Returns the name of a message type given its code. The result string must - * not be altered. - */ -PLAYERUTILS_EXPORT const char* -msgtype_to_str(uint8_t code); - -/* - * Returns the code for a message type, given a string. If the name is not - * found, 0xFF is returned. - */ -PLAYERUTILS_EXPORT uint8_t -str_to_msgtype(const char *name); - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif Modified: code/player/trunk/libplayercore/message.cc =================================================================== --- code/player/trunk/libplayercore/message.cc 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/message.cc 2009-07-13 10:34:37 UTC (rev 8003) @@ -50,11 +50,12 @@ #include <math.h> #include <time.h> +#include <libplayerinterface/player.h> +#include <libplayerinterface/error.h> +#include <libplayerinterface/interface_util.h> +#include <libplayerinterface/playerxdr.h> + #include <libplayercore/message.h> -#include <libplayercore/player.h> -#include <libplayercore/error.h> -#include <libplayercore/interface_util.h> -#include <playerxdr.h> #include <replace/replace.h> Message::Message(const struct player_msghdr & aHeader, Deleted: code/player/trunk/libplayercore/player.h =================================================================== --- code/player/trunk/libplayercore/player.h 2009-07-13 08:14:03 UTC (rev 8002) +++ code/player/trunk/libplayercore/player.h 2009-07-13 10:34:37 UTC (rev 8003) @@ -1,495 +0,0 @@ -/* - * Player - One Hell of a Robot Server - * Copyright (C) 2000 - * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/******************************************************************** - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more detail... [truncated message content] |