diff --git a/src/hos_celix/CMakeLists.txt b/src/hos_celix/CMakeLists.txt
index fc3c5de1..64f971b3 100644
--- a/src/hos_celix/CMakeLists.txt
+++ b/src/hos_celix/CMakeLists.txt
@@ -95,6 +95,7 @@ ExternalProject_Add( celix_project
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
CONFIGURE_COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/src
-DCMAKE_INSTALL_PREFIX=${CATKIN_DEVEL_PREFIX}
+ -DBUILD_SHARED_LIBS=TRUE
-DBUILD_FRAMEWORK=TRUE
-DBUILD_LAUNCHER=TRUE
-DBUILD_UTILS=TRUE
diff --git a/src/hos_cosgi_core/CMakeLists.txt b/src/hos_cosgi_core/CMakeLists.txt
new file mode 100644
index 00000000..cdb3bbf3
--- /dev/null
+++ b/src/hos_cosgi_core/CMakeLists.txt
@@ -0,0 +1,161 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(hos_cosgi_core)
+
+## Find catkin macros and libraries
+## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
+## is used, also find other catkin packages
+find_package(catkin REQUIRED COMPONENTS
+ hos_celix
+)
+
+## System dependencies are found with CMake's conventions
+# find_package(Boost REQUIRED COMPONENTS system)
+
+
+## Uncomment this if the package has a setup.py. This macro ensures
+## modules and global scripts declared therein get installed
+## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
+# catkin_python_setup()
+
+################################################
+## Declare ROS messages, services and actions ##
+################################################
+
+## To declare and build messages, services or actions from within this
+## package, follow these steps:
+## * Let MSG_DEP_SET be the set of packages whose message types you use in
+## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
+## * In the file package.xml:
+## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
+## * If MSG_DEP_SET isn't empty the following dependencies might have been
+## pulled in transitively but can be declared for certainty nonetheless:
+## * add a build_depend tag for "message_generation"
+## * add a run_depend tag for "message_runtime"
+## * In this file (CMakeLists.txt):
+## * add "message_generation" and every package in MSG_DEP_SET to
+## find_package(catkin REQUIRED COMPONENTS ...)
+## * add "message_runtime" and every package in MSG_DEP_SET to
+## catkin_package(CATKIN_DEPENDS ...)
+## * uncomment the add_*_files sections below as needed
+## and list every .msg/.srv/.action file to be processed
+## * uncomment the generate_messages entry below
+## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
+
+## Generate messages in the 'msg' folder
+# add_message_files(
+# FILES
+# Message1.msg
+# Message2.msg
+# )
+
+## Generate services in the 'srv' folder
+# add_service_files(
+# FILES
+# Service1.srv
+# Service2.srv
+# )
+
+## Generate actions in the 'action' folder
+# add_action_files(
+# FILES
+# Action1.action
+# Action2.action
+# )
+
+## Generate added messages and services with any dependencies listed here
+# generate_messages(
+# DEPENDENCIES
+# std_msgs # Or other packages containing msgs
+# )
+
+###################################
+## catkin specific configuration ##
+###################################
+## The catkin_package macro generates cmake config files for your package
+## Declare things to be passed to dependent projects
+## INCLUDE_DIRS: uncomment this if you package contains header files
+## LIBRARIES: libraries you create in this project that dependent projects also need
+## CATKIN_DEPENDS: catkin_packages dependent projects also need
+## DEPENDS: system dependencies of this project that dependent projects also need
+catkin_package(
+ INCLUDE_DIRS include
+# LIBRARIES hos_cosgi_core
+ CATKIN_DEPENDS hos_celix
+# DEPENDS system_lib
+)
+
+###########
+## Build ##
+###########
+
+## Specify additional locations of header files
+## Your package locations should be listed before other locations
+# include_directories(include)
+include_directories(
+ ${catkin_INCLUDE_DIRS}
+)
+
+## Declare a cpp library
+# add_library(hos_cosgi_core
+# src/${PROJECT_NAME}/hos_cosgi_core.cpp
+# )
+
+## Declare a cpp executable
+# add_executable(hos_cosgi_core_node src/hos_cosgi_core_node.cpp)
+
+## Add cmake target dependencies of the executable/library
+## as an example, message headers may need to be generated before nodes
+# add_dependencies(hos_cosgi_core_node hos_cosgi_core_generate_messages_cpp)
+
+## Specify libraries to link a library or executable target against
+# target_link_libraries(hos_cosgi_core_node
+# ${catkin_LIBRARIES}
+# )
+
+#############
+## Install ##
+#############
+
+# all install targets should use catkin DESTINATION variables
+# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
+
+## Mark executable scripts (Python etc.) for installation
+## in contrast to setup.py, you can choose the destination
+# install(PROGRAMS
+# scripts/my_python_script
+# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+# )
+
+## Mark executables and/or libraries for installation
+# install(TARGETS hos_cosgi_core hos_cosgi_core_node
+# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# RUNTIME DESTINATION ${CATKIN_PACKAGE_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
+)
+
+## Mark other files for installation (e.g. launch and bag files, etc.)
+# install(FILES
+# # myfile1
+# # myfile2
+# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
+# )
+
+#############
+## Testing ##
+#############
+
+## Add gtest based cpp test target and link libraries
+# catkin_add_gtest(${PROJECT_NAME}-test test/test_hos_cosgi_core.cpp)
+# if(TARGET ${PROJECT_NAME}-test)
+# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
+# endif()
+
+## Add folders to be run by python nosetests
+# catkin_add_nosetests(test)
diff --git a/src/hos_cosgi_core/include/hos_cosgi_core/cosgi_core.h b/src/hos_cosgi_core/include/hos_cosgi_core/cosgi_core.h
new file mode 100644
index 00000000..cc2a94cb
--- /dev/null
+++ b/src/hos_cosgi_core/include/hos_cosgi_core/cosgi_core.h
@@ -0,0 +1,25 @@
+/*
+ * cosgi_core.h
+ *
+ * Created on: 19.04.2015
+ * Author: matzman
+ */
+
+#ifndef INCLUDE_HOS_COSGI_CORE_COSGI_CORE_H_
+#define INCLUDE_HOS_COSGI_CORE_COSGI_CORE_H_
+
+
+class COSGI_Object_Interface {
+public:
+ virtual ~COSGI_Object_Interface() {}
+};
+
+
+class COSGI_Service_Interface : public COSGI_Object_Interface {
+public:
+ virtual const char* getServiceName() = 0;
+ virtual void getServiceVersion(int& major, int& minor) = 0;
+};
+
+
+#endif /* INCLUDE_HOS_COSGI_CORE_COSGI_CORE_H_ */
diff --git a/src/hos_cosgi_core/package.xml b/src/hos_cosgi_core/package.xml
new file mode 100644
index 00000000..41f67a15
--- /dev/null
+++ b/src/hos_cosgi_core/package.xml
@@ -0,0 +1,52 @@
+
+
+ hos_cosgi_core
+ 0.0.0
+ The hos_cosgi_core package
+
+
+
+
+ matzman
+
+
+
+
+
+ TODO
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ catkin
+ hos_celix
+ hos_celix
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/hos_cosgi_devicerepository/CMakeLists.txt b/src/hos_cosgi_devicerepository/CMakeLists.txt
index 9dd2f47e..85ce2844 100644
--- a/src/hos_cosgi_devicerepository/CMakeLists.txt
+++ b/src/hos_cosgi_devicerepository/CMakeLists.txt
@@ -8,6 +8,9 @@ find_package(catkin REQUIRED COMPONENTS
hos_celix
hos_core_msgs
hos_cosgi_launcher
+ hos_cosgi_core
+ hos_libvariant
+ roscpp
)
## System dependencies are found with CMake's conventions
@@ -87,7 +90,7 @@ find_package(Boost REQUIRED)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES hos_cosgi_devicerepository
- CATKIN_DEPENDS hos_celix hos_core_msgs hos_cosgi_launcher
+ CATKIN_DEPENDS hos_celix hos_core_msgs hos_cosgi_launcher roscpp hos_cosgi_core hos_libvariant
# DEPENDS system_lib
)
diff --git a/src/hos_cosgi_devicerepository/include/hos_cosgi_devicerepository/hos_devicerepository_service.h b/src/hos_cosgi_devicerepository/include/hos_cosgi_devicerepository/hos_devicerepository_service.h
index f3232447..8754d518 100644
--- a/src/hos_cosgi_devicerepository/include/hos_cosgi_devicerepository/hos_devicerepository_service.h
+++ b/src/hos_cosgi_devicerepository/include/hos_cosgi_devicerepository/hos_devicerepository_service.h
@@ -2,6 +2,7 @@
#define _HOS_DEVICEREPOSITORY_SERVICE_H_
+#include
#include
#include
@@ -11,10 +12,8 @@ namespace hos {
class DeviceEvent;
class DeviceEventListener;
-class GenericDevice {
+class GenericDevice : public COSGI_Object_Interface {
public:
- virtual ~GenericDevice() {}
-
virtual std::string getDeviceID() = 0;
virtual bool registerDeviceStatusListener(DeviceEventListener& listener) = 0;
@@ -30,26 +29,23 @@ public:
};
-class DeviceEventListener {
+class DeviceEventListener : public COSGI_Object_Interface {
public:
- virtual ~DeviceEventListener() {}
virtual void deviceEventReceived(const DeviceEvent& event) = 0;
};
-class HOSDeviceRepositoryService {
+class HOSDeviceRepositoryService : public COSGI_Service_Interface {
public:
static constexpr const char* SERVICE_NAME = "hos_devicerepository_service";
-
- virtual ~HOSDeviceRepositoryService() {}
+ static constexpr int SERVICE_VERSION_MAJOR = 1;
+ static constexpr int SERVICE_VERSION_MINOR = 0;
virtual GenericDevice* getDevice(std::string device_id) = 0;
virtual std::vector& getDevices(std::vector& devices) = 0;
virtual bool registerDeviceStatusListener(DeviceEventListener& listener) = 0;
virtual bool unregisterDeviceStatusListener(DeviceEventListener& listener) = 0;
-
- virtual void getVersion(int& major, int& minor) = 0;
};
diff --git a/src/hos_cosgi_devicerepository/package.xml b/src/hos_cosgi_devicerepository/package.xml
index 8a8c761a..0486b7ca 100644
--- a/src/hos_cosgi_devicerepository/package.xml
+++ b/src/hos_cosgi_devicerepository/package.xml
@@ -43,9 +43,15 @@
hos_celix
hos_core_msgs
hos_cosgi_launcher
+ roscpp
+ hos_cosgi_core
+ hos_libvariant
hos_celix
hos_core_msgs
hos_cosgi_launcher
+ roscpp
+ hos_cosgi_core
+ hos_libvariant
@@ -56,4 +62,4 @@
-
\ No newline at end of file
+
diff --git a/src/hos_cosgi_devicerepository/src/bundle_activator.cpp b/src/hos_cosgi_devicerepository/src/bundle_activator.cpp
index bbe5f3cd..a6e92897 100644
--- a/src/hos_cosgi_devicerepository/src/bundle_activator.cpp
+++ b/src/hos_cosgi_devicerepository/src/bundle_activator.cpp
@@ -56,7 +56,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
ROS_ERROR("DeviceRepositoryService: Could not retrieve HOSCoreService.");
} else {
int major = 0, minor = 0;
- coreService->getVersion(major, minor);
+ coreService->getServiceVersion(major, minor);
ROS_INFO_STREAM("DeviceRepositoryService: Found HOSCoreService Version " << major << "." << minor);
// Create and register hos-devicerepository-service
if (myUserData->serviceReg != nullptr) {
diff --git a/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.cpp b/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.cpp
index 22df7dc6..84c0e2e2 100644
--- a/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.cpp
+++ b/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.cpp
@@ -41,8 +41,6 @@ HOSDeviceRepositoryServiceImpl::HOSDeviceRepositoryServiceImpl(HOSCoreService& c
privateNodeHandle.getParam("~device_repository_prefix", deviceRepositoryPrefix);
}
-HOSDeviceRepositoryServiceImpl::~HOSDeviceRepositoryServiceImpl() {}
-
GenericDevice* HOSDeviceRepositoryServiceImpl::getDevice(std::string device_id) {
return this->devices[device_id];
}
@@ -75,9 +73,9 @@ bool HOSDeviceRepositoryServiceImpl::unregisterDeviceStatusListener(DeviceEventL
}
-void HOSDeviceRepositoryServiceImpl::getVersion(int& major, int& minor) {
- major = 1;
- minor = 0;
+void HOSDeviceRepositoryServiceImpl::getServiceVersion(int& major, int& minor) {
+ major = SERVICE_VERSION_MAJOR;
+ minor = SERVICE_VERSION_MINOR;
}
int HOSDeviceRepositoryServiceImpl::getRefCount() {
diff --git a/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.h b/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.h
index 5e281143..930f2671 100644
--- a/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.h
+++ b/src/hos_cosgi_devicerepository/src/hos_devicerepository_service_impl.h
@@ -45,7 +45,6 @@ private:
public:
HOSDeviceRepositoryServiceImpl(HOSCoreService& coreService);
- virtual ~HOSDeviceRepositoryServiceImpl();
virtual GenericDevice* getDevice(std::string device_id);
virtual std::vector& getDevices(std::vector& devices);
@@ -53,7 +52,9 @@ public:
virtual bool registerDeviceStatusListener(DeviceEventListener& listener);
virtual bool unregisterDeviceStatusListener(DeviceEventListener& listener);
- virtual void getVersion(int& major, int& minor);
+ virtual const char* getServiceName() { return SERVICE_NAME; }
+ virtual void getServiceVersion(int& major, int& minor);
+
virtual int getRefCount();
};
diff --git a/src/hos_cosgi_launcher/CMakeLists.txt b/src/hos_cosgi_launcher/CMakeLists.txt
index 8709eed1..92447fab 100644
--- a/src/hos_cosgi_launcher/CMakeLists.txt
+++ b/src/hos_cosgi_launcher/CMakeLists.txt
@@ -7,6 +7,7 @@ project(hos_cosgi_launcher)
find_package(catkin REQUIRED COMPONENTS
hos_celix
roscpp
+ hos_cosgi_core
)
## System dependencies are found with CMake's conventions
@@ -82,7 +83,7 @@ find_package(APR REQUIRED)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES hos_cosgi_launcher
- CATKIN_DEPENDS hos_celix
+ CATKIN_DEPENDS hos_celix hos_cosgi_core
# DEPENDS system_lib
)
diff --git a/src/hos_cosgi_launcher/include/hos_cosgi_launcher/hos_core_service.h b/src/hos_cosgi_launcher/include/hos_cosgi_launcher/hos_core_service.h
index 55474873..68af32ec 100644
--- a/src/hos_cosgi_launcher/include/hos_cosgi_launcher/hos_core_service.h
+++ b/src/hos_cosgi_launcher/include/hos_cosgi_launcher/hos_core_service.h
@@ -2,22 +2,24 @@
#define SRC_HOS_CORE_SERVICE_H_
+#include
+
+
namespace ros {
class NodeHandle;
}
namespace hos {
-class HOSCoreService {
+class HOSCoreService : public COSGI_Service_Interface {
public:
static constexpr const char* SERVICE_NAME = "hos_core_service";
-
- virtual ~HOSCoreService() {}
+ static constexpr int SERVICE_VERSION_MAJOR = 1;
+ static constexpr int SERVICE_VERSION_MINOR = 0;
virtual ros::NodeHandle& getPublicNodeHandle() = 0;
virtual ros::NodeHandle& getPrivateNodeHandle() = 0;
virtual void requestShutdown() = 0;
- virtual void getVersion(int& major, int& minor) = 0;
};
} // namespace hos
diff --git a/src/hos_cosgi_launcher/package.xml b/src/hos_cosgi_launcher/package.xml
index 32437d2d..5d74924f 100644
--- a/src/hos_cosgi_launcher/package.xml
+++ b/src/hos_cosgi_launcher/package.xml
@@ -42,8 +42,10 @@
catkin
hos_celix
roscpp
+ hos_cosgi_core
hos_celix
roscpp
+ hos_cosgi_core
diff --git a/src/hos_cosgi_launcher/src/hos_core_service_impl.cpp b/src/hos_cosgi_launcher/src/hos_core_service_impl.cpp
index 180e59ab..22fcd3b5 100644
--- a/src/hos_cosgi_launcher/src/hos_core_service_impl.cpp
+++ b/src/hos_cosgi_launcher/src/hos_core_service_impl.cpp
@@ -14,8 +14,6 @@ namespace hos {
HOSCoreServiceImpl::HOSCoreServiceImpl(ros::NodeHandle& publicNodeHandle, ros::NodeHandle& privateNodeHandle)
: publicNodeHandle(publicNodeHandle), privateNodeHandle(privateNodeHandle) {}
-HOSCoreServiceImpl::~HOSCoreServiceImpl() {}
-
ros::NodeHandle& HOSCoreServiceImpl::getPublicNodeHandle() {
return publicNodeHandle;
@@ -31,9 +29,9 @@ void HOSCoreServiceImpl::requestShutdown() {
ros::shutdown();
}
-void HOSCoreServiceImpl::getVersion(int& major, int& minor) {
- major = 1;
- minor = 0;
+void HOSCoreServiceImpl::getServiceVersion(int& major, int& minor) {
+ major = SERVICE_VERSION_MAJOR;
+ minor = SERVICE_VERSION_MINOR;
}
} // namespace hos
diff --git a/src/hos_cosgi_launcher/src/hos_core_service_impl.h b/src/hos_cosgi_launcher/src/hos_core_service_impl.h
index 50a7ce1b..85a66b13 100644
--- a/src/hos_cosgi_launcher/src/hos_core_service_impl.h
+++ b/src/hos_cosgi_launcher/src/hos_core_service_impl.h
@@ -20,12 +20,12 @@ private:
public:
HOSCoreServiceImpl(ros::NodeHandle& publicNodeHandle, ros::NodeHandle& privateNodeHandle);
- virtual ~HOSCoreServiceImpl();
virtual ros::NodeHandle& getPublicNodeHandle();
virtual ros::NodeHandle& getPrivateNodeHandle();
virtual void requestShutdown();
- virtual void getVersion(int& major, int& minor);
+ virtual const char* getServiceName() { return SERVICE_NAME; }
+ virtual void getServiceVersion(int& major, int& minor);
};
} // namespace hos
diff --git a/src/hos_libvariant/CMakeLists.txt b/src/hos_libvariant/CMakeLists.txt
new file mode 100644
index 00000000..b138e1c7
--- /dev/null
+++ b/src/hos_libvariant/CMakeLists.txt
@@ -0,0 +1,193 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(hos_libvariant)
+
+## Find catkin macros and libraries
+## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
+## is used, also find other catkin packages
+find_package(catkin REQUIRED)
+
+## System dependencies are found with CMake's conventions
+# find_package(Boost REQUIRED COMPONENTS system)
+
+
+## Uncomment this if the package has a setup.py. This macro ensures
+## modules and global scripts declared therein get installed
+## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
+# catkin_python_setup()
+
+################################################
+## Declare ROS messages, services and actions ##
+################################################
+
+## To declare and build messages, services or actions from within this
+## package, follow these steps:
+## * Let MSG_DEP_SET be the set of packages whose message types you use in
+## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
+## * In the file package.xml:
+## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
+## * If MSG_DEP_SET isn't empty the following dependencies might have been
+## pulled in transitively but can be declared for certainty nonetheless:
+## * add a build_depend tag for "message_generation"
+## * add a run_depend tag for "message_runtime"
+## * In this file (CMakeLists.txt):
+## * add "message_generation" and every package in MSG_DEP_SET to
+## find_package(catkin REQUIRED COMPONENTS ...)
+## * add "message_runtime" and every package in MSG_DEP_SET to
+## catkin_package(CATKIN_DEPENDS ...)
+## * uncomment the add_*_files sections below as needed
+## and list every .msg/.srv/.action file to be processed
+## * uncomment the generate_messages entry below
+## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
+
+## Generate messages in the 'msg' folder
+# add_message_files(
+# FILES
+# Message1.msg
+# Message2.msg
+# )
+
+## Generate services in the 'srv' folder
+# add_service_files(
+# FILES
+# Service1.srv
+# Service2.srv
+# )
+
+## Generate actions in the 'action' folder
+# add_action_files(
+# FILES
+# Action1.action
+# Action2.action
+# )
+
+## Generate added messages and services with any dependencies listed here
+# generate_messages(
+# DEPENDENCIES
+# std_msgs # Or other packages containing msgs
+# )
+
+###################################
+## catkin specific configuration ##
+###################################
+## The catkin_package macro generates cmake config files for your package
+## Declare things to be passed to dependent projects
+## INCLUDE_DIRS: uncomment this if you package contains header files
+## LIBRARIES: libraries you create in this project that dependent projects also need
+## CATKIN_DEPENDS: catkin_packages dependent projects also need
+## DEPENDS: system dependencies of this project that dependent projects also need
+catkin_package(
+ INCLUDE_DIRS include
+ LIBRARIES Variant
+# CATKIN_DEPENDS other_catkin_pkg
+# DEPENDS system_lib
+)
+
+###########
+## Build ##
+###########
+
+include(ExternalProject)
+
+ExternalProject_Add( libvariant_project
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
+ CONFIGURE_COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/src
+ -DCMAKE_INSTALL_PREFIX=${CATKIN_DEVEL_PREFIX}
+ -DBUILD_SHARED_LIBS=FALSE
+ -DLIBVARIANT_BUILD_EXAMPLES=FALSE
+ -DLIBVARIANT_BUILD_TESTS=FALSE
+ -DLIBVARIANT_BUILD_WALL=TRUE
+ -DLIBVARIANT_ENABLE_CURL=TRUE
+ -DLIBVARIANT_ENABLE_MSGPACK=FALSE
+ -DLIBVARIANT_ENABLE_XML=TRUE
+ -DLIBVARIANT_ENABLE_YAML=TRUE
+ BUILD_COMMAND make all
+ INSTALL_COMMAND make install
+)
+
+add_library( Variant STATIC IMPORTED )
+set_property( TARGET Variant PROPERTY IMPORTED_LOCATION "${CATKIN_DEVEL_PREFIX}/lib/libVariant.a")
+add_dependencies( Variant libvariant_project )
+
+## Specify additional locations of header files
+## Your package locations should be listed before other locations
+# include_directories(include)
+
+## Declare a cpp library
+# add_library(hos_libvariant
+# src/${PROJECT_NAME}/hos_libvariant.cpp
+# )
+
+## Declare a cpp executable
+# add_executable(hos_libvariant_node src/hos_libvariant_node.cpp)
+
+## Add cmake target dependencies of the executable/library
+## as an example, message headers may need to be generated before nodes
+# add_dependencies(hos_libvariant_node hos_libvariant_generate_messages_cpp)
+
+## Specify libraries to link a library or executable target against
+# target_link_libraries(hos_libvariant_node
+# ${catkin_LIBRARIES}
+# )
+
+#############
+## Install ##
+#############
+
+install(DIRECTORY include/${PROJECT_NAME}/
+ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
+)
+install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/lib/
+ DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+)
+install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/bin/
+ DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+ USE_SOURCE_PERMISSIONS
+)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake/
+ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake
+ FILES_MATCHING PATTERN "*.cmake"
+)
+
+# all install targets should use catkin DESTINATION variables
+# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
+
+## Mark executable scripts (Python etc.) for installation
+## in contrast to setup.py, you can choose the destination
+# install(PROGRAMS
+# scripts/my_python_script
+# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+# )
+
+## Mark executables and/or libraries for installation
+# install(TARGETS hos_libvariant hos_libvariant_node
+# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# RUNTIME DESTINATION ${CATKIN_PACKAGE_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
+# )
+
+## Mark other files for installation (e.g. launch and bag files, etc.)
+# install(FILES
+# # myfile1
+# # myfile2
+# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
+# )
+
+#############
+## Testing ##
+#############
+
+## Add gtest based cpp test target and link libraries
+# catkin_add_gtest(${PROJECT_NAME}-test test/test_hos_libvariant.cpp)
+# if(TARGET ${PROJECT_NAME}-test)
+# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
+# endif()
+
+## Add folders to be run by python nosetests
+# catkin_add_nosetests(test)
diff --git a/src/hos_libvariant/include/hos_libvariant/ArgParse.h b/src/hos_libvariant/include/hos_libvariant/ArgParse.h
new file mode 100644
index 00000000..74248bec
--- /dev/null
+++ b/src/hos_libvariant/include/hos_libvariant/ArgParse.h
@@ -0,0 +1,302 @@
+/** \file
+ * \author John Bridgman
+ * \brief
+ */
+#ifndef VARIANT_ARGPARSER_H
+#define VARIANT_ARGPARSER_H
+
+#pragma once
+#include "../hos_libvariant/Variant.h"
+#include
+#include
+namespace libvariant {
+
+
+ enum ArgParseAction {
+ ARGACTION_UNKNOWN, // Unknown action (invalid)
+ ARGACTION_STORE, // Interpret the option argument and store it at the path
+ ARGACTION_STORE_CONST, // Store const into the path
+ ARGACTION_STORE_TRUE, // Store true into the path
+ ARGACTION_STORE_FALSE, // Store false into the path
+ ARGACTION_APPEND, // Append the option argument to the list at path
+ ARGACTION_COUNT, // Make the value at path be the count of this options occurrences
+ ARGACTION_HELP, // Print out the help text and exit
+ ARGACTION_ADVHELP, // Print the advanced help and exit
+ ARGACTION_CONFIG, // Consider the option argument a filename to be loaded and parsed as a config
+ ARGACTION_CONFIG_JSON, // force parser to use jscn
+ ARGACTION_CONFIG_YAML, // force parser to use yaml
+ ARGACTION_CONFIG_PLIST, // force parser to use xmlplist
+ ARGACTION_PRINT_CONFIG // At the end of parsing print out the resulting config and exit.
+ };
+
+ // A constrained list of only the valid types for ArgParse
+ enum ArgParseType {
+ ARGTYPE_GUESS = Variant::NullType, // No type specification, guess, uses deserialize machinery
+ ARGTYPE_INT = Variant::IntegerType, // Error if it cannot be turned into an integer
+ ARGTYPE_UINT = Variant::UnsignedType, // Error if it cannot be turned into a unsigned
+ ARGTYPE_FLOAT = Variant::FloatType, // Error if it cannot be turned into a float
+ ARGTYPE_STRING = Variant::StringType, // store as string
+ ARGTYPE_BOOL = Variant::BoolType // Error if it cannot be turned into a boolean type
+ // it treats 0 or the strings 'false' and 'no' or any substring ignoring case as false
+ // and everything else as true
+ };
+
+ //! Valid values are:
+ // This is used for converting the enum to a Variant and back for
+ // ArgParse::GetDescription and ArgParse::Merge
+ // store -- store the value into the key (default)
+ // store_const -- store const (see Const) into the key
+ // store_true -- store true into the key (i.e. no option argument)
+ // store_false -- store false into the key
+ // append -- make the value a list of instances of the option
+ // count -- count the number of instances of this argument
+ // help -- display the help text and exit
+ // config -- load a file and merge it into the result (uses GuessFormat)
+ // config_json -- same as config, force to use json parser
+ // config_yaml -- same as config, force to use yaml parser
+ // config_plist -- same as config, force to use xml-plist parser
+ // config_print -- when finished parsing, print out the config and exit
+ ArgParseAction ArgParseActionFromStr(const std::string &action);
+ std::string ArgParseActionToStr(ArgParseAction action);
+
+ class ArgParse;
+ struct ArgParseImpl;
+ struct ArgParseOptImpl;
+ struct ArgParseGroupImpl;
+
+ //! ArgParseOption is a part of class ArgParse.
+ // ArgParseOption is the interface that ArgParse provides to the user to be able
+ // to conveniently set the options for an option.
+ class ArgParseOption {
+ public:
+
+ //! Set the title of this option. The title is used
+ // as an argument placeholder string.
+ ArgParseOption &Title(const std::string &title);
+
+ //! What action to perform when this option is encountered.
+ // See ArgParseAction above for a list of actions.
+ ArgParseOption &Action(ArgParseAction action);
+ DEPRECATED ArgParseOption &Action(const std::string &action);
+
+ //! Set the type parsing and validation.
+ // If set and the argument is not of this type, then it is invalid.
+ // Default: ARGTYPE_GUESS
+ // If type is ARGTYPE_GUESS then ArgParse attempts to parse the
+ // argument with the same machinery that is used by the deserializers
+ // to figure out the type of a scalar.
+ // ARGTYPE_UINT is the same as ARGTYPE_INT but with
+ // Minimum set to 0.
+ // See ArgParseType for the list of valid types.
+ ArgParseOption &Type(ArgParseType type);
+ // Same as above but throws on invalid type
+ DEPRECATED ArgParseOption &Type(Variant::Type_t type);
+ // String version of the above
+ // Valid types are "string", "number", "integer", "boolean", or "null".
+ // Default type is "null".
+ DEPRECATED ArgParseOption &Type(const std::string &type);
+
+ //! Set the const value for "store_const"
+ ArgParseOption &Const(Variant val);
+
+ //! Set the default value used when the option is not set.
+ ArgParseOption &Default(Variant val);
+
+ //! Set the environment variable name to check for a value for this option.
+ // When the environment variable is present this acts like Default was set
+ // to the environment variable's value. I.e., this overrides default,
+ // command line arguments override this.
+ ArgParseOption &Env(const char *env);
+
+ //! If the resulting value is a number, require to be at least this minimum.
+ ArgParseOption &Minimum(Variant val);
+
+ //! If the resulting value is a number, require to be at most this maximum.
+ ArgParseOption &Maximum(Variant val);
+
+ //! Add choices.
+ // If a choice is added, the value of the option must be one of the choices.
+ ArgParseOption &AddChoice(Variant val);
+
+ //! Set choices (old ones forgotten) from a vector.
+ ArgParseOption &SetChoices(const std::vector &val);
+
+ //! Return the vector of choices set.
+ const std::vector &GetChoices();
+
+ //! Is this option required?
+ ArgParseOption &Required(bool req=true);
+
+ //! Set the help text for this option.
+ ArgParseOption &Help(const std::string &helptxt);
+
+ //! If this option is a string, it must match the regex in pattern.
+ ArgParseOption &Pattern(const std::string &pattern);
+
+ //! If this option is a string, it must be no longer than maxLength.
+ ArgParseOption &MaxLength(unsigned l);
+
+ //! If this option is a string, it must be no shorter than minLength.
+ ArgParseOption &MinLength(unsigned l);
+
+ //! If this option can be specified multiple times, it must be
+ // specified minArgs times at least.
+ // A value of 0 means zero arguments is valid.
+ ArgParseOption &MinArgs(unsigned l);
+
+ //! If this option can be specified multiple times, it cannot be
+ // specified more than maxArgs.
+ // A value of 0 means any number
+ ArgParseOption &MaxArgs(unsigned l);
+
+ //! Specify that this argument must be present l times.
+ // Sets both minArgs and maxArgs to l
+ ArgParseOption &NumArgs(unsigned l);
+
+ //! Adds this option to group gname. If gname does not exist,
+ //it will be created with an empty title and description.
+ ArgParseOption &Group(const std::string &gname);
+
+ //! Sets this argument to be an advanced option
+ // This hides the option when not printing advanced options
+ ArgParseOption &Advanced(bool adv = true);
+
+ private:
+ ArgParseOption(ArgParseOptImpl *i) : impl(i) {}
+ ArgParseOptImpl *impl;
+ friend class ArgParse;
+ };
+
+ //! Groups are a way to organize the option and to provide mutual exclusion
+ //of option. An argument may be part of more than one group, but may only
+ //be part of one group that has a non-empty title and description. An
+ //attempt is made to order the help text so that options within the same
+ //group appear together and if a group has a title and/or description the
+ //options are placed within a subsection headed with the title and
+ //description.
+ class OptionGroup {
+ public:
+ //! Set the title for this group
+ OptionGroup &Title(const std::string &t);
+ //! Set the description for this group
+ OptionGroup &Description(const std::string &d);
+ //! Set that the options in this group are mutually exclusive
+ OptionGroup &MutuallyExclusive(bool exclusive=true);
+ //! Set that at least one option in this group is required.
+ //Has no meaning when the group is not mutually exclusive.
+ OptionGroup &Required(bool req=true);
+
+ OptionGroup &Add(const std::string &keypath);
+ OptionGroup &Add(const Path &keypath);
+
+ //! Sets this option group to be advanced
+ // Hide the group when not printing advanced options.
+ // This only hides the group when it has a title or description
+ OptionGroup &Advanced(bool adv=true);
+ private:
+ OptionGroup(ArgParseGroupImpl *i) : impl(i) {}
+ ArgParseGroupImpl *impl;
+ friend class ArgParse;
+ };
+
+ class ArgParse {
+ public:
+ //! addhelp true causes AddHelp to be called.
+ ArgParse(bool addhelp=true);
+ ArgParse(const std::string &pname, bool addhelp=true);
+
+ //! Add the option and configure it as an option that takes an argument.
+ //The default action will be "store" and type will be unspecified
+ //
+ // keypath must be a valid path as defined in Path.h
+ //
+ // For no short option, shortOpt may be 0, and for no long option, longOpt may be
+ // the empty string. If both shortOpt is 0 and longOpt is empty then this option
+ // is hidden unless Env is also set for the option.
+ ArgParseOption AddOption(const std::string &keypath, int shortOpt, const std::string &longOpt="",
+ const std::string &helptxt="");
+
+ //! Convenience methods for getting an existing option.
+ // ArgParse args(argv[0]);
+ // args.AddOption("key1", 'k', "key1", "how many things").Type("integer");
+ // args.AddOption("key2", 'K', "key2", "what to name it").Type("string");
+ // (... some intermediate code ...)
+ // args.At("key1").Default(42);
+ // args["key2"].Default("foo");
+ ArgParseOption At(const std::string &keypath);
+ ArgParseOption operator[](const std::string &keypath) { return At(keypath); }
+
+ //! Add the option and configure it as an option that is default false and
+ //if present sets to true
+ //i.e., same as:
+ // AddOption(keypath, shortOpt, longOpt, helptxt).Type("boolean")
+ // .Action("store_true").Default(false);
+ ArgParseOption AddFlag(const std::string &keypath, int shortOpt, const std::string &longOpt="",
+ const std::string &helptxt="");
+
+ //! Adds the group name.
+ OptionGroup AddGroup(const std::string &name, const std::string &title="", const std::string &description="");
+ //! Returns the group name.
+ OptionGroup GetGroup(const std::string &name);
+
+ //! Add a positional argument.
+ // By default the new positional argument will have NumArgs as 1.
+ // Arguments are processed in the order they are added.
+ // If maxArgs is 0, then no positional arguments after this one will
+ // be processed.
+ // Default action is store.
+ ArgParseOption AddArgument(const std::string &keypath, const std::string &helptxt="");
+
+ //! Convenience methods for getting an existing argument.
+ // ArgParse args(argv[0]);
+ // args.AddArgument("arg0", "pick one").AddChoice("AAA").AddChoice("BBB");
+ // args.AddArgument("arg1", "scale factor").Type("float");
+ // (... some intermediate code ...)
+ // args.At(0).AddChoice("CCC");
+ // args[1].Default(0.456);
+ ArgParseOption At(size_t argumentIndex);
+ ArgParseOption operator[](size_t argumentIndex) { return At(argumentIndex); }
+
+ //! When this is on, trying to add a second option with the same short option
+ //will cause the second option to act as though it had no short option specified.
+ void ConflictResolution(bool resolve=true);
+
+ //! Add a --config and --print-config option
+ // --config is set with action ARGACTION_CONFIG and
+ // --print-config is set with action ARGACTION_PRINT_CONFIG
+ void AddConfigDefaults();
+
+ //! Add -h,--help option with action ARGACTION_HELP
+ void AddHelp();
+
+ //! Set the description text that follows the usage message.
+ void SetDescription(const std::string &txt);
+ //! Set the epilog text at the end of help.
+ void SetEpilog(const std::string &txt);
+ //! Override the default program name.
+ void SetProgramName(const std::string &pname, bool do_basename=true);
+ std::string GetProgramName() const;
+
+ void Merge(Variant newopts);
+ void Merge(const ArgParse &other);
+
+ //! Validate the argparse description against the internal schema
+ void Validate() const;
+
+ //! Parse the arguments with the internal description
+ Variant Parse(int argc, char *const *argv);
+
+ //! Print the help message and exit.
+ void PrintHelp(bool advanced=false) const;
+
+ //! Return the Variant that describes the arguments
+ Variant GetDescription() const;
+
+ //! Generate a schema for the Variant returned by Parse from the argument description
+ Variant GenerateSchema() const;
+
+ private:
+ shared_ptr impl;
+ };
+}
+#endif
diff --git a/src/hos_libvariant/include/hos_libvariant/Blob.h b/src/hos_libvariant/include/hos_libvariant/Blob.h
new file mode 100644
index 00000000..b2706e4d
--- /dev/null
+++ b/src/hos_libvariant/include/hos_libvariant/Blob.h
@@ -0,0 +1,63 @@
+/** \file
+ * \author John Bridgman
+ * \brief
+ */
+#ifndef VARIANT_BLOB_H
+#define VARIANT_BLOB_H
+
+#pragma once
+#include "../../../src/include/Variant/SharedPtr.h"
+#include
+#include
+
+namespace libvariant {
+ class Blob;
+ typedef shared_ptr BlobPtr;
+ typedef shared_ptr ConstBlobPtr;
+
+ typedef void (*BlobFreeFunc)(void *ptr, void *ctx);
+
+ class Blob {
+ public:
+
+ /// Reference the buffer and call ffunc when Blob no longer references it
+ static BlobPtr Create(void *ptr, unsigned len, BlobFreeFunc ffunc, void *context);
+ /// Will call ffunc on each buffer in iov
+ static BlobPtr Create(struct iovec *iov, unsigned iov_len, BlobFreeFunc ffunc, void *context);
+ /// Copy the data into a newly allocatd buffer
+ static BlobPtr CreateCopy(const void *ptr, unsigned len);
+ static BlobPtr CreateCopy(const struct iovec *iov, unsigned iov_len);
+ /// Reference the buffer and when done call free to free the buffer
+ static BlobPtr CreateFree(void *ptr, unsigned len);
+ static BlobPtr CreateFree(struct iovec *iov, unsigned iov_len);
+ /// Reference the buffer, assume static or other allocation lifetime where
+ // calling a free function is not required
+ static BlobPtr CreateReferenced(void *ptr, unsigned len);
+ static BlobPtr CreateReferenced(struct iovec *iov, unsigned iov_len);
+ ~Blob();
+
+ BlobPtr Copy() const;
+
+ void *GetPtr(unsigned i) { return iov[i].iov_base; }
+ const void *GetPtr(unsigned i) const { return iov[i].iov_base; }
+ unsigned GetLength(unsigned i) const { return iov[i].iov_len; }
+ struct iovec *GetIOVec() { return &iov[0]; }
+ const struct iovec *GetIOVec() const { return &iov[0]; }
+ unsigned GetNumBuffers() const { return iov.size(); }
+ unsigned GetTotalLength() const;
+
+ int Compare(ConstBlobPtr other) const;
+
+ private:
+ Blob();
+ Blob(const Blob&);
+ Blob(struct iovec *v, unsigned l, BlobFreeFunc f, void *c);
+ Blob operator=(const Blob&);
+
+ std::vector iov;
+ BlobFreeFunc free_func;
+ void *ctx;
+ };
+
+}
+#endif
diff --git a/src/hos_libvariant/include/hos_libvariant/Config.h b/src/hos_libvariant/include/hos_libvariant/Config.h
new file mode 100644
index 00000000..32f40d22
--- /dev/null
+++ b/src/hos_libvariant/include/hos_libvariant/Config.h
@@ -0,0 +1,13 @@
+/** \file
+ * \author John Bridgman
+ * \brief
+ */
+#ifndef VARIANT_CONFIG_H
+#define VARIANT_CONFIG_H
+#pragma once
+
+/* #undef HAVE_CXX11_SHAREDPTR */
+#define HAVE_TR1_SHAREDPTR 1
+/* #undef USE_BOOST_SHAREDPTR */
+
+#endif
diff --git a/src/hos_libvariant/include/hos_libvariant/Emitter.h b/src/hos_libvariant/include/hos_libvariant/Emitter.h
new file mode 100644
index 00000000..1b113470
--- /dev/null
+++ b/src/hos_libvariant/include/hos_libvariant/Emitter.h
@@ -0,0 +1,226 @@
+//=============================================================================
+// This library is free software; you can redistribute it and/or modify it
+// under the terms of the GNU Library General Public License as published
+// by the Free Software Foundation; either version 2 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
+// Library General Public License for more details.
+//
+// The GNU Public License is available in the file LICENSE, or you
+// can write to the Free Software Foundation, Inc., 59 Temple Place -
+// Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
+// World Wide Web at http://www.fsf.org.
+//=============================================================================
+/** \file
+ * \author John Bridgman
+ * \brief
+ */
+#ifndef VARIANT_EMITTER_H
+#define VARIANT_EMITTER_H
+
+#pragma once
+#include
+#include
+#include