Compare commits

...

6 Commits

Author SHA1 Message Date
727233624e delete console_brigde 2026-02-06 10:12:02 +00:00
948405bba4 update for ROS 2026-01-07 16:56:28 +07:00
5f7ae1233d update if define 2026-01-05 18:55:26 +07:00
6a3dea8614 update hieplm 2026-01-05 18:14:29 +07:00
a93304418d update 2026-01-05 10:52:41 +07:00
bb14979b8a catkin_make 2025-12-31 15:34:02 +07:00
23 changed files with 199 additions and 149 deletions

View File

@@ -1,15 +1,51 @@
cmake_minimum_required(VERSION 3.10)
project(robot_xmlrpcpp)
cmake_minimum_required(VERSION 3.0.2)
project(robot_xmlrpcpp VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
set(BUILDING_WITH_CATKIN TRUE)
message(STATUS "Building robot_xmlrpcpp with Catkin")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -fPIC)
else()
set(BUILDING_WITH_CATKIN FALSE)
message(STATUS "Building robot_xmlrpcpp with Standalone CMake")
endif()
add_library(robot_xmlrpcpp
# C++ Standard - must be set before find_package
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT BUILDING_WITH_CATKIN)
# Enable Position Independent Code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Cấu hình RPATH để tránh cycle trong runtime search path
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
else()
# ========================================================
# Catkin specific configuration
# ========================================================
find_package(catkin REQUIRED)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
endif()
# Libraries
add_library(${PROJECT_NAME} SHARED
src/XmlRpcClient.cpp
src/XmlRpcDispatch.cpp
src/XmlRpcServer.cpp
@@ -21,33 +57,87 @@ add_library(robot_xmlrpcpp
src/XmlRpcValue.cpp
)
target_include_directories(robot_xmlrpcpp
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
if(BUILDING_WITH_CATKIN)
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
install(TARGETS robot_xmlrpcpp
EXPORT robot_xmlrpcpp-targets
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
LIBRARY DESTINATION lib # Thư viện động .so
RUNTIME DESTINATION bin # File thực thi (nếu có)
INCLUDES DESTINATION include # Cài đặt include
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(
DIRECTORY include/
DESTINATION include/
)
target_link_libraries(${PROJECT_NAME}
PUBLIC ${catkin_LIBRARIES}
)
# --- Xuất export set robot_xmlrpcpp-targets thành file CMake module ---
# --- Tạo file lib/cmake/robot_xmlrpcpp/robot_xmlrpcpp-targets.cmake ---
# --- File này chứa cấu hình giúp project khác có thể dùng ---
# --- Find_package(robot_xmlrpcpp REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE robot_xmlrpcpp::robot_xmlrpcpp) ---
install(EXPORT robot_xmlrpcpp-targets
FILE robot_xmlrpcpp-targets.cmake
NAMESPACE robot_xmlrpcpp::
DESTINATION lib/cmake/robot_xmlrpcpp
)
else()
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# target_link_libraries(${PROJECT_NAME}
# )
set_target_properties(${PROJECT_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
endif()
# Compiler flags
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fPIC -Wno-unused-parameter)
endif()
if(BUILDING_WITH_CATKIN)
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
else()
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# Export targets
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
# Print configuration info
message(STATUS "=================================")
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "=================================")
endif()

View File

@@ -1,5 +1,5 @@
#ifndef _XMLRPC_H_
#define _XMLRPC_H_
#ifndef _ROBOT_XMLRPC_H_
#define _ROBOT_XMLRPC_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
// This library is free software; you can redistribute it and/or
@@ -32,8 +32,7 @@
#include "XmlRpcValue.h"
#include "XmlRpcUtil.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! An interface allowing custom handling of error message reporting.
@@ -90,7 +89,6 @@ namespace XmlRpc {
//! Version identifier
extern const char XMLRPC_VERSION[];
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPC_H_
#endif // _ROBOT_XMLRPC_H_

View File

@@ -1,6 +1,5 @@
#ifndef _XMLRPCCLIENT_H_
#define _XMLRPCCLIENT_H_
#ifndef _ROBOT_XMLRPCCLIENT_H_
#define _ROBOT_XMLRPCCLIENT_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -16,8 +15,7 @@
#include "robot_xmlrpcpp/XmlRpcDispatch.h"
#include "robot_xmlrpcpp/XmlRpcSource.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
// Arguments and results are represented by XmlRpcValues
class XmlRpcValue;
@@ -124,7 +122,6 @@ namespace XmlRpc {
}; // class XmlRpcClient
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCCLIENT_H_
#endif // _ROBOT_XMLRPCCLIENT_H_

View File

@@ -1,7 +1,6 @@
#ifndef _ROBOT_XMLRPCDISPATCH_H_
#define _ROBOT_XMLRPCDISPATCH_H_
#ifndef _XMLRPCDISPATCH_H_
#define _XMLRPCDISPATCH_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
#if defined(_MSC_VER)
@@ -12,8 +11,7 @@
# include <list>
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
// An RPC source represents a file descriptor to monitor
class XmlRpcSource;
@@ -84,7 +82,6 @@ namespace XmlRpc {
bool _inWork;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCDISPATCH_H_
#endif // _ROBOT_XMLRPCDISPATCH_H_

View File

@@ -1,7 +1,6 @@
#ifndef _ROBOT_XMLRPCEXCEPTION_H_
#define _ROBOT_XMLRPCEXCEPTION_H_
#ifndef _XMLRPCEXCEPTION_H_
#define _XMLRPCEXCEPTION_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
#if defined(_MSC_VER)
@@ -13,8 +12,7 @@
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! A class representing an error.
//! If server methods throw this exception, a fault response is returned
@@ -38,7 +36,6 @@ namespace XmlRpc {
int _code;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCEXCEPTION_H_
#endif // _ROBOT_XMLRPCEXCEPTION_H_

View File

@@ -1,7 +1,6 @@
#ifndef _ROBOT_XMLRPCSERVER_H_
#define _ROBOT_XMLRPCSERVER_H_
#ifndef _XMLRPCSERVER_H_
#define _XMLRPCSERVER_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
#if defined(_MSC_VER)
@@ -16,8 +15,7 @@
#include "robot_xmlrpcpp/XmlRpcDispatch.h"
#include "robot_xmlrpcpp/XmlRpcSource.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
// An abstract class supporting XML RPC methods
@@ -100,7 +98,6 @@ namespace XmlRpc {
XmlRpcServerMethod* _methodHelp;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif //_XMLRPCSERVER_H_
#endif //_ROBOT_XMLRPCSERVER_H_

View File

@@ -1,5 +1,5 @@
#ifndef _XMLRPCSERVERCONNECTION_H_
#define _XMLRPCSERVERCONNECTION_H_
#ifndef _ROBOT_XMLRPCSERVERCONNECTION_H_
#define _ROBOT_XMLRPCSERVERCONNECTION_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -14,8 +14,7 @@
#include "robot_xmlrpcpp/XmlRpcValue.h"
#include "robot_xmlrpcpp/XmlRpcSource.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
// The server waits for client connections and provides methods
@@ -98,7 +97,6 @@ namespace XmlRpc {
// Whether to keep the current client connection open for further requests
bool _keepAlive;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCSERVERCONNECTION_H_
#endif // _ROBOT_XMLRPCSERVERCONNECTION_H_

View File

@@ -1,7 +1,6 @@
#ifndef _XMLRPCSERVERMETHOD_H_
#ifndef _ROBOT_XMLRPCSERVERMETHOD_H_
#define _XMLRPCSERVERMETHOD_H_
//
#define _ROBOT_XMLRPCSERVERMETHOD_H_
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
#if defined(_MSC_VER)
@@ -12,8 +11,7 @@
# include <string>
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
// Representation of a parameter or result value
class XmlRpcValue;
@@ -43,7 +41,6 @@ namespace XmlRpc {
std::string _name;
XmlRpcServer* _server;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCSERVERMETHOD_H_
#endif // _ROBOT_XMLRPCSERVERMETHOD_H_

View File

@@ -1,5 +1,5 @@
#ifndef _XMLRPCSOCKET_H_
#define _XMLRPCSOCKET_H_
#ifndef _ROBOT_XMLRPCSOCKET_H_
#define _ROBOT_XMLRPCSOCKET_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -11,8 +11,7 @@
# include <string>
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! A platform-independent socket API.
class XmlRpcSocket {
@@ -65,7 +64,6 @@ namespace XmlRpc {
static std::string getErrorMsg(int error);
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif
#endif // _ROBOT_XMLRPCSOCKET_H_

View File

@@ -1,6 +1,5 @@
#ifndef _XMLRPCSOURCE_H_
#define _XMLRPCSOURCE_H_
#ifndef _ROBOT_XMLRPCSOURCE_H_
#define _ROBOT_XMLRPCSOURCE_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -8,8 +7,7 @@
# pragma warning(disable:4786) // identifier was truncated in debug info
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! An RPC source represents a file descriptor to monitor
class XmlRpcSource {
@@ -51,7 +49,6 @@ namespace XmlRpc {
// In the client, keep connections open if you intend to make multiple calls.
bool _keepOpen;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif //_XMLRPCSOURCE_H_
#endif //_ROBOT_XMLRPCSOURCE_H_

View File

@@ -1,5 +1,5 @@
#ifndef _XMLRPCUTIL_H_
#define _XMLRPCUTIL_H_
#ifndef _ROBOT_XMLRPCUTIL_H_
#define _ROBOT_XMLRPCUTIL_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -21,8 +21,7 @@
# define strncasecmp strnicmp
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! Utilities for XML parsing, encoding, and decoding and message handlers.
class XmlRpcUtil {
@@ -57,7 +56,6 @@ namespace XmlRpc {
static void error(const char* fmt, ...);
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
#endif // _XMLRPCUTIL_H_

View File

@@ -1,6 +1,5 @@
#ifndef _XMLRPCVALUE_H_
#define _XMLRPCVALUE_H_
#ifndef _ROBOT_XMLRPCVALUE_H_
#define _ROBOT_XMLRPCVALUE_H_
//
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
//
@@ -15,8 +14,7 @@
# include <time.h>
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
//! RPC method arguments and results are represented by Values
// should probably refcount them...
@@ -181,11 +179,9 @@ namespace XmlRpc {
} _value;
};
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
std::ostream& operator<<(std::ostream& os, robot::XmlRpc::XmlRpcValue& v);
std::ostream& operator<<(std::ostream& os, robot_xmlrpcpp::XmlRpcValue& v);
#endif // _XMLRPCVALUE_H_
#endif // _ROBOT_XMLRPCVALUE_H_

View File

@@ -6,8 +6,8 @@
//
//
#if !defined(__BASE64_H_INCLUDED__)
#define __BASE64_H_INCLUDED__ 1
#if !defined(__ROBOT_BASE64_H_INCLUDED__)
#define __ROBOT_BASE64_H_INCLUDED__ 1
#ifndef MAKEDEPEND
# include <iterator>

View File

@@ -19,8 +19,4 @@
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>libconsole-bridge-dev</build_depend>
<run_depend>libconsole-bridge-dev</run_depend>
</package>

View File

@@ -11,7 +11,7 @@
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;
// Static data
const char XmlRpcClient::REQUEST_BEGIN[] =
@@ -397,7 +397,7 @@ XmlRpcClient::parseResponse(XmlRpcValue& result)
// Expect either <params><param>... or <fault>...
if ((XmlRpcUtil::nextTagIs(PARAMS_TAG,_response,&offset) &&
XmlRpcUtil::nextTagIs(PARAM_TAG,_response,&offset)) ||
XmlRpcUtil::nextTagIs(FAULT_TAG,_response,&offset) && (_isFault = true))
(XmlRpcUtil::nextTagIs(FAULT_TAG,_response,&offset) && (_isFault = true)))
{
if ( ! result.fromXml(_response, &offset)) {
XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response value. Response:\n%s", _response.c_str());

View File

@@ -19,7 +19,7 @@
#endif // _WINDOWS
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;
XmlRpcDispatch::XmlRpcDispatch()

View File

@@ -7,7 +7,7 @@
#include "robot_xmlrpcpp/XmlRpcException.h"
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;
XmlRpcServer::XmlRpcServer()

View File

@@ -11,7 +11,7 @@
#endif
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;
// Static data
const char XmlRpcServerConnection::METHODNAME_TAG[] = "<methodName>";

View File

@@ -2,8 +2,7 @@
#include "robot_xmlrpcpp/XmlRpcServerMethod.h"
#include "robot_xmlrpcpp/XmlRpcServer.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
XmlRpcServerMethod::XmlRpcServerMethod(std::string const& name, XmlRpcServer* server)
@@ -19,5 +18,4 @@ namespace XmlRpc {
}
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp

View File

@@ -30,7 +30,7 @@ extern "C" {
#endif // MAKEDEPEND
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;

View File

@@ -3,8 +3,7 @@
#include "robot_xmlrpcpp/XmlRpcSocket.h"
#include "robot_xmlrpcpp/XmlRpcUtil.h"
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
XmlRpcSource::XmlRpcSource(int fd /*= -1*/, bool deleteOnClose /*= false*/)
@@ -33,5 +32,4 @@ namespace XmlRpc {
}
}
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp

View File

@@ -11,7 +11,7 @@
#include "robot_xmlrpcpp/XmlRpc.h"
using namespace robot::XmlRpc;
using namespace robot_xmlrpcpp;
//#define USE_WINDOWS_DEBUG // To make the error and log messages go to VC++ debug output
@@ -21,7 +21,7 @@ using namespace robot::XmlRpc;
#endif
// Version id
const char robot::XmlRpc::XMLRPC_VERSION[] = "XMLRPC++ 0.7";
const char robot_xmlrpcpp::XMLRPC_VERSION[] = "XMLRPC++ 0.7";
// Default log verbosity: 0 for no messages through 5 (writes everything)
int XmlRpcLogHandler::_verbosity = 0;
@@ -63,8 +63,8 @@ XmlRpcErrorHandler* XmlRpcErrorHandler::_errorHandler = &defaultErrorHandler;
// Easy API for log verbosity
int robot::XmlRpc::getVerbosity() { return XmlRpcLogHandler::getVerbosity(); }
void robot::XmlRpc::setVerbosity(int level) { XmlRpcLogHandler::setVerbosity(level); }
int robot_xmlrpcpp::getVerbosity() { return XmlRpcLogHandler::getVerbosity(); }
void robot_xmlrpcpp::setVerbosity(int level) { XmlRpcLogHandler::setVerbosity(level); }

View File

@@ -11,8 +11,7 @@
# include <stdio.h>
#endif
namespace robot {
namespace XmlRpc {
namespace robot_xmlrpcpp {
static const char VALUE_TAG[] = "<value>";
@@ -598,12 +597,11 @@ namespace XmlRpc {
return os;
}
} // namespace XmlRpc
} // namespace robot
} // namespace robot_xmlrpcpp
// ostream
std::ostream& operator<<(std::ostream& os, robot::XmlRpc::XmlRpcValue& v)
std::ostream& operator<<(std::ostream& os, robot_xmlrpcpp::XmlRpcValue& v)
{
// If you want to output in xml format:
//return os << v.toXml();