Skip to content
Snippets Groups Projects
Commit e6e5f3b1 authored by hvanwelbergen's avatar hvanwelbergen
Browse files

Merge branch 'master' of portb.techfak.uni-bielefeld.de:/vol/soa/repositories/ipaaca

parents 873934e7 922f3458
No related branches found
No related tags found
No related merge requests found
Showing
with 3891 additions and 45 deletions
.DS_Store .DS_Store
generatedsrc generatedsrc
build build
docs docs/doxygen_generated
lib lib
test/lib test/lib
report report
......
doxygen_generated
.*.sw?
This diff is collapsed.
File moved
File moved
...@@ -3,63 +3,127 @@ cmake_minimum_required (VERSION 2.6) ...@@ -3,63 +3,127 @@ cmake_minimum_required (VERSION 2.6)
# project name # project name
project (ipaaca_cpp) project (ipaaca_cpp)
# use C++11 (starting with proto v2 / ipaaca-c++ release 12)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
## use the following line to enable console debug messages in ipaaca ## use the following line to enable console debug messages in ipaaca
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
# expose the full RSB api in the headers (set only in ipaaca itself) # expose the full RSB api in the headers (set only in ipaaca itself)
# !! NOTE: at the moment required in any ipaaca cpp project in Windows !!
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_EXPOSE_FULL_RSB_API") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_EXPOSE_FULL_RSB_API")
# find cmake modules locally too # find cmake modules locally too
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
find_package(Boost COMPONENTS system filesystem thread regex REQUIRED) if(WIN32) # Check if we are on Windows
link_directories(${Boost_LIBRARY_DIRS}) if(MSVC) # Check if we are using the Visual Studio compiler
include_directories(${Boost_INCLUDE_DIRS}) #set_target_properties(TestProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
#set(BOOSTLIBS boost_regex-mt boost_date_time-mt boost_program_options-mt boost_thread-mt boost_filesystem-mt boost_signals-mt boost_system-mt) #
# Setup section for Windows build (using precompiled rsb + deps)
find_package(Protobuf REQUIRED) #
link_directories(${PROTOBUF_LIBRARY_DIRS}) # You need the rsx precompiled archive, even if you build rsb yourself,
include_directories(${PROTOBUF_INCLUDE_DIRS}) # for the dependencies. Make sure to grab the right version (bitness
# and Visual Studio version). Tested with the rsx-0.10 branch.
# Please unpack the rsx archive into the repo dir (where ipaaca also is).
# Then set these environment variables before building rsb or ipaaca:
#
# set BOOST_ROOT=%SOA_REPO_DIR%\rsx\boost
# set PROTOBUF_ROOT=%SOA_REPO_DIR%\rsx\protobuf
# set SPREAD_ROOT=%SOA_REPO_DIR%\rsx\spread
#
#
#
# If you want to compile rsb locally, check out the soa project 'rsb', build it
# and use resolve.sh to pull its libraries into this project.
# On the other hand, if you simply want to use the precompiled rsb from inside
# "rsx" (it works but has no debug info), uncomment the following four lines.
#
include_directories( ${PROJECT_SOURCE_DIR}/../../../rsx/RSC-0.11.0-win32/include/rsc0.11 )
include_directories( ${PROJECT_SOURCE_DIR}/../../../rsx/RSB-0.11.2-win32/include/rsb0.11 )
link_directories( ${PROJECT_SOURCE_DIR}/../../../rsx/RSC-0.11.0-win32/lib )
link_directories( ${PROJECT_SOURCE_DIR}/../../../rsx/RSB-0.11.2-win32/lib )
set(RSBLIBS rsc0.11 rsb0.11)
set(LIBS ${LIBS} rpcrt4)
# Using custom Protobuf script (from rsc) because it honors PROTOBUF_ROOT
find_package(ProtocolBuffers REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
find_package(Boost COMPONENTS date_time program_options system filesystem thread signals regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
# Windows linkage hack: overriding the determined libs to remove boost_thread (causes multiple-definition issues)
set(CORRECT_BOOST_LIBS "")
foreach(BLIB ${Boost_LIBRARIES})
#message(STATUS "Boost lib: ${BLIB}")
string(REGEX MATCH "boost_thread[^/]+$" drop_item ${BLIB})
if(drop_item)
message(STATUS "(Windows hack:) Removing boost_thread library from the linkage list.")
else(drop_item)
list(APPEND CORRECT_BOOST_LIBS ${BLIB})
endif(drop_item)
endforeach(BLIB ${Boost_LIBRARIES})
set(Boost_LIBRARIES ${CORRECT_BOOST_LIBS})
else()
message(SEND_ERROR "Unsupported compiler! Please build with MSVC (2010).")
endif()
else()
#
#
# Setup section for Linux or OS X (using 'rsb' soa project)
#
#
find_package(Boost COMPONENTS system filesystem thread regex signals REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
#set(BOOSTLIBS boost_regex-mt boost_date_time-mt boost_program_options-mt boost_thread-mt boost_filesystem-mt boost_signals-mt boost_system-mt)
find_package(ProtocolBuffers REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
# change for each new rsb version
if (DEFINED APPLE)
set(RSBLIBS rsc0.11 rsb0.11)
#set(RSBLIBS rsc0.10 rsb.0.10)
else(DEFINED APPLE)
set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../deps/lib/librsc0.11.so ${PROJECT_SOURCE_DIR}/../../deps/lib/librsb0.11.so )
set(LIBS ${LIBS} uuid)
endif(DEFINED APPLE)
# enhance the default search paths (headers, libs ...)
set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH})
# MacPorts compatibility
if (DEFINED APPLE)
message(STATUS "Adding extra options for building on Mac OS X")
set(CXX_DEFINES "${CXX_DEFINES} -D__MACOSX__")
link_directories( /opt/local/lib )
include_directories( /opt/local/include )
endif(DEFINED APPLE)
endif(WIN32)
##set(PROTOLIBS protobuf)
#set(RSBLIBS rsc rsbcore)
# add for for each new rsb version
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsc0.9 )
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsb0.9 )
# change for each new rsb version
if (DEFINED APPLE)
set(RSBLIBS rsc0.9 rsb.0.9)
else(DEFINED APPLE)
set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../deps/lib/librsc0.9.so ${PROJECT_SOURCE_DIR}/../../deps/lib/librsb.so.0.9 )
endif(DEFINED APPLE)
#set(LIBS ${LIBS} ${BOOSTLIBS} ${PROTOLIBS} ${RSBLIBS})
#set(LIBS ${LIBS} ${PROTOLIBS} ${RSBLIBS})
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${RSBLIBS}) set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${RSBLIBS})
if (NOT DEFINED APPLE) # Hide the rsb-induced boost-signals warning (FOR NOW)
set(LIBS ${LIBS} uuid) set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -DBOOST_SIGNALS_NO_DEPRECATION_WARNING")
endif(NOT DEFINED APPLE)
# enhance the default search paths (headers, libs ...)
set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH})
## Ace2 uses deprecated style (non-template friend functions and non-const char*s)
## We just hide the warnings here
#set(CXX_OLD_CODE_CONVENIENCE_FLAGS "-Wno-non-template-friend -Wno-write-strings")
# Compiler defines copied from the old build system # Compiler defines copied from the old build system
set(CXX_DEFINES "-D_BSD_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0") set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -D_BSD_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0")
if (DEFINED APPLE)
message(STATUS "Adding extra options for building on Mac OS X")
set(CXX_DEFINES "${CXX_DEFINES} -D__MACOSX__")
link_directories( /opt/local/lib )
include_directories( /opt/local/include )
endif(DEFINED APPLE)
# Combine the extra compiler flags # Combine the extra compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_OLD_CODE_CONVENIENCE_FLAGS} ${CXX_DEFINES}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_OLD_CODE_CONVENIENCE_FLAGS} ${IPAACA_CXX_DEFINES}")
# add for for each new rsb version
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsc0.11 )
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsb0.11 )
#include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsc0.10 )
#include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsb0.10 )
# add include dir for auto-generated headers placed in build/ # add include dir for auto-generated headers placed in build/
include_directories( ${PROJECT_SOURCE_DIR}/build ) include_directories( ${PROJECT_SOURCE_DIR}/build )
...@@ -74,17 +138,47 @@ link_directories( ${PROJECT_SOURCE_DIR}/../../deps/lib ) ...@@ -74,17 +138,47 @@ link_directories( ${PROJECT_SOURCE_DIR}/../../deps/lib )
# specify source files for ipaaca (auto-generated ones are in build/ ) # specify source files for ipaaca (auto-generated ones are in build/ )
set (SOURCE set (SOURCE
src/ipaaca.cc src/ipaaca.cc
src/ipaaca-buffers.cc
src/ipaaca-internal.cc
src/ipaaca-iuinterface.cc
src/ipaaca-ius.cc
src/ipaaca-links.cc
src/ipaaca-locking.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc src/ipaaca-string-utils.cc
src/util/notifier.cc src/util/notifier.cc
build/ipaaca/ipaaca.pb.cc build/ipaaca/ipaaca.pb.cc
) )
set (JSON_TEST_SOURCE
src/ipaaca.cc
src/ipaaca-buffers.cc
src/ipaaca-fake.cc
src/ipaaca-internal.cc
src/ipaaca-iuinterface.cc
src/ipaaca-json.cc # main
src/ipaaca-locking.cc
src/ipaaca-links.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
# more stuff going beyond the fake test case
src/ipaaca-ius.cc
build/ipaaca/ipaaca.pb.cc
)
# compile all files to "ipaaca" shared library # compile all files to "ipaaca" shared library
add_library(ipaaca SHARED ${SOURCE}) add_library(ipaaca SHARED ${SOURCE})
# and link all the required external libs (found above using find_package etc.) # and link all the required external libs (found above using find_package etc.)
target_link_libraries(ipaaca ${LIBS}) target_link_libraries(ipaaca ${LIBS})
add_executable (ipaaca-test-json ${JSON_TEST_SOURCE})
target_link_libraries (ipaaca-test-json ${LIBS})
set(DEFAULT_BIN_SUBDIR bin) set(DEFAULT_BIN_SUBDIR bin)
set(DEFAULT_LIB_SUBDIR lib) set(DEFAULT_LIB_SUBDIR lib)
set(DEFAULT_DATA_SUBDIR share/data) set(DEFAULT_DATA_SUBDIR share/data)
...@@ -98,12 +192,19 @@ install ( ...@@ -98,12 +192,19 @@ install (
) )
install( install(
DIRECTORY include DIRECTORY include
DESTINATION / DESTINATION .
FILES_MATCHING PATTERN "*.h" PATTERN "*.hh" PATTERN "*.hpp" PATTERN "*.inl" FILES_MATCHING PATTERN "*.h" PATTERN "*.hh" PATTERN "*.hpp" PATTERN "*.inl"
) )
install( install(
FILES build/ipaaca/ipaaca.pb.h FILES build/ipaaca/ipaaca.pb.h
DESTINATION /include/ipaaca/ DESTINATION include/ipaaca/
)
install (
TARGETS ipaaca-test-json
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
) )
# Locate and configure the Google Protocol Buffers library.
# A modified version of the original macro from CMake 2.8.
# Defines the following variables:
#
# PROTOBUF_FOUND - Found the Google Protocol Buffers library
# PROTOBUF_INCLUDE_DIRS - Include directories for Google Protocol Buffers
# PROTOBUF_LIBRARIES - The protobuf library
#
# The following cache variables are also defined:
# PROTOBUF_LIBRARY - The protobuf library
# PROTOBUF_PROTOC_LIBRARY - The protoc library
# PROTOBUF_INCLUDE_DIR - The include directory for protocol buffers
# PROTOBUF_PROTOC_EXECUTABLE - The protoc compiler
#
# These variables are read for additional hints:
# PROTOBUF_ROOT - Root directory of the protobuf installation if not found
# automatically
#
# ====================================================================
# Example:
#
# find_package(ProtocolBuffers REQUIRED)
# include_directories(${PROTOBUF_INCLUDE_DIRS})
#
# include_directories(${CMAKE_CURRENT_BINARY_DIR})
# PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto)
# add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
# target_link_libraries(bar ${PROTOBUF_LIBRARY})
#
# NOTE: You may need to link against pthreads, depending
# on the platform.
# ====================================================================
#
# PROTOBUF_GENERATE_CPP ([CPP srcs hdrs] [JAVA files] [PYTHON files] PROTOFILES files... [PROTOROOT root] [OUTPATH path] [EXPORT_MACRO macroName] [DEBUG])
# srcs = Variable to define with autogenerated
# source files
# hdrs = Variable to define with autogenerated
# header files
# PROTOROOT = Root under which the proto files are located. Paths starting
# from this root are used under OUTPATH as directory structure
# for the generated files. Defaults to CMAKE_CURRENT_SOURCE_DIR.
# OUTPATH = Path to store generated files under. Default is
# CMAKE_CURRENT_BINARY_DIR.
# EXPORT_MACRO = Tells protoc to generate DLL export definitions using the
# specified macro name
# DEBUG = if set, debug messages will be generated
#
# ====================================================================
#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2009 Philip Lowman <philip@yhbt.com>
# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
INCLUDE(ParseArguments)
FUNCTION(PROTOBUF_GENERATE)
# argument parsing
PARSE_ARGUMENTS(ARG "PROTOROOT;PROTOFILES;OUTPATH;INCLUDES;EXPORT_MACRO;CPP;JAVA;PYTHON;MATLAB" "DEBUG" ${ARGN})
IF(NOT ARG_PROTOFILES)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() called without any proto files")
RETURN()
ENDIF(NOT ARG_PROTOFILES)
LIST(LENGTH ARG_PROTOROOT PROTOROOT_LENGTH)
#IF(PROTOROOT_LENGTH GREATER 1)
# MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() called with too many protoroots, only one is allowed")
# RETURN()
#ENDIF()
LIST(LENGTH ARG_OUTPATH OUTPATH_LENGTH)
IF(OUTPATH_LENGTH GREATER 1)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() called with too many outpaths, only one is allowed")
RETURN()
ENDIF()
LIST(LENGTH ARG_EXPORT_MACRO EXPORT_MACRO_LENGTH)
IF(EXPORT_MACRO_LENGTH GREATER 1)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() called with too many export macro names, only one is allowed")
RETURN()
ENDIF()
# decide whether to build CPP
LIST(LENGTH ARG_CPP CPP_LENGTH)
IF(CPP_LENGTH EQUAL 0)
SET(BUILD_CPP FALSE)
ELSE()
IF(NOT CPP_LENGTH EQUAL 2)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() CPP argument expects two parameters SRC_VAR and HDR_VAR")
RETURN()
ENDIF()
SET(BUILD_CPP TRUE)
LIST(GET ARG_CPP 0 RESULT_CPP_SRCS)
LIST(GET ARG_CPP 1 RESULT_CPP_HDRS)
ENDIF()
# decide whether to build java
LIST(LENGTH ARG_JAVA JAVA_LENGTH)
IF(JAVA_LENGTH EQUAL 0)
SET(BUILD_JAVA FALSE)
ELSE()
IF(NOT JAVA_LENGTH EQUAL 1)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() JAVA argument expects one parameter JAVA_VAR")
RETURN()
ENDIF()
SET(BUILD_JAVA TRUE)
LIST(GET ARG_JAVA 0 RESULT_JAVA)
ENDIF()
# decide whether to build PYTHON
LIST(LENGTH ARG_PYTHON PYTHON_LENGTH)
IF(PYTHON_LENGTH EQUAL 0)
SET(BUILD_PYTHON FALSE)
ELSE()
IF(NOT PYTHON_LENGTH EQUAL 1)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() PYTHON argument expects one parameter PYTHON_VAR")
RETURN()
ENDIF()
SET(BUILD_PYTHON TRUE)
LIST(GET ARG_PYTHON 0 RESULT_PYTHON)
ENDIF()
# decide whether to build MATLAB
LIST(LENGTH ARG_MATLAB MATLAB_LENGTH)
IF(MATLAB_LENGTH EQUAL 0)
SET(BUILD_MATLAB FALSE)
ELSE()
IF(NOT MATLAB_LENGTH EQUAL 1)
MESSAGE(SEND_ERROR "Error: PROTOBUF_GENERATE() MATLAB argument expects one parameter MATLAB_VAR")
RETURN()
ENDIF()
SET(BUILD_MATLAB TRUE)
LIST(GET ARG_MATLAB 0 RESULT_MATLAB)
ENDIF()
# create proper export macro for CPP if desired
IF(EXPORT_MACRO_LENGTH EQUAL 1)
SET(ARG_EXPORT "dllexport_decl=${ARG_EXPORT_MACRO}:")
MESSAGE(STATUS "Enabling export macro ${ARG_EXPORT_MACRO} for CPP")
ENDIF()
SET(OUTPATH ${CMAKE_CURRENT_BINARY_DIR})
IF(OUTPATH_LENGTH EQUAL 1)
SET(OUTPATH ${ARG_OUTPATH})
ENDIF()
SET(PROTOROOTS ${CMAKE_CURRENT_SOURCE_DIR})
IF(PROTOROOT_LENGTH GREATER 0)
SET(PROTOROOTS ${ARG_PROTOROOT})
ENDIF()
SET(ARG_EXPORT "")
IF(EXPORT_MACRO_LENGTH EQUAL 1)
SET(ARG_EXPORT "dllexport_decl=${ARG_EXPORT_MACRO}:")
ENDIF()
# build command line for additional includes paths
SET(INCLUDE_CMD_LINE)
FOREACH(P ${ARG_INCLUDES})
LIST(APPEND INCLUDE_CMD_LINE "--proto_path" ${P})
ENDFOREACH()
IF(ARG_DEBUG)
MESSAGE("OUTPATH: ${OUTPATH}")
MESSAGE("PROTOROOTS: ${PROTOROOTS}")
MESSAGE("INCLUDE_CMD_LINE: ${INCLUDE_CMD_LINE}")
ENDIF()
SET(MATCHED_FILE_PATHS)
FOREACH(PROTOFILE ${ARG_PROTOFILES})
FILE(TO_CMAKE_PATH ${PROTOFILE} PROTOFILE)
# ensure that the file ends with .proto
STRING(REGEX MATCH "\\.proto$$" PROTOEND ${PROTOFILE})
IF(NOT PROTOEND)
MESSAGE(SEND_ERROR "Proto file '${PROTOFILE}' does not end with .proto")
ENDIF()
GET_FILENAME_COMPONENT(PROTO_PATH ${PROTOFILE} PATH)
GET_FILENAME_COMPONENT(ABS_FILE ${PROTOFILE} ABSOLUTE)
GET_FILENAME_COMPONENT(FILE_WE ${PROTOFILE} NAME_WE)
STRING(LENGTH ${ABS_FILE} ABS_FILE_LENGTH)
IF(ARG_DEBUG)
MESSAGE("file ${PROTOFILE}:")
MESSAGE(" PATH=${PROTO_PATH}")
MESSAGE(" ABS_FILE=${ABS_FILE}")
MESSAGE(" FILE_WE=${FILE_WE}")
MESSAGE(" PROTOROOTS=${PROTOROOTS}")
ENDIF()
# find out if the file is in one of the specified proto root
# we mimic the protoc logic here by taking the first matching proto_path
SET(MATCH_PATH)
FOREACH(ROOT ${PROTOROOTS})
IF(ARG_DEBUG)
MESSAGE(" ROOT=${ROOT}")
ENDIF()
FILE(RELATIVE_PATH REL_ABS ${ROOT} ${ABS_FILE})
STRING(LENGTH ${REL_ABS} REL_LENGTH)
IF(ARG_DEBUG)
MESSAGE(" REL_ABS=${REL_ABS}")
MESSAGE(" REL_LENGTH=${REL_LENGTH}")
ENDIF()
IF(${REL_LENGTH} GREATER 0 AND ${REL_LENGTH} LESS ${ABS_FILE_LENGTH})
# we did not need to go directories up, hence the path is shorter
# and this is a match... bad assumption but works
SET(MATCH_PATH ${REL_ABS})
SET(MATCH_ROOT ${ROOT})
IF(ARG_DEBUG)
MESSAGE(" MATCH_ROOT=${MATCH_ROOT}")
ENDIF()
BREAK()
ENDIF()
ENDFOREACH()
IF(ARG_DEBUG)
MESSAGE(" MATCH_PATH=${MATCH_PATH}")
ENDIF()
IF(NOT MATCH_PATH)
MESSAGE(SEND_ERROR "Proto file '${PROTOFILE}' is not in protoroots '${PROTOROOTS}'")
ENDIF()
LIST(APPEND MATCHED_FILE_PATHS ${ABS_FILE})
# build the result file name
FILE(RELATIVE_PATH ROOT_CLEANED_FILE ${MATCH_ROOT} ${ABS_FILE})
IF(ARG_DEBUG)
MESSAGE(" ROOT_CLEANED_FILE=${ROOT_CLEANED_FILE}")
ENDIF()
STRING(REGEX REPLACE "\\.proto$$" "" EXT_CLEANED_FILE ${ROOT_CLEANED_FILE})
IF(ARG_DEBUG)
MESSAGE(" EXT_CLEANED_FILE=${EXT_CLEANED_FILE}")
ENDIF()
SET(CPP_FILE "${OUTPATH}/${EXT_CLEANED_FILE}.pb.cc")
SET(HDR_FILE "${OUTPATH}/${EXT_CLEANED_FILE}.pb.h")
SET(PYTHON_FILE "${OUTPATH}/${EXT_CLEANED_FILE}_pb2.py")
# determine the java file name
FILE(READ ${PROTOFILE} PROTO_CONTENT)
# first the package
# TODO jwienke: ignore comments... see below TODO
SET(PACKAGE_REGEX "package[\t ]+([^;\n\r]+);")
STRING(REGEX MATCH ${PACKAGE_REGEX} PACKAGE_LINE ${PROTO_CONTENT})
IF(ARG_DEBUG)
MESSAGE(" PACKAGE_LINE=${PACKAGE_LINE}")
ENDIF()
SET(PACKAGE "")
IF(PACKAGE_LINE)
STRING(REGEX REPLACE ${PACKAGE_REGEX} "\\1" PACKAGE ${PACKAGE_LINE})
ENDIF()
STRING(REPLACE "." "/" JAVA_PACKAGE_PATH "${PACKAGE}")
IF(ARG_DEBUG)
MESSAGE(" PACKAGE=${PACKAGE}")
MESSAGE(" JAVA_PACKAGE_PATH=${JAVA_PACKAGE_PATH}")
ENDIF()
# then the java class name
# this is the default
# TODO jwienke: how to integrate that this line must not start with //?
# cmake regex are strange, because ^ and $ match beginning
# and end of file and not of each line
SET(JAVA_CLASS_REGEX "option[\t ]+java_outer_classname[\t ]+=[\t ]+\"([^\"]+)\"")
STRING(REGEX MATCH ${JAVA_CLASS_REGEX} JAVA_CLASS_LINE ${PROTO_CONTENT})
IF(ARG_DEBUG)
MESSAGE(" JAVA_CLASS_LINE=${JAVA_CLASS_LINE}")
ENDIF()
SET(JAVA_CLASS ${FILE_WE})
IF(JAVA_CLASS_LINE)
STRING(REGEX REPLACE ${JAVA_CLASS_REGEX} "\\1" JAVA_CLASS ${JAVA_CLASS_LINE})
# Now that we have the real java class name, this must be replaced
# in the original file name proposal. However, the subpath in the
# file system is also part of EXT_CLEANED_FILE. Hence, we need to
# do some replace logic again...
ENDIF()
IF(ARG_DEBUG)
MESSAGE(" JAVA_CLASS=${JAVA_CLASS}")
ENDIF()
# finally deduce the real java name
SET(JAVA_FILE "${OUTPATH}/${JAVA_PACKAGE_PATH}/${JAVA_CLASS}.java")
IF(ARG_DEBUG)
MESSAGE(" CPP_FILE=${CPP_FILE}")
MESSAGE(" HDR_FILE=${HDR_FILE}")
MESSAGE(" JAVA_FILE=${JAVA_FILE}")
MESSAGE(" PYTHON_FILE=${PYTHON_FILE}")
ENDIF()
# generate and use a list of protoroot arguments to pass to protoc
SET(ROOT_ARGS)
FOREACH(ROOT ${PROTOROOTS})
LIST(APPEND ROOT_ARGS "--proto_path" ${ROOT})
ENDFOREACH()
IF(BUILD_CPP)
LIST(APPEND CPP_SRCS "${CPP_FILE}")
LIST(APPEND CPP_HDRS "${HDR_FILE}")
ADD_CUSTOM_COMMAND(
OUTPUT "${CPP_FILE}"
"${HDR_FILE}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPATH}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS "--cpp_out=${ARG_EXPORT}${OUTPATH}" ${ROOT_ARGS} ${INCLUDE_CMD_LINE} "${ABS_FILE}"
DEPENDS ${ABS_FILE}
COMMENT "Running C++ protocol buffer compiler on ${ABS_FILE} with root ${MATCH_ROOT}, generating: ${CPP_FILE}"
VERBATIM)
ENDIF()
IF(BUILD_JAVA)
LIST(APPEND JAVA_FILES "${JAVA_FILE}")
ADD_CUSTOM_COMMAND(
OUTPUT "${JAVA_FILE}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPATH}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS "--java_out=${OUTPATH}" ${ROOT_ARGS} ${INCLUDE_CMD_LINE} "${ABS_FILE}"
DEPENDS ${ABS_FILE}
COMMENT "Running Java protocol buffer compiler on ${ABS_FILE} with root ${MATCH_ROOT}, generating: ${JAVA_FILE}"
VERBATIM)
ENDIF()
IF(BUILD_PYTHON)
LIST(APPEND PYTHON_FILES "${PYTHON_FILE}")
ADD_CUSTOM_COMMAND(
OUTPUT "${PYTHON_FILE}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPATH}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS "--python_out=${OUTPATH}" ${ROOT_ARGS} ${INCLUDE_CMD_LINE} "${ABS_FILE}"
DEPENDS ${ABS_FILE}
COMMENT "Running Python protocol buffer compiler on ${ABS_FILE} with root ${MATCH_ROOT}, generating: ${PYTHON_FILE}"
VERBATIM)
ENDIF()
ENDFOREACH()
IF(BUILD_CPP)
SET_SOURCE_FILES_PROPERTIES(${${CPP_SRCS}} ${${CPP_HDRS}} PROPERTIES GENERATED TRUE)
SET(${RESULT_CPP_SRCS} ${CPP_SRCS} PARENT_SCOPE)
SET(${RESULT_CPP_HDRS} ${CPP_HDRS} PARENT_SCOPE)
ENDIF()
IF(BUILD_JAVA)
SET_SOURCE_FILES_PROPERTIES(${${JAVA_FILES}} PROPERTIES GENERATED TRUE)
SET(${RESULT_JAVA} ${JAVA_FILES} PARENT_SCOPE)
ENDIF()
IF(BUILD_PYTHON)
SET_SOURCE_FILES_PROPERTIES(${${PYTHON_FILES}} PROPERTIES GENERATED TRUE)
SET(${RESULT_PYTHON} ${PYTHON_FILES} PARENT_SCOPE)
ENDIF()
IF(BUILD_MATLAB)
ADD_CUSTOM_COMMAND(
OUTPUT ${OUTPATH}
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPATH}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS "--matlab_out=${OUTPATH}" ${ROOT_ARGS} ${INCLUDE_CMD_LINE} ${MATCHED_FILE_PATHS}
DEPENDS ${MATCHED_FILE_PATHS}
COMMENT "Running Matlab protocol buffer compiler to generate files in ${OUTPATH}"
VERBATIM)
ENDIF()
IF(BUILD_MATLAB)
SET(${RESULT_MATLAB} ${OUTPATH} PARENT_SCOPE)
ENDIF()
ENDFUNCTION()
MACRO(PROTOBUF_GENERATE_CPP SRCS HDRS)
PROTOBUF_GENERATE(${ARGN} CPP ${SRCS} ${HDRS})
ENDMACRO()
FIND_PATH(PROTOBUF_INCLUDE_DIR NAMES google/protobuf/service.h
HINTS "${PROTOBUF_ROOT}/include"
DOC "The Google Protocol Buffers Headers")
# Google's provided vcproj files generate libraries with a "lib"
# prefix on Windows
IF(WIN32)
SET(PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
ENDIF()
FIND_LIBRARY(PROTOBUF_LIBRARY NAMES protobuf
HINTS "${PROTOBUF_ROOT}/bin"
"${PROTOBUF_ROOT}/lib"
DOC "The Google Protocol Buffers Library"
)
FIND_LIBRARY(PROTOBUF_PROTOC_LIBRARY NAMES protoc
HINTS "${PROTOBUF_ROOT}/bin"
"${PROTOBUF_ROOT}/lib"
DOC "The Google Protocol Buffers Compiler Library"
)
FIND_PROGRAM(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc
HINTS "${PROTOBUF_ROOT}/bin"
DOC "The Google Protocol Buffers Compiler"
)
IF(PROTOBUF_PROTOC_EXECUTABLE AND NOT PROTOBUF_PROTOC_MATLAB)
# check whether this protoc version supports matlab
EXECUTE_PROCESS(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} "-h"
ERROR_VARIABLE PROTOC_HELP_TEXT
OUTPUT_QUIET)
STRING(REGEX MATCH "--matlab_out" PROTOC_MATLAB_OUT "${PROTOC_HELP_TEXT}")
IF(PROTOC_MATLAB_OUT)
SET(PROTOBUF_PROTOC_MATLAB TRUE CACHE BOOL "Whether protoc is able to generate matlab output.")
MESSAGE(STATUS "protoc supports matlab")
ELSE()
SET(PROTOBUF_PROTOC_MATLAB FALSE CACHE BOOL "Whether protoc is able to generate matlab output.")
MESSAGE(STATUS "protoc does not support matlab")
ENDIF()
ENDIF()
SET(PROTOBUF_PROTOC_VERSION "PROTOBUF_PROTOC_VERSION-NOTFOUND")
IF(PROTOBUF_PROTOC_EXECUTABLE)
EXECUTE_PROCESS(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version
OUTPUT_VARIABLE PROTOBUF_PROTOC_VERSION_TEMP
RESULT_VARIABLE PROTOBUF_PROTOC_VERSION_RESULT)
STRING(REGEX REPLACE ".*([0-9]\\.[0-9]\\.[0-9]).*" "\\1"
PROTOBUF_PROTOC_VERSION_TEMP "${PROTOBUF_PROTOC_VERSION_TEMP}")
IF(PROTOBUF_PROTOC_VERSION_TEMP)
SET(PROTOBUF_PROTOC_VERSION "${PROTOBUF_PROTOC_VERSION_TEMP}")
ENDIF()
ENDIF()
SET(KNOWN_VERSIONS 2.6.0 2.5.1 2.5.0 2.4.1 2.4.0 2.3.0)
# if we know the compiler version, we should favor it
IF(PROTOBUF_PROTOC_VERSION)
LIST(INSERT KNOWN_VERSIONS 0 ${PROTOBUF_PROTOC_VERSION})
ENDIF()
SET(JAVA_NAMES ${PROTOBUF_JAVA_NAME} protobuf.jar protobuf-java.jar)
FOREACH(VERSION ${KNOWN_VERSIONS})
LIST(APPEND JAVA_NAMES "protobuf-java-${VERSION}.jar")
ENDFOREACH()
FIND_FILE(PROTOBUF_JAVA_LIBRARY
NAMES ${JAVA_NAMES}
HINTS ${PROTOBUF_JAVA_ROOT}
"${PROTOBUF_JAVA_ROOT}/share/java"
"/usr/share/java"
"/usr/share/java/protobuf-java"
"/usr/share/protobuf/lib"
"${CMAKE_INSTALL_PREFIX}/lib/java"
"${CMAKE_INSTALL_PREFIX}/share/java")
MARK_AS_ADVANCED(PROTOBUF_INCLUDE_DIR
PROTOBUF_LIBRARY
PROTOBUF_PROTOC_LIBRARY
PROTOBUF_PROTOC_EXECUTABLE
PROTOBUF_JAVA_LIBRARY
PROTOBUF_PROTOC_MATLAB)
# Restore original find library prefixes
IF(WIN32)
SET(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}")
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
IF(PROTOBUF_FOUND)
SET(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
SET(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARY})
ENDIF()
# Parse arguments passed to a function into several lists separated by
# upper-case identifiers and options that do not have an associated list e.g.:
#
# SET(arguments
# hello OPTION3 world
# LIST3 foo bar
# OPTION2
# LIST1 fuz baz
# )
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
#
# results in 7 distinct variables:
# * ARG_DEFAULT_ARGS: hello;world
# * ARG_LIST1: fuz;baz
# * ARG_LIST2:
# * ARG_LIST3: foo;bar
# * ARG_OPTION1: FALSE
# * ARG_OPTION2: TRUE
# * ARG_OPTION3: TRUE
#
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
...@@ -18,5 +18,21 @@ ...@@ -18,5 +18,21 @@
</exec> </exec>
</target> </target>
<target name="-pre-compilation" depends="-proto-yes,-proto-no" /> <target name="-pre-compilation" depends="-proto-yes,-proto-no" />
<target name="-compilation" depends="-build-setup, -pre-compilation">
<!-- echo message="Using temporary RSBProtocol_DIR=${cmake.base.dir}/rsc_tmp/share/rsbprotocol0.10" / -->
<cmake srcdir="${cmake.base.dir}"
bindir="${build.dir}"
buildtype="Debug">
<generator name="Visual Studio 10" platform="windows" buildargs="ALL_BUILD.vcxproj">
<variable name="CMAKE_INSTALL_PREFIX" type="PATH" value="../${zip.tmp.dir}" />
</generator>
<generator name="Unix Makefiles">
<variable name="CMAKE_INSTALL_PREFIX" type="PATH" value="" />
</generator>
<variable name="SPREAD_ROOT" type="FILEPATH" value="${env.SPREAD_ROOT}" />
<variable name="PROTOBUF_ROOT" type="FILEPATH" value="${env.PROTOBUF_ROOT}" />
</cmake>
</target>
</project> </project>
This diff is collapsed.
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2015 Social Cognitive Systems Group
* (formerly the Sociable Agents Group)
* CITEC, Bielefeld University
*
* http://opensource.cit-ec.de/projects/ipaaca/
* http://purl.org/net/ipaaca
*
* This file may be licensed under the terms of of the
* GNU Lesser General Public License Version 3 (the ``LGPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the LGPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the LGPL along with this
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by the
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
* The Excellence Cluster EXC 277 is a grant of the Deutsche
* Forschungsgemeinschaft (DFG) in the context of the German
* Excellence Initiative.
*/
/**
* \file ipaaca-definitions.h
*
* \brief Header file for data and exception types and helper functions.
*
* Users should not include this file directly, but use ipaaca.h
*
* \author Ramin Yaghoubzadeh (ryaghoubzadeh@uni-bielefeld.de)
* \date March, 2015
*/
#ifndef __ipaaca_definitions_h_INCLUDED__
#define __ipaaca_definitions_h_INCLUDED__
#ifndef __ipaaca_h_INCLUDED__
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
// LAST FIXME LAST
//typedef boost::shared_ptr<rapidjson::Document> JsonDocPtr;
typedef uint32_t revision_t;
/// Type of the IU event. Realized as an integer to enable bit masks for filters. One of: IU_ADDED, IU_COMMITTED, IU_DELETED, IU_RETRACTED, IU_UPDATED, IU_LINKSUPDATED, IU_MESSAGE
typedef uint32_t IUEventType;
#define IU_ADDED 1
#define IU_COMMITTED 2
#define IU_DELETED 4
#define IU_RETRACTED 8
#define IU_UPDATED 16
#define IU_LINKSUPDATED 32
#define IU_MESSAGE 64
/// Bit mask for receiving all IU events \see IUEventType
#define IU_ALL_EVENTS 127
/// Ipaaca (console) log levels
#define IPAACA_LOG_LEVEL_NONE 0
#define IPAACA_LOG_LEVEL_CRITICAL 1
#define IPAACA_LOG_LEVEL_ERROR 2
#define IPAACA_LOG_LEVEL_WARNING 3
#define IPAACA_LOG_LEVEL_INFO 4
#define IPAACA_LOG_LEVEL_DEBUG 5
/// Convert an int event type to a human-readable string
IPAACA_HEADER_EXPORT inline std::string iu_event_type_to_str(IUEventType type)
{
switch(type) {
case IU_ADDED: return "ADDED";
case IU_COMMITTED: return "COMMITTED";
case IU_DELETED: return "DELETED";
case IU_RETRACTED: return "RETRACTED";
case IU_UPDATED: return "UPDATED";
case IU_LINKSUPDATED: return "LINKSUPDATED";
case IU_MESSAGE: return "MESSAGE";
default: return "(NOT A KNOWN SINGLE IU EVENT TYPE)";
}
}
/// IU access mode: PUSH means that updates are broadcast; REMOTE means that reads are RPC calls (currently NOT implemented); MESSAGE means a fire-and-forget message
IPAACA_HEADER_EXPORT enum IUAccessMode {
IU_ACCESS_PUSH,
IU_ACCESS_REMOTE,
IU_ACCESS_MESSAGE
};
/// generate a UUID as an ASCII string
IPAACA_HEADER_EXPORT std::string generate_uuid_string();
/**
* Exception with string description
*/
IPAACA_HEADER_EXPORT class Exception: public std::exception//{{{
{
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _description;
public:
IPAACA_HEADER_EXPORT inline Exception(const std::string& description=""): _description(description) { }
IPAACA_HEADER_EXPORT inline ~Exception() throw() { }
IPAACA_HEADER_EXPORT const char* what() const throw() {
return _description.c_str();
}
};//}}}
IPAACA_HEADER_EXPORT class Abort: public std::exception//{{{
{
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _description;
public:
IPAACA_HEADER_EXPORT inline Abort(const std::string& description=""): _description(description) { }
IPAACA_HEADER_EXPORT inline ~Abort() throw() { }
IPAACA_HEADER_EXPORT const char* what() const throw() {
return _description.c_str();
}
};//}}}
/// IU was not found in a buffer
IPAACA_HEADER_EXPORT class IUNotFoundError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUNotFoundError() throw() { }
IPAACA_HEADER_EXPORT inline IUNotFoundError() { //boost::shared_ptr<IU> iu) {
_description = "IUNotFoundError";
}
};//}}}
/// IU was already published
IPAACA_HEADER_EXPORT class IUPublishedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUPublishedError() throw() { }
IPAACA_HEADER_EXPORT inline IUPublishedError() { //boost::shared_ptr<IU> iu) {
_description = "IUPublishedError";
}
};//}}}
/// IU had already been committed to
IPAACA_HEADER_EXPORT class IUCommittedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUCommittedError() throw() { }
IPAACA_HEADER_EXPORT inline IUCommittedError() { //boost::shared_ptr<IU> iu) {
_description = "IUCommittedError";
}
};//}}}
/// Remote IU update failed because it had been modified in the mean time
IPAACA_HEADER_EXPORT class IUUpdateFailedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUUpdateFailedError() throw() { }
IPAACA_HEADER_EXPORT inline IUUpdateFailedError() { //boost::shared_ptr<IU> iu) {
_description = "IUUpdateFailedError";
}
};//}}}
/// Requested resend of old IU due to malformed channel specification
IPAACA_HEADER_EXPORT class IUResendRequestFailedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUResendRequestFailedError() throw() { }
IPAACA_HEADER_EXPORT inline IUResendRequestFailedError() { //boost::shared_ptr<IU> iu) {
_description = "IUResendRequestFailedError";
}
};//}}}
/// Write operation failed because IU had been set read-only
IPAACA_HEADER_EXPORT class IUReadOnlyError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUReadOnlyError() throw() { }
IPAACA_HEADER_EXPORT inline IUReadOnlyError() { //boost::shared_ptr<IU> iu) {
_description = "IUReadOnlyError";
}
};//}}}
/// Buffer::add() failed because the IU had been previously placed in another buffer
IPAACA_HEADER_EXPORT class IUAlreadyInABufferError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUAlreadyInABufferError() throw() { }
IPAACA_HEADER_EXPORT inline IUAlreadyInABufferError() { //boost::shared_ptr<IU> iu) {
_description = "IUAlreadyInABufferError";
}
};//}}}
/// A request was made that is only valid for an already published IU
IPAACA_HEADER_EXPORT class IUUnpublishedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUUnpublishedError() throw() { }
IPAACA_HEADER_EXPORT inline IUUnpublishedError() { //boost::shared_ptr<IU> iu) {
_description = "IUUnpublishedError";
}
};//}}}
/// IU had already been allocated a UID
IPAACA_HEADER_EXPORT class IUAlreadyHasAnUIDError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUAlreadyHasAnUIDError() throw() { }
IPAACA_HEADER_EXPORT inline IUAlreadyHasAnUIDError() { //boost::shared_ptr<IU> iu) {
_description = "IUAlreadyHasAnUIDError";
}
};//}}}
/// IU had already been allocated an owner name
IPAACA_HEADER_EXPORT class IUAlreadyHasAnOwnerNameError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~IUAlreadyHasAnOwnerNameError() throw() { }
IPAACA_HEADER_EXPORT inline IUAlreadyHasAnOwnerNameError() { //boost::shared_ptr<IU> iu) {
_description = "IUAlreadyHasAnOwnerNameError";
}
};//}}}
/// UID generation failed (Windows only)
IPAACA_HEADER_EXPORT class UUIDGenerationError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~UUIDGenerationError() throw() { }
IPAACA_HEADER_EXPORT inline UUIDGenerationError() { //boost::shared_ptr<IU> iu) {
_description = "UUIDGenerationError";
}
};//}}}
/// Not implemented (e.g. invalid request parameters via backend)
IPAACA_HEADER_EXPORT class NotImplementedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~NotImplementedError() throw() { }
IPAACA_HEADER_EXPORT inline NotImplementedError() { //boost::shared_ptr<IU> iu) {
_description = "NotImplementedError";
}
};//}}}
/// PayloadEntryProxy requested type conversion failed (including lenient interpretation)
IPAACA_HEADER_EXPORT class PayloadTypeConversionError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~PayloadTypeConversionError() throw() { }
IPAACA_HEADER_EXPORT inline PayloadTypeConversionError() { //boost::shared_ptr<IU> iu) {
_description = "PayloadTypeConversionError";
}
};//}}}
/// PayloadEntryProxy was addressed as list when not a list or as map when not a map
IPAACA_HEADER_EXPORT class PayloadAddressingError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~PayloadAddressingError() throw() { }
IPAACA_HEADER_EXPORT inline PayloadAddressingError() { //boost::shared_ptr<IU> iu) {
_description = "PayloadAddressingError";
}
};//}}}
/// Malformed json was received for a Payload
IPAACA_HEADER_EXPORT class JsonParsingError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~JsonParsingError() throw() { }
IPAACA_HEADER_EXPORT inline JsonParsingError() { //boost::shared_ptr<IU> iu) {
_description = "JsonParsingError";
}
};//}}}
/// PayloadEntryProxy invalidated (unused)
IPAACA_HEADER_EXPORT class PayloadEntryProxyInvalidatedError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~PayloadEntryProxyInvalidatedError() throw() { }
IPAACA_HEADER_EXPORT inline PayloadEntryProxyInvalidatedError() { //boost::shared_ptr<IU> iu) {
_description = "PayloadEntryProxyInvalidatedError";
}
};//}}}
/// Iterator over Payload entries was invalidated by an intermediate IU update operation
IPAACA_HEADER_EXPORT class PayloadIteratorInvalidError: public Exception//{{{
{
public:
IPAACA_HEADER_EXPORT inline ~PayloadIteratorInvalidError() throw() { }
IPAACA_HEADER_EXPORT inline PayloadIteratorInvalidError() { //boost::shared_ptr<IU> iu) {
_description = "PayloadIteratorInvalidError";
}
};//}}}
/** \brief Static library initialization for backend
*
* This static class (singleton) is called once (explicitly or on-demand).
* Unless called manually, it is initialized when ipaaca is first used
* (i.e. the first Buffer is created).
*/
IPAACA_HEADER_EXPORT class Initializer
{
public:
/// Initialize the backend [DEPRECATED] (old name, use initialize_backend() instead)
[[deprecated("Use initialize_backend() instead")]]
IPAACA_HEADER_EXPORT static void initialize_ipaaca_rsb_if_needed();
/// Explicitly initialize the backend. No effect if already initialized. Automatically called during first Buffer construction.
IPAACA_HEADER_EXPORT static void initialize_backend();
IPAACA_HEADER_EXPORT static bool initialized();
IPAACA_HEADER_EXPORT static void dump_current_default_config();
protected:
IPAACA_HEADER_EXPORT static void auto_configure_rsb();
IPAACA_MEMBER_VAR_EXPORT static bool _initialized;
};
// in ipaaca-cmdline-parser.cc
// additional misc classes ( Command line options )//{{{
/** \brief Command line argument container for CommandLineParser
*
* Contains the results of argument parsing from CommandLineParser::parse()
*
* The parser is preconfigured to handle some standard options:
*
* Option | Function
* --------------------------------|------------------------------------------------------------------------------
* --help | Print list of available options
* --verbose | Set verbose flag
* --character-name <name> | Set character name (legacy)
* --component-name <name> | Set component name (legacy)
* --ipaaca-payload-type <type> | Set default ipaaca payload type (default JSON, set STR for legacy protocol)
* --ipaaca-default-channel <name> | Set default channel name (default 'default')
* --ipaaca-enable-logging <level> | Set console log level, one of NONE, DEBUG, INFO, WARNING, ERROR, CRITICAL
* --rsb-enable-logging <level> | Set rsb (transport) log level
*
*/
IPAACA_HEADER_EXPORT class CommandLineOptions {
public:
IPAACA_HEADER_EXPORT inline CommandLineOptions()
//: _unconsumed_argc(0), _unconsumed_argv(nullptr)
{ }
IPAACA_HEADER_EXPORT inline ~CommandLineOptions() {
//if (_unconsumed_argv) delete[] _unconsumed_argv;
}
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, std::string> param_opts;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, bool> param_set;
public:
IPAACA_HEADER_EXPORT void set_option(const std::string& name, bool expect, const char* optarg);
/// Get the option argument or default value (if the option expected an argument)
IPAACA_HEADER_EXPORT std::string get_param(const std::string& o);
/// Check whether option has been set
IPAACA_HEADER_EXPORT bool is_set(const std::string& o);
IPAACA_HEADER_EXPORT void dump();
public:
//IPAACA_HEADER_EXPORT inline int unconsumed_argc() { return _unconsumed_argc; }
//IPAACA_HEADER_EXPORT inline char** unconsumed_argv() { return _unconsumed_argv; }
protected:
//IPAACA_MEMBER_VAR_EXPORT int _unconsumed_argc;
//IPAACA_MEMBER_VAR_EXPORT char** _unconsumed_argv;
public:
typedef boost::shared_ptr<CommandLineOptions> ptr;
};
/**
* \brief Command line parser for ipaaca programs.
*
* The parser is preconfigured to handle some standard options:
*
* Option | Function
* --------------------------------|------------------------------------------------------------------------------
* --help | Print list of available options
* --verbose | Set verbose flag
* --character-name <name> | Set character name (legacy)
* --component-name <name> | Set component name (legacy)
* --ipaaca-payload-type <type> | Set default ipaaca payload type (default JSON, set STR for legacy protocol)
* --ipaaca-default-channel <name> | Set default channel name (default 'default')
* --ipaaca-enable-logging <level> | Set console log level, one of NONE, DEBUG, INFO, WARNING, ERROR, CRITICAL
* --rsb-enable-logging <level> | Set rsb (transport) log level
*
*/
class CommandLineParser {
protected:
IPAACA_MEMBER_VAR_EXPORT std::map<char, std::string> longopt; // letter->name
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, char> shortopt; // letter->name
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, bool> options; // name / expect_param
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, std::string> defaults; // for opt params
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, int> set_flag; // for paramless opts
protected:
IPAACA_HEADER_EXPORT CommandLineParser();
IPAACA_MEMBER_VAR_EXPORT bool library_options_handled;
IPAACA_HEADER_EXPORT bool consume_library_option(const std::string& name, bool expect, const char* optarg);
IPAACA_HEADER_EXPORT void ensure_defaults_in( CommandLineOptions::ptr clo );
public:
IPAACA_HEADER_EXPORT inline ~CommandLineParser() { }
/// Create a new parser object reference.
IPAACA_HEADER_EXPORT static inline boost::shared_ptr<CommandLineParser> create() {
return boost::shared_ptr<CommandLineParser>(new CommandLineParser());
}
IPAACA_HEADER_EXPORT void initialize_parser_defaults();
IPAACA_HEADER_EXPORT void dump_options();
/** \brief Add a user-defined option
*
* \param optname The long option name, e.g. verbose for --verbose
* \param shortn The short option (or \0 for none)
* \param expect_param Whether an argument is expected for the option
* \param defaultv The default string value (unused if expect_param is false)
*/
IPAACA_HEADER_EXPORT void add_option(const std::string& optname, char shortn, bool expect_param, const std::string& defaultv);
/** \brief Parse argument list and return result.
*
* Parse argument list (e.g. from main()) with the parser, consuming the internal options.
* The remaining options are packaged into a CommandLineOptions object.
*/
IPAACA_HEADER_EXPORT CommandLineOptions::ptr parse(int argc, char* const* argv);
typedef boost::shared_ptr<CommandLineParser> ptr;
};
//}}}
// in ipaaca-string-utils.cc
// additional misc functions ( String splitting / joining )//{{{
IPAACA_HEADER_EXPORT std::string str_trim(const std::string &s);
IPAACA_HEADER_EXPORT std::string str_join(const std::set<std::string>& set,const std::string& sep);
IPAACA_HEADER_EXPORT std::string str_join(const std::vector<std::string>& vec,const std::string& sep);
IPAACA_HEADER_EXPORT void str_split_wipe(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters );
IPAACA_HEADER_EXPORT void str_split_append(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters );
//}}}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment