Skip to content

Commit

Permalink
Add ZeroMQ XOP
Browse files Browse the repository at this point in the history
t-b committed Jul 5, 2017
0 parents commit f98539d
Showing 65 changed files with 7,612 additions and 0 deletions.
84 changes: 84 additions & 0 deletions procedures/ZeroMQ_Interop.ipf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma IgorVersion=7.0

/// @name Flags for zeromq_set()
/// @anchor ZeroMQSetFlags
/// @{
/// Sets the default flags (no debug, no ipv6, busy wait on receive)
Constant ZeroMQ_SET_FLAGS_DEFAULT = 0x1
/// Enable debug output
Constant ZeroMQ_SET_FLAGS_DEBUG = 0x2
/// Enable ipv6 support
Constant ZeroMQ_SET_FLAGS_IPV6 = 0x4
/// Don't do busy waiting on zeromq_server_recv() and zeromq_client_recv()
/// instead immediately return if no messages are available.
Constant ZeroMQ_SET_FLAGS_NOBUSYWAITRECV = 0x8
/// @}

/// @name Error codes
/// @anchor ZeroMQErrorCodes
/// @{
Constant ZeroMQ_UNKNOWN_SET_FLAG = 10003
Constant ZeroMQ_INTERNAL_ERROR = 10004
Constant ZeroMQ_INVALID_ARG = 10005
Constant ZeroMQ_HANDLER_ALREADY_RUNNING = 10006
Constant ZeroMQ_HANDLER_NO_CONNECTION = 10007
Constant ZeroMQ_MISSING_PROCEDURE_FILES = 10008
Constant ZeroMQ_INVALID_MESSAGE_FORMAT = 10009
/// @}

Constant REQ_SUCCESS = 0
Constant REQ_UNKNOWN_ERROR = 1
Constant REQ_INVALID_JSON_OBJECT = 3
Constant REQ_INVALID_VERSION = 4
Constant REQ_INVALID_OPERATION = 5
Constant REQ_INVALID_OPERATION_FORMAT = 6
Constant REQ_INVALID_MESSAGEID = 7
// error codes for CallFunction class
Constant REQ_PROC_NOT_COMPILED = 100
Constant REQ_NON_EXISTING_FUNCTION = 101
Constant REQ_TOO_FEW_FUNCTION_PARAMS = 102
Constant REQ_TOO_MANY_FUNCTION_PARAMS = 103
Constant REQ_UNSUPPORTED_FUNC_SIG = 104
Constant REQ_UNSUPPORTED_FUNC_RET = 105
Constant REQ_INVALID_PARAM_FORMAT = 106
Constant REQ_FUNCTION_ABORTED = 107

/// @name Functions which might be useful for outside callers
/// @anchor ZeroMQInterfaceFunctions
/// @{
Function ZeroMQ_WaveExists(pathToWave)
string pathToWave

WAVE/Z wv = $pathToWave

return WaveExists(wv)
End

Function/WAVE ZeroMQ_GetWave(pathToWave)
string pathToWave

WAVE/Z wv = $pathToWave

return wv
End

Function ZeroMQ_DataFolderExists(pathToDataFolder)
string pathToDataFolder

return DataFolderExists(pathToDataFolder)
End

Function/S ZeroMQ_FunctionList(matchStr)
string matchStr

return FunctionList(matchStr, ";", "")
End

Function/S ZeroMQ_FunctionInfo(functionNameStr)
string functionNameStr

return FunctionInfo(functionNameStr)
End
/// @}
67 changes: 67 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SortIncludes: false
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
...
147 changes: 147 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)

# get working XOP on MacOSX, exported symbol list??
PROJECT(ZeroMQ)

IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(bitness "")
SET(bitnessWithDash "")
SET(bitnessWithDashAndText "-64")
SET(bitnessLibFolder "x86")
SET(installFolder "${CMAKE_SOURCE_DIR}/../../../XOPs-IP7")
ELSEIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(bitness "64")
SET(bitnessWithDash "-64")
SET(bitnessWithDashAndText "-64bit")
SET(bitnessLibFolder "x64")
SET(installFolder "${CMAKE_SOURCE_DIR}/../../../XOPs-IP7-64bit")
ENDIF()

SET(libname "${PROJECT_NAME}${bitnessWithDash}")

IF(APPLE)
# use RPATH
cmake_policy(SET CMP0042 NEW)
SET(RESOURCES "${PROJECT_NAME}.r")
ELSEIF(WIN32)
SET(RESOURCES "${PROJECT_NAME}.rc")
ENDIF()

SET(SOURCES
CallFunctionOperation.cpp
CallFunctionParameterHandler.cpp
ConcurrentXOPNotice.cpp
CustomExceptions.cpp
functions.cpp
GlobalData.cpp
HelperFunctions.cpp
MessageHandler.cpp
RequestInterface.cpp
RequestInterfaceException.cpp
SerializeWave.cpp
ZeroMQ.cpp
zeromq_client_connect.cpp
zeromq_client_recv.cpp
zeromq_client_send.cpp
zeromq_server_bind.cpp
zeromq_server_recv.cpp
zeromq_server_send.cpp
zeromq_set.cpp
zeromq_handler_start.cpp
zeromq_stop.cpp
zeromq_handler_stop.cpp
zeromq_test_callfunction.cpp
zeromq_test_serializeWave.cpp)

SET(SOURCES_EXT
fmt/format.cc
fmt/ostream.cc
fmt/posix.cc)

SET(HEADERS
CallFunctionOperation.h
CallFunctionParameterHandler.h
ConcurrentQueue.h
ConcurrentXOPNotice.h
CustomExceptions.h
Errors.h
functions.h
GlobalData.h
HelperFunctions.h
IgorTypeUnion.h
MessageHandler.h
RequestInterface.h
RequestInterfaceException.h
resource.h
SerializeWave.h
SocketWithMutex.h
ZeroMQ.h)

SOURCE_GROUP("Headers" FILES ${HEADERS})
ADD_LIBRARY(${libname} SHARED ${SOURCES} ${SOURCES_EXT} ${HEADERS} ${RESOURCES})

SET_TARGET_PROPERTIES(${libname} PROPERTIES SUFFIX ".xop")

INCLUDE_DIRECTORIES(XOPSupport . "libzmq/include")

IF(APPLE)
SET_TARGET_PROPERTIES(${libname} PROPERTIES PREFIX "")

FIND_LIBRARY(CARBON_LIBRARY Carbon)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(AUDIO_UNIT AudioUnit)
FIND_LIBRARY(AUDIO_TOOLBOX AudioToolbox)
MARK_AS_ADVANCED(CARBON_LIBRARY AUDIO_TOOLBOX AUDIO_UNIT COCOA_LIBRARY)
SET(EXTRA_LIBS ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${AUDIO_TOOLBOX} ${AUDIO_UNIT})

FIND_PROGRAM(APPLE_RESOURCE Rez /Developer/Tools)
ADD_CUSTOM_COMMAND(TARGET ${libname}
POST_BUILD
COMMAND ${APPLE_RESOURCE} -i XOPSupport -F ${CARBON_LIBRARY}/.. ${RESOURCES} -o ${CMAKE_BINARY_DIR}/${libname}.xop
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

TARGET_LINK_LIBRARIES(${libname} ${EXTRA_LIBS}
${CMAKE_SOURCE_DIR}/XOPSupport/Xcode/libXOPSupport${bitness}.a
/Users/thomas/devel/libzmq/build/lib/libzmq-static.a)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D=TARGET_OS_MAC -Wno-deprecated -mmacosx-version-min=10.9")
ELSEIF(WIN32)
# CMAKE links by default to the MSVC runtime dynamically
# so we don't have to set that here

TARGET_LINK_LIBRARIES(${libname} version.lib ${EXTRA_LIBS}
${CMAKE_SOURCE_DIR}/XOPSupport/IGOR${bitness}.lib
${CMAKE_SOURCE_DIR}/XOPSupport/VC2015/XOPSupport${bitness}.lib
optimized ${CMAKE_SOURCE_DIR}/libzmq/${bitnessLibFolder}/libzmq-v140-mt-4_2_0.lib
debug ${CMAKE_SOURCE_DIR}/libzmq/${bitnessLibFolder}/libzmq-v140-mt-gd-4_2_0.lib)

# Use parallel builds
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF()
ENDIF()

# run clang-format before building
ADD_CUSTOM_COMMAND(TARGET ${libname}
PRE_BUILD
COMMAND clang-format -i ${SOURCES} ${HEADERS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running clang-format" VERBATIM)

ADD_CUSTOM_TARGET(clang-tidy
COMMAND clang-tidy -i -- ${SOURCES} -p=${CMAKE_BUILD_DIR} -checks=*
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running clang-tidy" VERBATIM)

INSTALL(TARGETS ${libname}
RUNTIME
DESTINATION ${installFolder})

INSTALL(FILES libzmq/${bitnessLibFolder}/libzmq-v140-mt-4_2_0.dll
DESTINATION ${installFolder}
CONFIGURATIONS Release)

INSTALL(FILES libzmq/${bitnessLibFolder}/libzmq-v140-mt-gd-4_2_0.dll
DESTINATION ${installFolder}
CONFIGURATIONS Debug)
Loading

0 comments on commit f98539d

Please sign in to comment.