pax_global_header00006660000000000000000000000064122364737440014526gustar00rootroot0000000000000052 comment=fc6f7381e438048032ee754aee70b8caa79a6150 zmqpp-3.2.0/000077500000000000000000000000001223647374400126775ustar00rootroot00000000000000zmqpp-3.2.0/.gitignore000066400000000000000000000000431223647374400146640ustar00rootroot00000000000000build .cproject .project .settings zmqpp-3.2.0/CHANGES.md000066400000000000000000000041441223647374400142740ustar00rootroot00000000000000Version 3.2.0 ============= * Reworked client application, this is techically breaking but its only the the client so noone should care. Multipart support that works with linux pipes is now the default. * Added a new -d detailed verbose option, the only reason it is not -vv is lack of boost option support. This provides diagnostic infomation. * Added -s to support single part messages, incase anyone actually used that. Version 3.1.0 ============= * Support for 3.2 socket disconnect and unbind. Version 3.0.0 ============= Breaking -------- * All constants are now lower_case rather the FULL_CAPITAL, this was due to defintiations conflicting with some of the values * Message class methods that read data are now marked as const. This is only potentially breaking and probably will not harm most people. Other changes ------------- * Support for 3.2 style contexts and context options * context_option::io_threads to set the number of threads required. This must be set before sockets are created to have any effect. Default 1. * context_option::max_sockets to set the maximum number of sockets allowed by this context. Default 1024. * Support for new 3.2 socket options * socket_option::delay_attach_on_connect to force connections to delay creating internal buffers until the connection to the remote endpoint. * socket_option::last_endpoint to get the last endpoint this socket was bound to. * socket_option::router_mandatory to enable routablity error checking on router sockets. * socket_option::xpub_verbose to force all subscriptions to bubble up the system rather than just new subscriptions. * socket_option::tcp_keepalive to enable tcp level keepalives, a special value of -1 is used for os default. * socket_option::tcp_keepalive_idle to force an overide of the keepalive count, often this is the retry count. * socket_option::tcp_keepalive_count to force an overide of the retry count. * socket_option::tcp_keepalive_interval to alter time between keepalives. * socket_option::tcp_accept_filter to add address based whitelist for incomming connections. zmqpp-3.2.0/LICENSE000066400000000000000000000021201223647374400136770ustar00rootroot00000000000000License: http://www.opensource.org/licenses/MIT Copyright (C) 2011 by Ben Gray Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. zmqpp-3.2.0/Makefile000066400000000000000000000123131223647374400143370ustar00rootroot00000000000000# # Instance values, command line user specifiable # CONFIG = max CPPFLAGS = CXXFLAGS = LDFLAGS = PREFIX = /usr/local BINDIR = $(DESTDIR)$(PREFIX)/bin LIBDIR = $(DESTDIR)$(PREFIX)/lib INCLUDEDIR = $(DESTDIR)$(PREFIX)/include # # Tools # CXX = g++ LD = $(CXX) AR = ar # # Build values # LIBRARY_NAME = zmqpp VERSION_MAJOR = 3 VERSION_MINOR = 2 VERSION_REVISION = 0 # # Paths # LIBRARY_DIR = $(LIBRARY_NAME) CLIENT_DIR = client TESTS_DIR = tests SRC_PATH = ./src LIBRARY_PATH = $(SRC_PATH)/$(LIBRARY_DIR) CLIENT_PATH = $(SRC_PATH)/$(CLIENT_DIR) TESTS_PATH = $(SRC_PATH)/$(TESTS_DIR) BUILD_PATH = ./build/$(CONFIG)-$(CXX) OBJECT_PATH = $(BUILD_PATH)/obj # # Core values # APP_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) APP_DATESTAMP = $(shell date '+"%Y-%m-%d %H:%M"') LIBRARY_SHARED = lib$(LIBRARY_NAME).so LIBRARY_ARCHIVE = lib$(LIBRARY_NAME).a CLIENT_TARGET = $(LIBRARY_NAME) TESTS_TARGET = $(LIBRARY_NAME)-tests CONFIG_FLAGS = ifeq ($(CONFIG),debug) CONFIG_FLAGS = -g -fno-inline -ftemplate-depth-1000 endif ifeq ($(CONFIG),valgrind) CONFIG_FLAGS = -g -O1 -DNO_DEBUG_LOG -DNO_TRACE_LOG endif ifeq ($(CONFIG),max) CONFIG_FLAGS = -O3 -funroll-loops -ffast-math -finline-functions -fomit-frame-pointer -DNDEBUG endif ifneq (,$(findstring $(CONFIG),release loadtest)) CONFIG_FLAGS = -O3 -funroll-loops -ffast-math -finline-functions -fomit-frame-pointer -DNO_DEBUG_LOG -DNO_TRACE_LOG -DNDEBUG endif COMMON_FLAGS = -MMD -std=c++0x -pipe -Wall -fPIC \ -DBUILD_ENV=$(CONFIG) \ -DBUILD_VERSION='"$(APP_VERSION)"' \ -DBUILD_VERSION_MAJOR=$(VERSION_MAJOR) \ -DBUILD_VERSION_MINOR=$(VERSION_MINOR) \ -DBUILD_VERSION_REVISION=$(VERSION_REVISION) \ -DBUILD_DATESTAMP='$(APP_DATESTAMP)' \ -DBUILD_LIBRARY_NAME='"$(LIBRARY_NAME)"' \ -DBUILD_CLIENT_NAME='"$(CLIENT_TARGET)"' \ -I$(SRC_PATH) COMMON_LIBS = -lzmq LIBRARY_LIBS = CLIENT_LIBS = -L$(BUILD_PATH) \ -l$(LIBRARY_NAME) \ -lboost_program_options TEST_LIBS = -L$(BUILD_PATH) \ -l$(LIBRARY_NAME) \ -lboost_unit_test_framework ifeq ($(CONFIG),loadtest) CONFIG_FLAGS := $(CONFIG_FLAGS) -DLOADTEST TEST_LIBS := $(TEST_LIBS) -lboost_thread -lboost_system endif ALL_LIBRARY_OBJECTS := $(patsubst $(SRC_PATH)/%.cpp, $(OBJECT_PATH)/%.o, $(shell find $(LIBRARY_PATH) -iname '*.cpp')) ALL_LIBRARY_INCLUDES := $(shell find $(LIBRARY_PATH) -iname '*.hpp') ALL_CLIENT_OBJECTS := $(patsubst $(SRC_PATH)/%.cpp, $(OBJECT_PATH)/%.o, $(shell find $(CLIENT_PATH) -iname '*.cpp')) ALL_TEST_OBJECTS := $(patsubst $(SRC_PATH)/%.cpp, $(OBJECT_PATH)/%.o, $(shell find $(TESTS_PATH) -iname '*.cpp')) TEST_SUITES := ${addprefix test-,${sort ${shell find ${TESTS_PATH} -iname *.cpp | xargs grep BOOST_AUTO_TEST_SUITE\( | sed 's/.*BOOST_AUTO_TEST_SUITE( \(.*\) )/\1/' }}} # # BUILD Targets - Standardised # .PHONY: clean uninstall test $(TEST_SUITES) main: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) @echo "use make check to test the build" all: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) $(CLIENT_TARGET) @echo "use make check to test the build" check: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) test install: install -m 644 $(ALL_LIBRARY_INCLUDES) $(INCLUDEDIR)/$(LIBRARY_DIR) install -m 755 $(BUILD_PATH)/$(LIBRARY_SHARED).$(VERSION_MAJOR) $(LIBDIR)/$(LIBRARY_SHARED).$(APP_VERSION) ln -sf $(LIBRARY_SHARED).$(APP_VERSION) $(LIBDIR)/$(LIBRARY_SHARED).$(VERSION_MAJOR) ln -sf $(LIBRARY_SHARED).$(APP_VERSION) $(LIBDIR)/$(LIBRARY_SHARED) if [ -f $(BUILD_PATH)/$(CLIENT_TARGET) ]; then install -m 755 $(BUILD_PATH)/$(CLIENT_TARGET) $(BINDIR); fi $(LDCONFIG) @echo "use make installcheck to test the install" installcheck: $(TESTS_TARGET) $(BUILD_PATH)/$(TESTS_TARGET) uninstall: rm -rf $(INCLUDEDIR)/$(LIBRARY_DIR) rm -f $(LIBDIR)/$(LIBRARY_SHARED).$(APP_VERSION) rm -f $(LIBDIR)/$(LIBRARY_SHARED).$(VERSION_MAJOR) rm -f $(LIBDIR)/$(LIBRARY_SHARED) rm -f $(BINDIR)/$(CLIENT_TARGET) clean: rm -rf $(BUILD_PATH) rm -rf docs client: $(CLIENT_TARGET) library: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) # # BUILD Targets # $(LIBRARY_SHARED): $(ALL_LIBRARY_OBJECTS) $(LD) $(LDFLAGS) -shared -rdynamic -Wl,-soname -Wl,$(LIBRARY_SHARED).$(VERSION_MAJOR) -o $(BUILD_PATH)/$@.$(VERSION_MAJOR) $^ $(LIBRARY_LIBS) $(COMMON_LIBS) $(LIBRARY_ARCHIVE): $(ALL_LIBRARY_OBJECTS) $(AR) crf $(BUILD_PATH)/$@ $^ $(CLIENT_TARGET): $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) $(ALL_CLIENT_OBJECTS) $(LD) $(LDFLAGS) -o $(BUILD_PATH)/$@ $(ALL_CLIENT_OBJECTS) $(CLIENT_LIBS) $(COMMON_LIBS) $(TESTS_TARGET): $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) $(ALL_TEST_OBJECTS) $(LD) $(LDFLAGS) -o $(BUILD_PATH)/$@ $(ALL_TEST_OBJECTS) $(TEST_LIBS) $(COMMON_LIBS) $(TEST_SUITES): $(TESTS_TARGET) LD_LIBRARY_PATH=$(BUILD_PATH):$(LD_LIBRARY_PATH) $(BUILD_PATH)/$(TESTS_TARGET) --log_level=message --run_test=$(patsubst test-%,%,$@) test: $(TESTS_TARGET) @echo "running all test targets ($(TEST_SUITES))" LD_LIBRARY_PATH=$(BUILD_PATH):$(LD_LIBRARY_PATH) $(BUILD_PATH)/$(TESTS_TARGET) # # Dependencies # We don't care if they don't exist as the object won't have been built # -include $(patsubst %.o,%.d,$(ALL_LIBRARY_OBJECTS) $(ALL_TEST_OBJECTS)) # # Object file generation # $(OBJECT_PATH)/%.o: $(SRC_PATH)/%.cpp -mkdir -p $(dir $@) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COMMON_FLAGS) $(CONFIG_FLAGS) -c -o $@ $< zmqpp-3.2.0/README.md000066400000000000000000000074321223647374400141640ustar00rootroot00000000000000Introduction ============ This C++ binding is a 'high-level' library that hides most of the c-style interface core 0mq provides. It consists of a number of header and source files all residing in the zmq directory, these files are provided under the MIT license (see LICENCE for details). They can either be included directly into any 0mq using project or used as a library. A really basic Makefile is provided for this purpose and will generate both shared and static libraries. There is a number of unittests covering the code but in no way should the tests be considered complete. Documentation ============= Most of the code is now commented with doxygen style tags, and a basic configuration file to generate them is in the root directory. To build the documentation with doxygen then use; doxygen zmqpp.doxygen.conf And the resulting html or latex docs will be in the docs/html or docs/latex directories. libzmqpp ======== There is a Makefile provided which will build, test and install the binding on a GNU Linux system. I have not tested it on anything other than Ubuntu 11.04 and Centos 5.5. The install process will only install headers and the shared object to the system. The archive will remain in the build directory. The tests for the binding (make check) require the boost unittest framework to have been installed however these do not need to be built or run to install the library. Requirements ------------ ZeroMQ 2.2.x or later C++0x compliant compiler (g++ 4.6.x, g++ 4.4.x with compatability.hpp) Installation ------------ Installation can be done by the standard make && make install. If the boost unittest framework is install check and installcheck can be run for sanity checking. make make check sudo make install make installcheck The most commonly useful overrides are setting CXX, to change the compiler used, and PREFIX to change install location. The CXX prefix should be used on all targets as the compiler version is used in the build path. PREFIX is only relevant for the install target. Debugging --------- The makefile defaults to a production ready build, however a debug version can be build by passing CONFIG=debug to the make command. In debug mode there is less optimisations and a number of sanity check assert statements. If you are not using the installed library the sanity check effect is governed by the defining of NDEBUG. zmqpp ===== The make file can also build and install a client tool called zmqpp. To build this tool add the step; make client Before the install stage. The install target will install the client to the binaries directory if it has been built. Usage ----- The client is a command line tool that can be used to listen or send to 0mq sockets. Its very basic so don't expect anything clever. zmqpp --help will list details about the five possible flags it can take; Usage: zmqpp [options] SOCKETTYPE ENDPOINT 0mq command line client tool. SOCKETTYPE is one of the supported 0mq socket types. pub, pull, push, rep, req, sub ENDPOINT is any valid 0mq endpoint. Connection Options: -b [ --bind ] arg bind to specified endpoint -c [ --connect ] arg connect to specified endpoint -m [ --multipart ] enable multipart message sending Miscellaneous Options: --version display version --help show this help page Multiple uses of -c or -b are allowed to connect or bind to multiple endpoints, if neither is specified the connect is assumed for endpoint ENDPOINT. Multipart messages are for sending only, received messages always support multiple parts. For send capable sockets entering text on standard in and pressing return will send, if multipart is enabled then the message is only sent on an empty return otherwise message parts are generated. zmqpp-3.2.0/src/000077500000000000000000000000001223647374400134665ustar00rootroot00000000000000zmqpp-3.2.0/src/client/000077500000000000000000000000001223647374400147445ustar00rootroot00000000000000zmqpp-3.2.0/src/client/main.cpp000066400000000000000000000175701223647374400164060ustar00rootroot00000000000000/* * Created on: 16 Aug 2011 * Author: @benjamg */ #include #include #include #include #include "options.hpp" #ifndef BUILD_CLIENT_NAME #define BUILD_CLIENT_NAME "zmqpp" #endif int main(int argc, char const* argv[]) { client_options const options = process_command_line( argc, argv ); if( options.show_version ) { uint8_t major, minor, patch; zmqpp::zmq_version(major, minor, patch); std::cout << BUILD_CLIENT_NAME << " version " << BUILD_VERSION << std::endl; std::cout << " built against 0mq version " << static_cast(major) << "." << static_cast(minor) << "." << static_cast(patch) << std::endl; return EXIT_FAILURE; } if( options.show_usage || options.show_help ) { show_usage( std::cout, BUILD_CLIENT_NAME ); if( options.show_help ) { std::cout << std::endl << show_help( std::cout ); } return EXIT_FAILURE; } bool can_send = false, can_recv = false, toggles = false; switch( options.type ) { case zmqpp::socket_type::push: can_send = true; break; case zmqpp::socket_type::pull: can_recv = true; break; case zmqpp::socket_type::publish: can_send = true; break; case zmqpp::socket_type::subscribe: can_recv = true; break; case zmqpp::socket_type::request: can_send = true; toggles = true; break; case zmqpp::socket_type::reply: can_recv = true, toggles = true; break; default: std::cerr << "Unsupported socket type" << std::endl; return EXIT_FAILURE; } int standardin = -1; // If we can send / toggle then we need stdin if( can_send || toggles ) { if( options.verbose ) { std::cerr << "Connecting to stdin" << std::endl; } standardin = fileno(stdin); if ( standardin < 0 ) // really? { std::cerr << "Unable to get standard input, this might be an OS thing, sorry." << std::endl; return EXIT_FAILURE; } } zmqpp::context context; zmqpp::socket socket( context, options.type ); // TODO: allow subscriptions on command line if( zmqpp::socket_type::subscribe == options.type ) { socket.subscribe( "" ); } if( !options.binds.empty() ) { for(size_t i = 0; i < options.binds.size(); ++i) { if( options.verbose ) { std::cerr << "binding to " << options.binds[i] << std::endl; } try { socket.bind( options.binds[i] ); } catch(zmqpp::zmq_internal_exception& e) { std::cerr << "failed to bind to endpoint " << options.binds[i] << ": " << e.what() << std::endl; return EXIT_FAILURE; } } } if( !options.connects.empty() ) { for(size_t i = 0; i < options.connects.size(); ++i) { if( options.verbose ) { std::cerr << "connecting to " << options.connects[i] << std::endl; } try { socket.connect( options.connects[i] ); } catch(zmqpp::zmq_internal_exception& e) { std::cerr << "failed to bind to endpoint " << options.connects[i] << ": " << e.what() << std::endl; return EXIT_FAILURE; } } } zmqpp::poller poller; poller.add(socket); if( standardin >= 0 ) { poller.add( standardin ); } if( options.verbose && ( can_send || toggles ) ) { std::cerr << "While sending packets is allowed data entered on standard in will be sent to the 0mq socket." << std::endl; if( options.singlepart ) { std::cerr << "messages will be considered terminated by newline." << std::endl; } else { std::cerr << "Message parts will be considered terminated by newline." << std::endl; std::cerr << "Messages will be considered terminated by an empty part." << std::endl; std::cerr << "The empty part itself will not be included." << std::endl; } std::cerr << std::endl; if ( toggles && !can_send ) { std::cerr << "Sending starts as disabled for this socket type." << std::endl; std::cerr << std::endl; } } if( options.detailed ) { if( standardin >= 0 ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "reading from stdin is enabled." << std::endl; } if( can_send ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "sending via socket is enabled." << std::endl; } if( can_recv ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "receiving via socket is enabled." << std::endl; } if( toggles ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "socket will flip between send/recv." << std::endl; } if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Warning - Detailed logging is enabled." << std::endl; } zmqpp::message message; while(true) { poller.check_for(socket, (can_recv) ? zmqpp::poller::poll_in : zmqpp::poller::poll_none); if( standardin >= 0 ) { poller.check_for(standardin, (can_send) ? zmqpp::poller::poll_in : zmqpp::poller::poll_none); } if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Polling for incomming message data." << std::endl; } if( poller.poll() ) { if (poller.has_input(socket)) { assert(can_recv); if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Message on socket." << std::endl; } do { std::string message; socket.receive(message); if( options.annotate ) { std::cout << "<<: "; } std::cout << message << std::endl; } while(socket.has_more_parts()); if( options.annotate ) { std::cout << " --- " << std::endl; } else { std::cout << std::endl; } if (toggles) { can_recv = false; can_send = true; if( options.detailed ) { if( options.annotate ) { std::cerr << "**: " << std::endl; } std::cerr << "Toggling to sending enabled" << std::endl; } } } if( (standardin >= 0) && poller.has_input( standardin ) ) { assert(can_send); if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Data on stdin." << std::endl; } // TODO: handle cases where we actually read a mb of data from standard in and still don't have the terminator std::array buffer; size_t length = 0; char* result = fgets( buffer.data(), buffer.size(), stdin ); if( !result ) { if( options.annotate ) { std::cerr << "!!: "; } std::cerr << "Error in standard input" << std::endl; return EXIT_FAILURE; } assert(message.parts() == 0); while( result && (length = strlen( buffer.data() ) - 1) > 0 ) // trim newline from gets { buffer[length] = 0; message.add( buffer.data(), length ); if( options.singlepart ) { break; } result = fgets(buffer.data(), buffer.size(), stdin); } if( message.parts() > 0 ) { if( options.verbose ) { for( size_t i = 0; i < message.parts(); ++i ) { if( options.annotate ) { std::cout << ">>: "; } std::cout << message.get(i) << std::endl; } if( options.annotate ) { std::cout << " --- " << std::endl; } else { std::cout << std::endl; } } if( !socket.send( message, true ) ) { if( options.annotate ) { std::cerr << "!!: "; } std::cerr << "Send failed, socket would have blocked" << std::endl; zmqpp::message tmp; std::swap( tmp, message ); } if (toggles) { can_recv = true; can_send = false; if( options.detailed ) { if( options.annotate ) { std::cerr << "**: " << std::endl; } std::cerr << "Toggling to receive enabled" << std::endl; } } } } else if( (standardin >= 0) && can_send && !can_recv ) { if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "No data on stdin, exiting reader." << std::endl; } break; } } else if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Poller returned with no data, possibly an interrupt." << std::endl; } } if( options.detailed ) { if( options.annotate ) { std::cerr << "**: "; } std::cerr << "Exited reader, shutting down." << std::endl; } return EXIT_SUCCESS; } zmqpp-3.2.0/src/client/options.cpp000066400000000000000000000115251223647374400171470ustar00rootroot00000000000000/* * options.cpp * * Created on: 6 Nov 2013 * Author: bgray */ #include #include #include #include #include #include #include "options.hpp" boost::program_options::options_description connection_options() { boost::program_options::options_description options("Connection Options"); options.add_options() ( "annotate,a", "annotate output with direction" ) ( "bind,b", boost::program_options::value>(), "bind to specified endpoint" ) ( "connect,c", boost::program_options::value>(), "connect to specified endpoint" ) ( "detailed,d", "increased level of information displayed" ) ( "exit-when-no-input,x", "don't wait for (streamed) input; exit on zero message" ) ( "ignore-zeroes,z", "deprecated option, now the default state" ) ( "multipart,m", "deprecated option, now the default state" ) ( "singlepart,s", "treat each line as a new message" ) ( "verbose,v", "display output sent over socket to stderr" ) ; return options; } boost::program_options::options_description miscellaneous_options() { boost::program_options::options_description options("Miscellaneous Options"); options.add_options() ( "version", "display version" ) ( "help", "show this help page" ) ; return options; } typedef std::map socket_type_index; socket_type_index socket_type_options() { socket_type_index socket_types = { { "push", zmqpp::socket_type::push }, { "pull", zmqpp::socket_type::pull }, { "pub", zmqpp::socket_type::publish }, { "publish", zmqpp::socket_type::publish }, { "sub", zmqpp::socket_type::subscribe }, { "subscribe", zmqpp::socket_type::subscribe }, { "req", zmqpp::socket_type::request }, { "request", zmqpp::socket_type::request }, { "rep", zmqpp::socket_type::reply }, { "reply", zmqpp::socket_type::reply } }; return socket_types; } client_options process_command_line(int argc, char const* argv[]) { boost::program_options::positional_options_description arguments; arguments.add("type", 1); arguments.add("connect", 1); boost::program_options::options_description all; all.add_options() ( "type", "0mq socket type" ) ; all.add(miscellaneous_options()); all.add(connection_options()); boost::program_options::variables_map vm; client_options options; try { boost::program_options::store( boost::program_options::command_line_parser( argc, argv ).options( all ).positional( arguments ).run(), vm ); } catch(boost::program_options::too_many_positional_options_error& e) { std::cerr << "Too many arguments provided." << std::endl; options.show_usage = true; } catch(boost::program_options::unknown_option& e) { std::cerr << "Unknown option '" << e.get_option_name() << "'." << std::endl; options.show_usage = true; } catch(boost::program_options::error& e) { std::cerr << "command line parse error: " << e.what() << "'." << std::endl; options.show_usage = true; } socket_type_index socket_types = socket_type_options(); if ( vm.count( "type" ) && ( socket_types.end() == socket_types.find( vm["type"].as() ) ) ) { std::cerr << "Unknown value '" << vm["type"].as() << "' provided for 0mq socket type." << std::endl; options.show_usage = true; } if ( (0 == vm.count( "type" )) || vm.count( "help" ) || ( (0 == vm.count( "connect" )) && (0 == vm.count( "bind" )) ) ) { options.show_usage = true; } options.show_version = ( vm.count( "version" ) > 0 ); options.show_help = ( vm.count( "help" ) > 0 ); if ( vm.count( "type" ) ) { options.type = socket_types[ vm["type"].as() ]; } if ( vm.count( "bind" ) ) { options.binds = vm["bind"].as>(); } if ( vm.count( "connect" ) ) { options.connects = vm["connect"].as>(); } options.singlepart = ( vm.count( "singlepart" ) > 0 ); options.annotate = ( vm.count( "annotate" ) > 0 ); options.verbose = ( vm.count( "verbose" ) > 0 || vm.count( "detailed" ) > 0 ); options.detailed = ( vm.count( "detailed" ) > 0 ); options.exit_on_empty = ( vm.count( "exit-when-no-input" ) > 0 ); return options; } std::ostream& show_usage(std::ostream& stream, std::string const& application_name) { stream << "Usage: " BUILD_CLIENT_NAME " [options] SOCKETTYPE ENDPOINT" << std::endl; stream << "0mq command line client tool." << std::endl; stream << "SOCKETTYPE is one of the supported 0mq socket types." << std::endl; stream << " pull, push, pub, sub, req, rep" << std::endl; stream << "ENDPOINT is any valid 0mq endpoint." << std::endl; return stream; } std::ostream& show_help(std::ostream& stream) { stream << connection_options() << std::endl; stream << miscellaneous_options() << std::endl; return stream; } zmqpp-3.2.0/src/client/options.hpp000066400000000000000000000016371223647374400171570ustar00rootroot00000000000000/* * options.hpp * * Created on: 6 Nov 2013 * Author: bgray */ #ifndef OPTIONS_HPP_ #define OPTIONS_HPP_ #include #include struct client_options { bool show_usage; bool show_help; bool show_version; bool verbose; bool detailed; bool annotate; zmqpp::socket_type type; std::vector binds; std::vector connects; bool singlepart; bool exit_on_empty; client_options() : show_usage( false ), show_help( false ), show_version( false ) , verbose( false ), detailed( false ), annotate( false ) , type( zmqpp::socket_type::pair ), binds(), connects() , singlepart( false ), exit_on_empty( false ) { } }; client_options process_command_line(int argc, char const* argv[]); std::ostream& show_usage(std::ostream& stream, std::string const& application_name); std::ostream& show_help(std::ostream& stream); #endif /* OPTIONS_HPP_ */ zmqpp-3.2.0/src/tests/000077500000000000000000000000001223647374400146305ustar00rootroot00000000000000zmqpp-3.2.0/src/tests/test_context.cpp000066400000000000000000000023731223647374400200640ustar00rootroot00000000000000/* * Created on: 9 Aug 2011 * Author: @benjamg */ #include #include "zmqpp/context.hpp" BOOST_AUTO_TEST_SUITE( context ) BOOST_AUTO_TEST_CASE( initialises ) { zmqpp::context context; BOOST_CHECK(context); } BOOST_AUTO_TEST_CASE( move_supporting ) { zmqpp::context first; BOOST_CHECK(first); zmqpp::context second( std::move(first) ); BOOST_CHECK(second); BOOST_CHECK(!first); } BOOST_AUTO_TEST_CASE( defaults ) { zmqpp::context context; BOOST_CHECK_EQUAL(context.get(zmqpp::context_option::io_threads), ZMQ_IO_THREADS_DFLT); BOOST_CHECK_EQUAL(context.get(zmqpp::context_option::max_sockets), ZMQ_MAX_SOCKETS_DFLT); } BOOST_AUTO_TEST_CASE( validaty ) { zmqpp::context context; BOOST_CHECK(context); context.terminate(); BOOST_CHECK(!context); BOOST_CHECK_THROW(context.get(zmqpp::context_option::io_threads), zmqpp::invalid_instance); } BOOST_AUTO_TEST_CASE( throws_exception ) { #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) BOOST_CHECK_THROW(new zmqpp::context(-1), zmqpp::zmq_internal_exception); #else zmqpp::context context; BOOST_CHECK_THROW(context.set(zmqpp::context_option::io_threads, -1), zmqpp::zmq_internal_exception); #endif } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_inet.cpp000066400000000000000000000015451223647374400173370ustar00rootroot00000000000000/* * Created on: 8 Aug 2011 * Author: @benjamg */ #include #include "zmqpp/inet.hpp" BOOST_AUTO_TEST_SUITE( inet ) BOOST_AUTO_TEST_CASE( swaping_64bit_byteorder ) { uint64_t host = 0x1122334455667788; uint64_t network = zmqpp::swap_if_needed(host); uint8_t* bytes = reinterpret_cast(&network); BOOST_CHECK_EQUAL(0x11, bytes[0]); BOOST_CHECK_EQUAL(0x22, bytes[1]); BOOST_CHECK_EQUAL(0x33, bytes[2]); BOOST_CHECK_EQUAL(0x44, bytes[3]); BOOST_CHECK_EQUAL(0x55, bytes[4]); BOOST_CHECK_EQUAL(0x66, bytes[5]); BOOST_CHECK_EQUAL(0x77, bytes[6]); BOOST_CHECK_EQUAL(0x88, bytes[7]); } BOOST_AUTO_TEST_CASE( swaping_64bit_reversable ) { uint64_t host = 0x1122334455667788; uint64_t network = zmqpp::swap_if_needed(host); BOOST_CHECK_EQUAL(host, zmqpp::swap_if_needed(network)); } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_load.cpp000066400000000000000000000073011223647374400173130ustar00rootroot00000000000000/* * Created on: 12 Aug 2011 * Author: @benjamg */ #ifdef LOADTEST #include #include #include #include "zmqpp/zmqpp.hpp" BOOST_AUTO_TEST_SUITE( load ) // Number of messages to push const uint64_t messages = 1e7; // Short message to send const std::string short_message = "hello world!"; // Timeout for polling in milliseconds const long max_poll_timeout = 500; BOOST_AUTO_TEST_CASE( push_messages_baseline ) { boost::timer t; void* context = zmq_init(1); void* pusher = zmq_socket(context, ZMQ_PUSH); BOOST_REQUIRE_MESSAGE(0 == zmq_connect(pusher, "tcp://localhost:5555"), "connect: " << zmq_strerror(zmq_errno())); void* puller = zmq_socket(context, ZMQ_PULL); BOOST_REQUIRE_MESSAGE(0 == zmq_bind(puller, "tcp://*:5555"), "bind: " << zmq_strerror(zmq_errno())); auto pusher_func = [messages, &pusher](void) { auto remaining = messages; do { #if (ZMQ_VERSION_MAJOR == 2) zmq_msg_t msg; zmq_msg_init_size(&msg, short_message.size()); memcpy(zmq_msg_data(&msg), short_message.data(), short_message.size()); zmq_send(pusher, &msg, 0); #else zmq_send(pusher, short_message.data(), short_message.size(), 0); #endif } while(--remaining > 0); }; zmq_pollitem_t item = { puller, 0, ZMQ_POLLIN, 0 }; boost::thread thread(pusher_func); uint64_t processed = 0; zmq_msg_t message; zmq_msg_init(&message); while(zmq_poll(&item, 1, max_poll_timeout) > 0) { BOOST_REQUIRE(item.revents & ZMQ_POLLIN); #if (ZMQ_VERSION_MAJOR == 2) zmq_recv(puller, &message, 0); #elif (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) zmq_recvmsg(puller, &message, 0); #else zmq_msg_recv(&message, puller, 0); #endif BOOST_CHECK_EQUAL(0, strncmp(short_message.data(), static_cast(zmq_msg_data(&message)), short_message.size())); ++processed; } zmq_msg_close(&message); double elapsed_run = t.elapsed(); BOOST_CHECK_MESSAGE(thread.timed_join(boost::posix_time::milliseconds(max_poll_timeout)), "hung while joining pusher thread"); BOOST_CHECK_EQUAL(processed, messages); BOOST_TEST_MESSAGE("Baseline"); BOOST_TEST_MESSAGE("Messages pushed : " << processed); BOOST_TEST_MESSAGE("Run time : " << elapsed_run << " seconds"); BOOST_TEST_MESSAGE("Messages per second: " << processed / elapsed_run); BOOST_TEST_MESSAGE("\n"); zmq_close(pusher); zmq_close(puller); zmq_term(context); } BOOST_AUTO_TEST_CASE( push_messages ) { boost::timer t; zmqpp::context context; zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("tcp://localhost:55555"); zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.bind("tcp://*:55555"); auto pusher_func = [messages, &pusher](void) { auto remaining = messages; zmqpp::message message; do { message.add(short_message); pusher.send(message); } while(--remaining > 0); }; zmqpp::poller poller; poller.add(puller); boost::thread thread(pusher_func); uint64_t processed = 0; std::string message; while(poller.poll(max_poll_timeout)) { BOOST_REQUIRE(poller.has_input(puller)); puller.receive(message); BOOST_CHECK_EQUAL(short_message, message); ++processed; } double elapsed_run = t.elapsed(); BOOST_CHECK_MESSAGE(thread.timed_join(boost::posix_time::milliseconds(max_poll_timeout)), "hung while joining pusher thread"); BOOST_CHECK_EQUAL(processed, messages); BOOST_TEST_MESSAGE("ZMQPP: Copy String"); BOOST_TEST_MESSAGE("Messages pushed : " << processed); BOOST_TEST_MESSAGE("Run time : " << elapsed_run << " seconds"); BOOST_TEST_MESSAGE("Messages per second: " << processed / elapsed_run); BOOST_TEST_MESSAGE("\n"); } BOOST_AUTO_TEST_SUITE_END() #endif // LOADTEST zmqpp-3.2.0/src/tests/test_message.cpp000066400000000000000000000115471223647374400200270ustar00rootroot00000000000000/* * Created on: 9 Aug 2011 * Author: @benjamg */ #include #include #include "zmqpp/exception.hpp" #include "zmqpp/message.hpp" BOOST_AUTO_TEST_SUITE( message ) BOOST_AUTO_TEST_CASE( initialising ) { zmqpp::message message; BOOST_CHECK_EQUAL(0, message.parts()); } BOOST_AUTO_TEST_CASE( throws_exception_reading_invalid_part ) { zmqpp::message message; BOOST_CHECK_THROW(message.get(0), zmqpp::exception); } BOOST_AUTO_TEST_CASE( move_supporting ) { zmqpp::message first; first.add("string"); BOOST_CHECK_EQUAL(1, first.parts()); zmqpp::message second( std::move(first) ); BOOST_CHECK_EQUAL(1, second.parts()); BOOST_CHECK_EQUAL(0, first.parts()); } BOOST_AUTO_TEST_CASE( copyable ) { zmqpp::message second; { zmqpp::message first; first.add("string"); BOOST_CHECK_EQUAL(1, first.parts()); second = first.copy(); } BOOST_REQUIRE_EQUAL(1, second.parts()); BOOST_CHECK_EQUAL(strlen("string"), second.size(0)); BOOST_CHECK_EQUAL("string", second.get(0)); } #ifndef ZMQPP_IGNORE_LAMBDA_FUNCTION_TESTS BOOST_AUTO_TEST_CASE( move_part ) { bool called = false; size_t data_size = 5; void* data = malloc(data_size); memset(data, 0, data_size); memcpy(data, "tests", strlen("tests")); auto release_func = [data, &called](void* val) { BOOST_CHECK_EQUAL(val, data); free(val); called = true; }; zmqpp::message* msg = new zmqpp::message(); msg->move(data, data_size, release_func); BOOST_REQUIRE_EQUAL(1, msg->parts()); BOOST_CHECK_EQUAL(strlen("tests"), msg->size(0)); BOOST_CHECK_EQUAL("tests", msg->get(0)); delete msg; BOOST_CHECK(called); } #endif BOOST_AUTO_TEST_CASE( copy_part ) { size_t data_size = strlen("tests"); void* data = malloc(data_size); memset(data, 0, data_size); memcpy(data, "tests", data_size); zmqpp::message* msg = new zmqpp::message(); msg->add(data, data_size); BOOST_REQUIRE_EQUAL(1, msg->parts()); BOOST_CHECK_EQUAL(strlen("tests"), msg->size(0)); BOOST_CHECK_EQUAL("tests", msg->get(0)); delete msg; BOOST_CHECK_EQUAL("tests", std::string(static_cast(data), data_size)); free(data); } BOOST_AUTO_TEST_CASE( copy_part_string ) { zmqpp::message* msg = new zmqpp::message(); std::string part("tests"); msg->add(part); BOOST_REQUIRE_EQUAL(1, msg->parts()); BOOST_CHECK_EQUAL(strlen("tests"), msg->size(0)); BOOST_CHECK_EQUAL("tests", msg->get(0)); delete msg; BOOST_CHECK_EQUAL("tests", part); } BOOST_AUTO_TEST_CASE( multi_part_message ) { zmqpp::message message; message.add("this is the first part"); message.add("some other content here"); message.add("and finally"); BOOST_REQUIRE_EQUAL(3, message.parts()); BOOST_CHECK_EQUAL(strlen("this is the first part"), message.size(0)); BOOST_CHECK_EQUAL("this is the first part", message.get(0)); BOOST_CHECK_EQUAL(strlen("some other content here"), message.size(1)); BOOST_CHECK_EQUAL("some other content here", message.get(1)); BOOST_CHECK_EQUAL(strlen("and finally"), message.size(2)); BOOST_CHECK_EQUAL("and finally", message.get(2)); } BOOST_AUTO_TEST_CASE( stream_throws_exception ) { zmqpp::message message; std::string part; BOOST_CHECK_THROW(message >> part, zmqpp::exception); } BOOST_AUTO_TEST_CASE( stream_output_string ) { zmqpp::message message; message.add("part"); std::string part; message >> part; BOOST_CHECK_EQUAL("part", part); } BOOST_AUTO_TEST_CASE( stream_copy_input_c_string ) { zmqpp::message message; message << "test part"; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(strlen("test part"), message.size(0)); BOOST_CHECK_EQUAL("test part", message.get(0)); } BOOST_AUTO_TEST_CASE( stream_copy_input_string ) { const std::string part("test part"); zmqpp::message message; message << part; BOOST_CHECK_EQUAL("test part", part); BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(strlen("test part"), message.size(0)); BOOST_CHECK_EQUAL("test part", message.get(0)); } BOOST_AUTO_TEST_CASE( stream_multiple_parts ) { zmqpp::message message; message << "test part"; message << 42; BOOST_REQUIRE_EQUAL(2, message.parts()); std::string part1; uint32_t part2; message >> part1; message >> part2; BOOST_CHECK_EQUAL("test part", part1); BOOST_CHECK_EQUAL(42, part2); } BOOST_AUTO_TEST_CASE( output_stream_resetable ) { zmqpp::message message; message << "test part"; std::string first; message >> first; BOOST_CHECK_EQUAL("test part", first); message.reset_read_cursor(); std::string second; message >> second; BOOST_CHECK_EQUAL("test part", second); } #ifdef ZMQPP_NON_CONST_STREAM_OPERATORS_MOVE BOOST_AUTO_TEST_CASE( stream_move_input_string ) { std::string part("test part"); zmqpp::message message; message << part; BOOST_CHECK_EQUAL("", part); BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(strlen("test part"), message.size(0)); BOOST_CHECK_EQUAL("test part", message.get(0)); } #endif BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_message_stream.cpp000066400000000000000000000107701223647374400213770ustar00rootroot00000000000000/* * Created on: 10 Aug 2011 * Author: @benjmag */ #include #include "zmqpp/message.hpp" BOOST_AUTO_TEST_SUITE( message_stream ) BOOST_AUTO_TEST_CASE( stream_bool ) { bool input_value = true; bool output_value = false; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(1, message.size(0)); unsigned char const* data = static_cast(message.raw_data(0)); BOOST_CHECK_EQUAL(1, data[0]); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_float ) { float input_value = 3.14f; float output_value = 0.0f; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(sizeof(input_value), message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_double ) { double input_value = 3.14; double output_value = 0.0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(sizeof(input_value), message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_int8 ) { int8_t input_value = -42; int8_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(1, message.size(0)); unsigned char const* data = static_cast(message.raw_data(0)); BOOST_CHECK_EQUAL(0xD6, data[0]); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_int16 ) { int16_t input_value = 512; int16_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(2, message.size(0)); unsigned char const* data = static_cast(message.raw_data(0)); BOOST_CHECK_EQUAL(0x02, data[0]); BOOST_CHECK_EQUAL(0x00, data[1]); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_int32 ) { int32_t input_value = -19088744; //0xfedcba98 int32_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(4, message.size(0)); unsigned char const* data = static_cast(message.raw_data(0)); BOOST_CHECK_EQUAL(0xFE, data[0]); BOOST_CHECK_EQUAL(0xDC, data[1]); BOOST_CHECK_EQUAL(0xBA, data[2]); BOOST_CHECK_EQUAL(0x98, data[3]); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_int64 ) { int64_t input_value = 1234; int64_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(8, message.size(0)); unsigned char const* data = static_cast(message.raw_data(0)); BOOST_CHECK_EQUAL(0x00, data[0]); BOOST_CHECK_EQUAL(0x00, data[1]); BOOST_CHECK_EQUAL(0x00, data[2]); BOOST_CHECK_EQUAL(0x00, data[3]); BOOST_CHECK_EQUAL(0x00, data[4]); BOOST_CHECK_EQUAL(0x00, data[5]); BOOST_CHECK_EQUAL(0x04, data[6]); BOOST_CHECK_EQUAL(0xD2, data[7]); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_uint8 ) { uint8_t input_value = 1; uint8_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(1, message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_uint16 ) { uint16_t input_value = 12; uint16_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(2, message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_uint32 ) { uint32_t input_value = 123; uint32_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(4, message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_CASE( stream_uint64 ) { uint64_t input_value = 1234; uint64_t output_value = 0; zmqpp::message message; message << input_value; BOOST_REQUIRE_EQUAL(1, message.parts()); BOOST_CHECK_EQUAL(8, message.size(0)); message >> output_value; BOOST_CHECK_EQUAL(input_value, output_value); } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_poller.cpp000066400000000000000000000126141223647374400176740ustar00rootroot00000000000000/* * Created on: 12 Aug 2011 * Author: @benjamg */ #include #include "zmqpp/context.hpp" #include "zmqpp/message.hpp" #include "zmqpp/poller.hpp" #include "zmqpp/socket.hpp" BOOST_AUTO_TEST_SUITE( poll ) const int max_poll_timeout = 100; BOOST_AUTO_TEST_CASE( initialise ) { zmqpp::context context; zmqpp::socket socket(context, zmqpp::socket_type::pull); socket.bind("inproc://test"); zmqpp::poller poller; poller.add(socket); BOOST_CHECK_EQUAL(zmqpp::poller::poll_none, poller.events(socket)); BOOST_CHECK(!poller.has_input(socket)); BOOST_CHECK(!poller.has_output(socket)); BOOST_CHECK(!poller.has_error(socket)); } BOOST_AUTO_TEST_CASE( simple_pull_push ) { zmqpp::context context; zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.bind("inproc://test"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test"); BOOST_CHECK(pusher.send_raw("hello world!", sizeof("hello world!"))); zmqpp::poller poller; poller.add(puller); BOOST_CHECK(poller.poll(max_poll_timeout)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_in, poller.events(puller)); BOOST_CHECK(poller.has_input(puller)); std::string message; BOOST_CHECK(puller.receive(message)); BOOST_CHECK_EQUAL("hello world!", message.c_str()); BOOST_CHECK(!puller.has_more_parts()); } BOOST_AUTO_TEST_CASE( multi_socket_poll ) { zmqpp::context context; zmqpp::socket puller1(context, zmqpp::socket_type::pull); puller1.bind("inproc://test1"); zmqpp::socket puller2(context, zmqpp::socket_type::pull); puller2.bind("inproc://test2"); zmqpp::socket puller3(context, zmqpp::socket_type::pull); puller3.bind("inproc://test3"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test1"); BOOST_CHECK(pusher.send("hello world!")); zmqpp::poller poller; poller.add(puller1); poller.add(puller2); poller.add(puller3); BOOST_CHECK(poller.poll(max_poll_timeout)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_in, poller.events(puller1)); BOOST_CHECK(poller.has_input(puller1)); BOOST_CHECK(!poller.has_output(puller1)); BOOST_CHECK(!poller.has_error(puller1)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_none, poller.events(puller2)); BOOST_CHECK(!poller.has_input(puller2)); BOOST_CHECK(!poller.has_output(puller2)); BOOST_CHECK(!poller.has_error(puller2)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_none, poller.events(puller3)); BOOST_CHECK(!poller.has_input(puller3)); BOOST_CHECK(!poller.has_output(puller3)); BOOST_CHECK(!poller.has_error(puller3)); std::string message; BOOST_CHECK(puller1.receive(message)); BOOST_CHECK_EQUAL("hello world!", message); BOOST_CHECK(!puller1.has_more_parts()); } BOOST_AUTO_TEST_CASE( throws_exception_unknown_socket ) { zmqpp::context context; zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.bind("inproc://test"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test"); zmqpp::poller poller; poller.add(puller); BOOST_CHECK_THROW(poller.events(pusher), zmqpp::exception); } BOOST_AUTO_TEST_CASE( ignores_removed_sockets ) { zmqpp::context context; zmqpp::socket puller1(context, zmqpp::socket_type::pull); puller1.bind("inproc://test1"); zmqpp::socket puller2(context, zmqpp::socket_type::pull); puller2.bind("inproc://test2"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test1"); BOOST_CHECK(pusher.send("hello world!")); zmqpp::poller poller; poller.add(puller1); poller.add(puller2); poller.remove(puller1); BOOST_CHECK(!poller.poll(max_poll_timeout)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_none, poller.events(puller2)); BOOST_CHECK(!poller.has_input(puller2)); BOOST_CHECK(!poller.has_output(puller2)); BOOST_CHECK(!poller.has_error(puller2)); std::string message; BOOST_CHECK(puller1.receive(message)); BOOST_CHECK_EQUAL("hello world!", message); BOOST_CHECK(!puller1.has_more_parts()); } BOOST_AUTO_TEST_CASE( remove_maintains_index ) { zmqpp::context context; zmqpp::socket puller1(context, zmqpp::socket_type::pull); puller1.bind("inproc://test1"); zmqpp::socket puller2(context, zmqpp::socket_type::pull); puller2.bind("inproc://test2"); zmqpp::socket puller3(context, zmqpp::socket_type::pull); puller3.bind("inproc://test3"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test1"); BOOST_CHECK(pusher.send("hello world!")); zmqpp::poller poller; poller.add(puller1); poller.add(puller2); poller.add(puller3); poller.remove(puller1); // removing last puller will die if index has not been updated poller.remove(puller3); BOOST_CHECK(!poller.poll(max_poll_timeout)); BOOST_CHECK_EQUAL(zmqpp::poller::poll_none, poller.events(puller2)); BOOST_CHECK(!poller.has_input(puller2)); BOOST_CHECK(!poller.has_output(puller2)); BOOST_CHECK(!poller.has_error(puller2)); std::string message; BOOST_CHECK(puller1.receive(message)); BOOST_CHECK_EQUAL("hello world!", message); BOOST_CHECK(!puller1.has_more_parts()); } BOOST_AUTO_TEST_CASE( exceptions_testing_removed_sockets ) { zmqpp::context context; zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.bind("inproc://test1"); zmqpp::poller poller; // Has no events when added poller.add(pusher); BOOST_CHECK(!poller.events(pusher)); // Exception after removed poller.remove(pusher); BOOST_CHECK_THROW(poller.events(pusher), zmqpp::exception); } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_sanity.cpp000066400000000000000000000055051223647374400177070ustar00rootroot00000000000000/* * Created on: 8 Aug 2011 * Author: @benjamg */ // Module definition should only be in one of the tests #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE zmqpp #include #include #include #include #include const int max_poll_timeout = 100; BOOST_AUTO_TEST_SUITE( sanity ) BOOST_AUTO_TEST_CASE( correct_zmq_version ) { int major, minor, patch; zmq_version(&major, &minor, &patch); BOOST_CHECK_LE( ZMQPP_REQUIRED_ZMQ_MAJOR, major ); if(ZMQPP_REQUIRED_ZMQ_MAJOR == major) { BOOST_CHECK_LE( ZMQPP_REQUIRED_ZMQ_MINOR, minor ); } } BOOST_AUTO_TEST_CASE( correct_zmqpp_version ) { uint8_t major, minor, patch; zmqpp::version(major, minor, patch); BOOST_CHECK_EQUAL( BUILD_VERSION_MAJOR, major ); BOOST_CHECK_EQUAL( BUILD_VERSION_MINOR, minor ); BOOST_CHECK_EQUAL( BUILD_VERSION_REVISION, patch ); BOOST_CHECK_EQUAL( BUILD_VERSION, zmqpp::version() ); } BOOST_AUTO_TEST_CASE( same_zmq_version_as_built_against ) { uint8_t major, minor, patch; zmqpp::zmq_version(major, minor, patch); BOOST_CHECK_EQUAL( ZMQ_VERSION_MAJOR, major ); BOOST_CHECK_EQUAL( ZMQ_VERSION_MINOR, minor ); BOOST_CHECK_EQUAL( ZMQ_VERSION_PATCH, patch ); } BOOST_AUTO_TEST_CASE( zmq_basic_push_pull ) { std::string data = "hello world!"; void* context = zmq_init(1); void* puller = zmq_socket(context, ZMQ_PULL); zmq_bind(puller, "inproc://test"); void* pusher = zmq_socket(context, ZMQ_PUSH); zmq_connect(pusher, "inproc://test"); #if (ZMQ_VERSION_MAJOR == 2) zmq_msg_t sent_message; zmq_msg_init_size(&sent_message, data.size()); memcpy(zmq_msg_data(&sent_message), data.data(), data.size()); BOOST_CHECK_EQUAL(0, zmq_send(pusher, &sent_message, 0)); #else BOOST_CHECK_EQUAL(data.size(), zmq_send(pusher, data.data(), data.size(), 0)); #endif zmq_pollitem_t items[] = { { puller, ZMQ_POLLIN, 0 } }; BOOST_CHECK_EQUAL(0, zmq_poll(items, 1, max_poll_timeout)); zmq_msg_t received_message; zmq_msg_init(&received_message); #if (ZMQ_VERSION_MAJOR == 2) zmq_recv(puller, &received_message, 0); BOOST_CHECK_EQUAL(static_cast(zmq_msg_data(&received_message)), data.c_str()); zmq_msg_close(&sent_message); zmq_msg_close(&received_message); #else std::array buffer; memset(buffer.data(), 0, buffer.size()); zmq_recv(puller, buffer.data(), buffer.size(), 0); BOOST_CHECK_EQUAL(buffer.data(), data.c_str()); #endif zmq_close(pusher); zmq_close(puller); zmq_term(context); } BOOST_AUTO_TEST_CASE( zmq_basic_options ) { std::string data = "hello world!"; void* context = zmq_init(1); void* socket = zmq_socket(context, ZMQ_SUB); zmq_bind(socket, "inproc://test"); int value; size_t value_size = sizeof(value); BOOST_CHECK_EQUAL(0, zmq_getsockopt(socket, ZMQ_TYPE, &value, &value_size)); BOOST_CHECK_EQUAL(ZMQ_SUB, value); } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_socket.cpp000066400000000000000000000242461223647374400176730ustar00rootroot00000000000000/* * Created on: 8 Aug 2011 * Author: @benjamg */ #include #include #include #include #include #include "zmqpp/context.hpp" #include "zmqpp/socket.hpp" #include "zmqpp/message.hpp" BOOST_AUTO_TEST_SUITE( socket ) const int bubble_poll_timeout = 1; const int max_poll_timeout = 100; void bubble_subscriptions(zmqpp::socket& socket) { zmq_pollitem_t item = { socket, 0, ZMQ_POLLIN, 0 }; int result = zmq_poll(&item, 1, bubble_poll_timeout); BOOST_REQUIRE_MESSAGE(0 == result, "polling command failed to timeout during subscription bubble"); } void wait_for_socket(zmqpp::socket& socket) { zmq_pollitem_t item = { socket, 0, ZMQ_POLLIN, 0 }; int result = zmq_poll(&item, 1, max_poll_timeout); BOOST_REQUIRE_MESSAGE(result >= 0, "polling command returned without expected value: " << zmq_strerror(zmq_errno())); BOOST_REQUIRE_MESSAGE(0 != result, "polling command returned with timeout after " << max_poll_timeout << " milliseconds"); BOOST_REQUIRE_MESSAGE(1 == result, "polling command claims " << result << " sockets have events but we only gave it one"); BOOST_REQUIRE_MESSAGE(item.revents & ZMQ_POLLIN, "events do not match expected POLLIN event: " << item.revents); } BOOST_AUTO_TEST_CASE( socket_creation ) { zmqpp::context context; zmqpp::socket socket(context, zmqpp::socket_type::pull); } BOOST_AUTO_TEST_CASE( socket_creation_bad_type ) { zmqpp::context context; BOOST_CHECK_THROW(zmqpp::socket socket(context, static_cast(-1)), zmqpp::zmq_internal_exception) } BOOST_AUTO_TEST_CASE( valid_socket ) { zmqpp::context context; zmqpp::socket socket(context, zmqpp::socket_type::pull); socket.bind("inproc://test"); zmqpp::message message; BOOST_CHECK(!socket.receive(message, true)); } BOOST_AUTO_TEST_CASE( valid_move_supporting ) { zmqpp::context context; std::unique_ptr original(new zmqpp::socket(context, zmqpp::socket_type::pull)); original->bind("inproc://test"); zmqpp::socket clone(std::move(*original)); //original.reset(); zmqpp::message message; BOOST_CHECK(!clone.receive(message, true)); } BOOST_AUTO_TEST_CASE( simple_pull_push ) { zmqpp::context context; zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.bind("inproc://test"); zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.connect("inproc://test"); BOOST_CHECK(pusher.send("hello world!")); wait_for_socket(puller); std::string message; BOOST_CHECK(puller.receive(message)); BOOST_CHECK_EQUAL("hello world!", message); BOOST_CHECK(!puller.has_more_parts()); } BOOST_AUTO_TEST_CASE( multipart_pair ) { zmqpp::context context; zmqpp::socket alpha(context, zmqpp::socket_type::pair); alpha.bind("inproc://test"); zmqpp::socket omega(context, zmqpp::socket_type::pair); omega.connect("inproc://test"); BOOST_CHECK(alpha.send("hello", zmqpp::socket::send_more)); BOOST_CHECK(alpha.send("world", zmqpp::socket::send_more)); BOOST_CHECK(alpha.send("!")); wait_for_socket(omega); std::string message; BOOST_CHECK(omega.receive(message)); BOOST_CHECK_EQUAL("hello", message); BOOST_REQUIRE(omega.has_more_parts()); BOOST_CHECK(omega.receive(message)); BOOST_CHECK_EQUAL("world", message); BOOST_REQUIRE(omega.has_more_parts()); BOOST_CHECK(omega.receive(message)); BOOST_CHECK_EQUAL("!", message); BOOST_CHECK(!omega.has_more_parts()); } BOOST_AUTO_TEST_CASE( subscribe_via_option ) { zmqpp::context context; zmqpp::socket publisher(context, zmqpp::socket_type::publish); publisher.bind("inproc://test"); zmqpp::socket subscriber(context, zmqpp::socket_type::subscribe); subscriber.connect("inproc://test"); subscriber.set(zmqpp::socket_option::subscribe, "watch1"); BOOST_CHECK(publisher.send("watch0", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents0")); BOOST_CHECK(publisher.send("watch1", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents1")); wait_for_socket(subscriber); std::string message; BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch1", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents1", message); BOOST_CHECK(!subscriber.has_more_parts()); } BOOST_AUTO_TEST_CASE( subscribe_helpers ) { zmqpp::context context; zmqpp::socket publisher(context, zmqpp::socket_type::publish); publisher.bind("inproc://test"); zmqpp::socket subscriber(context, zmqpp::socket_type::subscribe); subscriber.connect("inproc://test"); subscriber.subscribe("watch1"); subscriber.subscribe("watch2"); BOOST_CHECK(publisher.send("watch0", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents0")); BOOST_CHECK(publisher.send("watch1", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents1")); BOOST_CHECK(publisher.send("watch2", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents2")); BOOST_CHECK(publisher.send("watch3", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents3")); wait_for_socket(subscriber); std::string message; BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch1", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents1", message); BOOST_CHECK(!subscriber.has_more_parts()); wait_for_socket(subscriber); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch2", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents2", message); BOOST_CHECK(!subscriber.has_more_parts()); subscriber.unsubscribe("watch1"); bubble_subscriptions(subscriber); BOOST_CHECK(publisher.send("watch0", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents0")); BOOST_CHECK(publisher.send("watch1", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents1")); BOOST_CHECK(publisher.send("watch2", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents2")); wait_for_socket(subscriber); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch2", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents2", message); BOOST_CHECK(!subscriber.has_more_parts()); } BOOST_AUTO_TEST_CASE( subscribe_helpers_multitopic_method ) { std::list topics = { "watch1", "watch2" }; zmqpp::context context; zmqpp::socket publisher(context, zmqpp::socket_type::publish); publisher.bind("inproc://test"); zmqpp::socket subscriber(context, zmqpp::socket_type::subscribe); subscriber.connect("inproc://test"); subscriber.subscribe(topics.begin(), topics.end()); BOOST_CHECK(publisher.send("watch0", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents0")); BOOST_CHECK(publisher.send("watch1", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents1")); BOOST_CHECK(publisher.send("watch2", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents2")); BOOST_CHECK(publisher.send("watch3", zmqpp::socket::send_more)); BOOST_CHECK(publisher.send("contents3")); wait_for_socket(subscriber); std::string message; BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch1", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents1", message); BOOST_CHECK(!subscriber.has_more_parts()); wait_for_socket(subscriber); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("watch2", message); BOOST_REQUIRE(subscriber.has_more_parts()); BOOST_CHECK(subscriber.receive(message)); BOOST_CHECK_EQUAL("contents2", message); BOOST_CHECK(!subscriber.has_more_parts()); } BOOST_AUTO_TEST_CASE( sending_messages ) { zmqpp::context context; zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.bind("inproc://test"); zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.connect("inproc://test"); zmqpp::message message; std::string part("another world"); message.add("hello world!"); message.add(part); pusher.send(message); BOOST_CHECK_EQUAL(0, message.parts()); wait_for_socket(puller); BOOST_CHECK(puller.receive(part)); BOOST_CHECK_EQUAL("hello world!", part); BOOST_REQUIRE(puller.has_more_parts()); BOOST_CHECK(puller.receive(part)); BOOST_CHECK_EQUAL("another world", part); BOOST_CHECK(!puller.has_more_parts()); } BOOST_AUTO_TEST_CASE( receiving_messages ) { zmqpp::context context; zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.bind("inproc://test"); zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.connect("inproc://test"); zmqpp::message message; std::string part("another world"); message.add("hello world!"); message.add(part); pusher.send(message); BOOST_CHECK_EQUAL(0, message.parts()); wait_for_socket(puller); BOOST_CHECK(puller.receive(message)); BOOST_REQUIRE_EQUAL(2, message.parts()); BOOST_CHECK_EQUAL("hello world!", message.get(0)); BOOST_CHECK_EQUAL("another world", message.get(1)); BOOST_CHECK(!puller.has_more_parts()); } BOOST_AUTO_TEST_CASE( cleanup_safe_with_pending_data ) { zmqpp::context context; zmqpp::socket pusher(context, zmqpp::socket_type::push); pusher.bind("inproc://test"); zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.connect("inproc://test"); zmqpp::message message; std::string part("another world"); message.add("hello world!"); message.add(part); pusher.send(message); BOOST_CHECK_EQUAL(0, message.parts()); } BOOST_AUTO_TEST_CASE( multitarget_puller ) { std::vector endpoints = { "inproc://test1", "inproc://test2" }; zmqpp::context context; zmqpp::socket pusher1(context, zmqpp::socket_type::push); pusher1.bind(endpoints[0]); zmqpp::socket pusher2(context, zmqpp::socket_type::push); pusher2.bind(endpoints[1]); zmqpp::socket puller(context, zmqpp::socket_type::pull); puller.connect(endpoints.begin(), endpoints.end()); BOOST_CHECK(pusher1.send("hello world!")); BOOST_CHECK(pusher2.send("a test message")); wait_for_socket(puller); std::string message; BOOST_CHECK(puller.receive(message)); BOOST_CHECK_EQUAL("hello world!", message); BOOST_CHECK(puller.receive(message)); BOOST_CHECK_EQUAL("a test message", message); } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/tests/test_socket_options.cpp000066400000000000000000000253551223647374400214500ustar00rootroot00000000000000/* * Created on: 8 Aug 2011 * Author: @benjamg */ #include #include #include "zmqpp/context.hpp" #include "zmqpp/socket.hpp" BOOST_AUTO_TEST_SUITE( socket_options ) #define STRINGIFY(x) #x #define CHECK_SET(socket, type, option) check_set(socket, zmqpp::socket_option::option, STRINGIFY(option), false) #define CHECK_SET_POSITIVE(socket, type, option) check_set(socket, zmqpp::socket_option::option, STRINGIFY(option), true) #define CHECK_GET(socket, type, option) check_get(socket, zmqpp::socket_option::option, STRINGIFY(option)) // Note the hacky abuse of the fact we don't have float options #define CHECK_NOSET(socket, option) check_set(socket, zmqpp::socket_option::option, STRINGIFY(option), false) #define CHECK_NOGET(socket, option) check_get(socket, zmqpp::socket_option::option, STRINGIFY(option)) template void try_set(zmqpp::socket& socket, zmqpp::socket_option const& option, CheckType const& value, std::string const& option_name, std::string const& value_type) { BOOST_CHECKPOINT("setting option " << option_name << " against set type '" << value_type << "'"); try { socket.set(option, value); BOOST_CHECK_MESSAGE(typeid(CheckType) == typeid(WantedType), "expected exception setting option '" << option_name << "' against type '" << value_type << "'"); } catch(zmqpp::zmq_internal_exception const& e) { BOOST_CHECK_MESSAGE(false, "threw internal exception " << e.zmq_error() << " '" << e.what() << "' setting option '" << option_name << "' against type '" << value_type << "'"); } catch(zmqpp::exception const& e) { BOOST_CHECK_MESSAGE(typeid(CheckType) != typeid(WantedType), "threw unexpected exception '" << e.what() << "' setting option '" << option_name << "' against type '" << value_type << "'"); } } template void try_get(zmqpp::socket const& socket, zmqpp::socket_option const& option, std::string const& option_name, std::string const& value_type) { BOOST_CHECKPOINT("getting option " << option_name << " against set type '" << value_type << "'"); try { CheckType value; socket.get(option, value); BOOST_CHECK_MESSAGE(typeid(CheckType) == typeid(WantedType), "expected exception getting option " << option_name << " against type '" << value_type << "'"); } catch(zmqpp::zmq_internal_exception const& e) { BOOST_CHECK_MESSAGE(false, "threw internal exception " << e.zmq_error() << " '" << e.what() << "' getting option " << option_name << " against type '" << value_type << "'"); } catch(zmqpp::exception const& e) { BOOST_CHECK_MESSAGE(typeid(CheckType) != typeid(WantedType), "threw unexpected exception '" << e.what() << "' getting option " << option_name << " against type '" << value_type << "'"); } } template void check_set(zmqpp::socket& socket, zmqpp::socket_option const& option, std::string const& option_name, bool positive_only) { // Boolean try_set(socket, option, true, option_name, "boolean (true)"); try_set(socket, option, false, option_name, "boolean (false)"); // Integer - Masquerade of unsigned 64bit integer if (typeid(uint64_t) == typeid(Type)) { // Positive integers are valid as unsigned 64bit try_set(socket, option, -1, option_name, "signed integer (negative)"); try_set(socket, option, 42, option_name, "signed_integer (positive / masquerade)"); } else if (typeid(int64_t) == typeid(Type)) { if (positive_only) { try_set(socket, option, -1, option_name, "signed integer (negative)"); } else { try_set(socket, option, -1, option_name, "signed integer (negative / masquerade)"); } try_set(socket, option, 42, option_name, "signed integer (positive / masquerade)"); } // Integer - Masquerade of boolean else if (typeid(bool) == typeid(Type)) { // 1 and 0 Integers are valid as boolean try_set(socket, option, -1, option_name, "signed integer (negative)"); try_set(socket, option, 0, option_name, "signed integer (false / masquerade)"); try_set(socket, option, 1, option_name, "signed integer (true / masquerade)"); try_set(socket, option, 42, option_name, "signed integer (positive)"); } // Integer - Others else { if (positive_only) { try_set(socket, option, -1, option_name, "signed integer (negative / masquerade)"); } else { try_set(socket, option, -1, option_name, "signed integer (negative)"); } try_set(socket, option, 42, option_name, "signed integer (positive)"); } // Unsigned 64bit integer try_set(socket, option, 1, option_name, "unsigned 64bit integer"); #if (ZMQ_VERSION_MAJOR == 2) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) // 64bit integer try_set(socket, option, 1, option_name, "signed 64bit integer"); #endif // Strings try_set(socket, option, "test", option_name, "string"); } template void check_get(zmqpp::socket& socket, zmqpp::socket_option const& option, std::string const& option_name) { // Boolean try_get(socket, option, option_name, "boolean"); // Integer - Masquerade of boolean if (typeid(bool) == typeid(Type)) { try_get(socket, option, option_name, "signed integer (masquerade)"); } // Integer - Others else { try_get(socket, option, option_name, "signed integer"); } // Unsigned 64bit integer try_get(socket, option, option_name, "unsigned 64bit integer"); #if (ZMQ_VERSION_MAJOR == 2) // 64bit integer - Masquerade of boolean if (typeid(bool) == typeid(Type)) { try_get(socket, option, option_name, "signed 64bit integer (masquerade)"); } // 64bit integer - Others else { try_get(socket, option, option_name, "signed 64bit integer"); } #else // 64bit integer try_get(socket, option, option_name, "signed 64bit integer"); #endif // Strings try_get(socket, option, option_name, "string"); } BOOST_AUTO_TEST_CASE( set_socket_options ) { zmqpp::context context; zmqpp::socket socket(context, zmqpp::socket_type::subscribe); socket.bind("inproc://test"); CHECK_NOSET(socket, receive_more); CHECK_NOSET(socket, file_descriptor); CHECK_NOSET(socket, events); CHECK_NOSET(socket, type); #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) CHECK_NOSET(socket, last_endpoint); #endif CHECK_SET(socket, int, linger); CHECK_SET_POSITIVE(socket, int, backlog); CHECK_SET(socket, int, receive_timeout); CHECK_SET(socket, int, send_timeout); CHECK_SET(socket, uint64_t, affinity); CHECK_SET(socket, std::string, identity); CHECK_SET(socket, std::string, subscribe); CHECK_SET(socket, std::string, unsubscribe); // For some reason -1 not working here //CHECK_SET(socket, int, reconnect_interval); CHECK_SET_POSITIVE(socket, int, reconnect_interval_max); #if (ZMQ_VERSION_MAJOR > 2) CHECK_SET_POSITIVE(socket, int, send_buffer_size); CHECK_SET_POSITIVE(socket, int, receive_buffer_size); CHECK_SET_POSITIVE(socket, int, rate); CHECK_SET_POSITIVE(socket, int, recovery_interval); CHECK_SET_POSITIVE(socket, int, send_high_water_mark); CHECK_SET_POSITIVE(socket, int, receive_high_water_mark); CHECK_SET_POSITIVE(socket, int, multicast_hops); CHECK_SET_POSITIVE(socket, int64_t, max_messsage_size); #else CHECK_SET(socket, bool, multicast_loopback); CHECK_SET_POSITIVE(socket, int64_t, rate); CHECK_SET_POSITIVE(socket, int64_t, recovery_interval); CHECK_SET_POSITIVE(socket, int64_t, recovery_interval_seconds); CHECK_SET_POSITIVE(socket, int64_t, swap_size); CHECK_SET(socket, uint64_t, send_buffer_size); CHECK_SET(socket, uint64_t, receive_buffer_size); CHECK_SET(socket, uint64_t, high_water_mark); #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) CHECK_SET(socket, bool, ipv4_only); #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) CHECK_SET(socket, bool, delay_attach_on_connect); CHECK_SET(socket, bool, router_mandatory); CHECK_SET(socket, bool, xpub_verbose); // CHECK_SET(socket, int, tcp_keepalive); --- special case of boolean but with -1? CHECK_SET(socket, int, tcp_keepalive_idle); CHECK_SET(socket, int, tcp_keepalive_count); CHECK_SET(socket, int, tcp_keepalive_interval); // CHECK_SET(socket, std::string, tcp_accept_filter); --- special case required to be an address #endif #ifdef ZMQ_EXPERIMENTAL_LABELS CHECK_NOSET(socket, receive_label); #endif } BOOST_AUTO_TEST_CASE( get_socket_options ) { zmqpp::context context; zmqpp::socket socket(context, zmqpp::socket_type::subscribe); socket.bind("inproc://test"); CHECK_NOGET(socket, subscribe); CHECK_NOGET(socket, unsubscribe); #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) CHECK_NOGET(socket, router_mandatory); CHECK_NOGET(socket, xpub_verbose); CHECK_NOGET(socket, tcp_accept_filter); #endif CHECK_GET(socket, bool, receive_more); CHECK_GET(socket, int, file_descriptor); CHECK_GET(socket, int, events); CHECK_GET(socket, int, type); CHECK_GET(socket, int, linger); CHECK_GET(socket, int, backlog); CHECK_GET(socket, int, reconnect_interval); CHECK_GET(socket, int, reconnect_interval_max); CHECK_GET(socket, int, receive_timeout); CHECK_GET(socket, int, send_timeout); CHECK_GET(socket, uint64_t, affinity); CHECK_GET(socket, std::string, identity); #if (ZMQ_VERSION_MAJOR > 2) CHECK_GET(socket, int, send_buffer_size); CHECK_GET(socket, int, receive_buffer_size); CHECK_GET(socket, int, rate); CHECK_GET(socket, int, recovery_interval); CHECK_GET(socket, int, send_high_water_mark); CHECK_GET(socket, int, receive_high_water_mark); CHECK_GET(socket, int, multicast_hops); CHECK_GET(socket, int64_t, max_messsage_size); #else CHECK_GET(socket, bool, multicast_loopback); CHECK_GET(socket, int64_t, rate); CHECK_GET(socket, int64_t, recovery_interval); CHECK_GET(socket, int64_t, recovery_interval_seconds); CHECK_GET(socket, int64_t, swap_size); CHECK_GET(socket, uint64_t, send_buffer_size); CHECK_GET(socket, uint64_t, receive_buffer_size); CHECK_GET(socket, uint64_t, high_water_mark); #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) CHECK_GET(socket, bool, ipv4_only); #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) CHECK_GET(socket, std::string, last_endpoint); CHECK_GET(socket, bool, delay_attach_on_connect); CHECK_GET(socket, int, tcp_keepalive); CHECK_GET(socket, int, tcp_keepalive_idle); CHECK_GET(socket, int, tcp_keepalive_count); CHECK_GET(socket, int, tcp_keepalive_interval); #endif #ifdef ZMQ_EXPERIMENTAL_LABELS CHECK_GET(socket, bool, receive_label); #endif } BOOST_AUTO_TEST_SUITE_END() zmqpp-3.2.0/src/zmqpp/000077500000000000000000000000001223647374400146355ustar00rootroot00000000000000zmqpp-3.2.0/src/zmqpp/compatibility.hpp000066400000000000000000000044201223647374400202170ustar00rootroot00000000000000/** * \file * * \date 10 Sep 2011 * \author ron * \author Ben Gray (\@benjamg) * * A fair number of C++0x (or more accurately C++11) features are used in this * library and as this project is used where I work on older compilers this * file was created to help. * * C++ features and their workaround where not supported: * \li lambda functions - disabled, these are only used in the test anyway. * \li typesafe enums - replaced with enum where comparisons needed. * \li nullptr - defined to null. * * As of the port to version 3.1 (libzmqpp version 1.1.0) this file will also * be used to maintain compatablity with multiple versions of 0mq */ #ifndef ZMQPP_COMPATIBILITY_HPP_ #define ZMQPP_COMPATIBILITY_HPP_ #include // Currently we require at least 0mq version 2.2.x #define ZMQPP_REQUIRED_ZMQ_MAJOR 2 #define ZMQPP_REQUIRED_ZMQ_MINOR 2 #if (ZMQ_VERSION_MAJOR < ZMQPP_REQUIRED_ZMQ_MAJOR) or ((ZMQ_VERSION_MAJOR == ZMQPP_REQUIRED_ZMQ_MAJOR) and (ZMQ_VERSION_MINOR < ZMQPP_REQUIRED_ZMQ_MINOR)) #error zmqpp requires a later version of 0mq #endif // Experimental feature support #if (ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR == 0) #define ZMQ_EXPERIMENTAL_LABELS #endif // Deal with older versions of gcc #if defined(__GNUC__) and !defined(__clang__) #if __GNUC__ == 4 // Deal with older gcc not supporting C++0x typesafe enum class name {} comparison #if __GNUC_MINOR__ < 4 #define ZMQPP_COMPARABLE_ENUM enum #endif #if __GNUC_MINOR__ == 4 #if __GNUC_PATCHLEVEL__ < 1 #undef ZMQPP_COMPARABLE_ENUM #define ZMQPP_COMPARABLE_ENUM enum #endif // if __GNUC_PATCHLEVEL__ < 1 #endif // if __GNUC_MINOR__ == 4 // Deal with older gcc not supporting C++0x lambda function #if __GNUC_MINOR__ < 5 #define ZMQPP_IGNORE_LAMBDA_FUNCTION_TESTS #define ZMQPP_EXPLICITLY_DELETED #endif // if __GNUC_MINOR__ < 5 // Deal with older gcc not supporting C++0x nullptr #if __GNUC_MINOR__ < 6 #define nullptr NULL #define noexcept #endif // if __GNUC_MINOR__ < 6 #endif // if __GNUC_ == 4 #endif // if defined(__GNUC__) && !defined(__clang__) // Generic state, assume a modern compiler #ifndef ZMQPP_COMPARABLE_ENUM #define ZMQPP_COMPARABLE_ENUM enum class #endif #ifndef ZMQPP_EXPLICITLY_DELETED #define ZMQPP_EXPLICITLY_DELETED = delete #endif #endif /* ZMQPP_COMPATIBILITY_HPP_ */ zmqpp-3.2.0/src/zmqpp/context.cpp000066400000000000000000000017671223647374400170400ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #include "context.hpp" namespace zmqpp { void context::terminate() { #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_term(_context); #else int result = zmq_ctx_destroy(_context); #endif if (result != 0) { throw zmq_internal_exception(); } _context = nullptr; } #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) void context::set(context_option const& option, int const& value) { if (nullptr == _context) { throw invalid_instance("context is invalid"); } if (0 != zmq_ctx_set(_context, static_cast(option), value)) { throw zmq_internal_exception(); } } int context::get(context_option const& option) { if (nullptr == _context) { throw invalid_instance("context is invalid"); } int result = zmq_ctx_get(_context, static_cast(option)); if (result < 0) { throw zmq_internal_exception(); } return result; } #endif } zmqpp-3.2.0/src/zmqpp/context.hpp000066400000000000000000000113361223647374400170360ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_CONTEXT_HPP_ #define ZMQPP_CONTEXT_HPP_ #include #include #include "compatibility.hpp" #include "exception.hpp" #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) #include "context_options.hpp" #endif namespace zmqpp { /*! * The context class represents internal zmq context and io threads. * * By default the context class will create one thread, however this can be * overridden in the constructor. * * The context class is the only object that can be considered thread safe. * * All sockets using endpoints other than inproc require the context to have * at least one thread. * * This class is c++0x move supporting and cannot be copied. */ class context { public: #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) /*! * Initialise the 0mq context. * * If only inproc is used then the context may be created with zero threads. * Any inproc endpoint using sockets must be created using the same context. * * The context is thread safe an may be used anywhere in your application, * however there is no requirement (other than inproc restrictions) for you * to do this. * * \param threads an integer argument for the number of required threads. Defaults to 1. */ context(int const& threads = 1) #else /*! * Initialise the 0mq context. * * The context is thread safe an may be used anywhere in your application, * however there is no requirement (other than inproc restrictions) for you * to do this. */ context() #endif : _context(nullptr) { #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) _context = zmq_init(threads); #else _context = zmq_ctx_new(); #endif if (nullptr == _context) { throw zmq_internal_exception(); } } /*! * Closes the 0mq context. * * Any blocking calls other than a socket close will return with an error. * * If there are open sockets will block while zmq internal buffers are * processed up to a limit specified by that sockets linger option. */ ~context() noexcept { if (nullptr != _context) { #ifndef NDEBUG // unused assert variable in release #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_term(_context); #else int result = zmq_ctx_destroy(_context); #endif assert(0 == result); #else #if (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) zmq_term(_context); #else zmq_ctx_destroy(_context); #endif #endif // NDEBUG _context = nullptr; } } /*! * Move supporting constructor. * * Allows zero-copy move semantics to be used with this class. * * \param source a rvalue instance of the object who's internals we wish to steal. */ context(context&& source) noexcept : _context(source._context) { source._context = nullptr; } /*! * Move supporting operator. * * Allows zero-copy move semantics to be used with this class. * * \param source an rvalue instance of the context who's internals we wish to steal. */ context& operator=(context&& source) noexcept { std::swap( _context, source._context ); return *this; } /*! * Terminate the current context. * * Any blocking calls other than a socket close will return with an error. * * If there are open sockets will block while zmq internal buffers are * processed up to a limit specified by that sockets linger option. */ void terminate(); #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) /*! * Set the value of an option in the underlaying zmq context. * * \param option a valid ::context_option * \param value to set the option to */ void set(context_option const& option, int const& value); /*! * Get a context option from the underlaying zmq context. * * \param option a valid ::context_option * \return context option value */ int get(context_option const& option); #endif /*! * Validity checking of the context * * Checks if the underlying 0mq context for this instance is valid. * * Contexts should always be valid unless people are doing 'fun' things with * std::move. * * \return boolean true if the object is valid. */ operator bool() const noexcept { return nullptr != _context; } /*! * Access to the raw 0mq context * * \return void pointer to the underlying 0mq context. */ operator void*() const noexcept { return _context; } private: void* _context; // No copy - private and not implemented context(context const&) ZMQPP_EXPLICITLY_DELETED; context& operator=(context const&) noexcept ZMQPP_EXPLICITLY_DELETED; }; } #endif /* ZMQPP_CONTEXT_HPP_ */ zmqpp-3.2.0/src/zmqpp/context_options.hpp000066400000000000000000000007751223647374400206160ustar00rootroot00000000000000/** * \file * * \date 3 Jul 2013 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_CONTEXT_OPTIONS_HPP_ #define ZMQPP_CONTEXT_OPTIONS_HPP_ namespace zmqpp { /** \todo Expand the information on the options to make it actually useful. */ /*! * \brief possible Context options in zmq */ enum class context_option { io_threads = ZMQ_IO_THREADS, /*!< I/O thread count */ max_sockets = ZMQ_MAX_SOCKETS, /*!< Maximum supported sockets */ }; } #endif /* ZMQPP_CONTEXT_OPTIONS_HPP_ */ zmqpp-3.2.0/src/zmqpp/exception.hpp000066400000000000000000000032571223647374400173530ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_EXCEPTION_HPP_ #define ZMQPP_EXCEPTION_HPP_ #include #include #include namespace zmqpp { /** \todo Have a larger variety of exceptions with better state debug information */ /*! * Represents the base zmqpp exception. * * All zmqpp runtime exceptions are children of this class. * The class itself does not provide any special access fields but it only * for convince when catching exceptions. * * The class extends std::runtime_error. * */ class exception : public std::runtime_error { public: /*! * Standard exception constructor. * * \param message a string representing the error message. */ exception(std::string const& message) : std::runtime_error(message) { } }; /*! * Represents an attempt to use an invalid object. * * Objects may be invalid initially or after a shutdown or close. */ class invalid_instance : public exception { public: invalid_instance(std::string const& message) : exception(message) { } }; /*! * Represents internal zmq errors. * * Any error response from the zmq bindings will be wrapped in this error. * * The class provides access to the zmq error number via zmq_error(). */ class zmq_internal_exception : public exception { public: /*! * Uses the zmq functions to pull out error messages and numbers. */ zmq_internal_exception() : exception(zmq_strerror(zmq_errno())) , _error(zmq_errno()) { } /*! * Retrieve the zmq error number associated with this exception. * \return zmq error number */ int zmq_error() const { return _error; } private: int _error; }; } #endif /* ZMQPP_EXCEPTION_HPP_ */ zmqpp-3.2.0/src/zmqpp/inet.hpp000066400000000000000000000051101223647374400163020ustar00rootroot00000000000000/** * \file * * \date 10 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_INET_HPP_ #define ZMQPP_INET_HPP_ /** \todo cross-platform version of including headers for htons and htonl. */ // We get htons and htonl from here #include #include "compatibility.hpp" namespace zmqpp { /*! * \brief Possible byte order types. * * An enumeration of all the known order types, all two of them. * There is also an entry for unknown which is just used as a default. */ ZMQPP_COMPARABLE_ENUM order { unknown, /*!< used as a default prior to detection of the the byte order */ big_endian, /*!< brief byte order is big endian */ little_endian /*!< \brief byte order is little endian */ }; /*! * Common code for the 64bit versions of htons/htons and ntohs/ntohl * * As htons and ntohs (or htonl and ntohs) always just do the same thing, ie * swap bytes if the host order differs from network order or otherwise don't * do anything, it seemed silly to type the code twice. * * \note This code assumes network order is always big endian. Which it is. * \note The host endian is only checked once and afterwards assumed to remain * the same. * * \param value_to_check unsigned 64 bit integer to swap * \return swapped (or not) unsigned 64 bit integer */ inline uint64_t swap_if_needed(uint64_t const& value_to_check) { static order host_order = order::unknown; union { uint64_t integer; uint8_t bytes[8]; } value; if (order::unknown == host_order) { value.integer = 1; host_order = (1 == value.bytes[0]) ? order::little_endian : order::big_endian; } if (order::big_endian == host_order) { return value_to_check; } value.integer = value_to_check; std::swap(value.bytes[0], value.bytes[7]); std::swap(value.bytes[1], value.bytes[6]); std::swap(value.bytes[2], value.bytes[5]); std::swap(value.bytes[3], value.bytes[4]); return value.integer; } } /*! * 64 bit version of the htons/htonl * * I've used the name htonll to try and keep with the htonl naming scheme. * * \param hostlonglong unsigned 64 bit host order integer * \return unsigned 64 bit network order integer */ inline uint64_t htonll(uint64_t const& hostlonglong) { return zmqpp::swap_if_needed(hostlonglong); } /*! * 64 bit version of the ntohs/ntohl * * I've used the name htonll to try and keep with the htonl naming scheme. * * \param networklonglong unsigned 64 bit network order integer * \return unsigned 64 bit host order integer */ inline uint64_t ntohll(uint64_t const& networklonglong) { return zmqpp::swap_if_needed(networklonglong); } #endif /* INET_HPP_ */ zmqpp-3.2.0/src/zmqpp/message.cpp000066400000000000000000000242661223647374400167770ustar00rootroot00000000000000/* * Created on: 9 Aug 2011 * Author: Ben Gray (@benjamg) */ #include #include #include "exception.hpp" #include "inet.hpp" #include "message.hpp" namespace zmqpp { /*! * \brief internal construct * \internal wraps the zmq struct block so allow us to monitor sent state */ struct zmq_msg_wrapper { bool sent; zmq_msg_t msg; }; /*! * \brief internal construct * \internal handles bubbling callback from zmq c style to the c++ functor provided */ struct callback_releaser { message::release_function func; }; message::message() : _parts() , _read_cursor(0) { } message::~message() { for(size_t i = 0; i < _parts.size(); ++i) { zmq_msg_t& msg = _parts[i].msg; #ifndef NDEBUG // unused assert variable in release int result = zmq_msg_close(&msg); assert(0 == result); #else zmq_msg_close(&msg); #endif // NDEBUG } _parts.clear(); } size_t message::parts() const { return _parts.size(); } /* * The two const_casts in size and raw_data are a little bit hacky * but neither of these methods called this way actually modify data * so accurately represent the intent of these calls. */ size_t message::size(size_t const& part /* = 0 */) const { if(part >= _parts.size()) { throw exception("attempting to request a message part outside the valid range"); } zmq_msg_wrapper const& wrap = _parts[part]; return zmq_msg_size( const_cast( &wrap.msg ) ); } void const* message::raw_data(size_t const& part /* = 0 */) const { if(part >= _parts.size()) { throw exception("attempting to request a message part outside the valid range"); } zmq_msg_wrapper const& wrap = _parts[part]; return zmq_msg_data( const_cast( &wrap.msg ) ); } zmq_msg_t& message::raw_msg(size_t const& part /* = 0 */) { if(part >= _parts.size()) { throw exception("attempting to request a message part outside the valid range"); } zmq_msg_wrapper& wrap = _parts[part]; return wrap.msg; } zmq_msg_t& message::raw_new_msg() { parts_type tmp(_parts.size() + 1); for(size_t i = 0; i < _parts.size(); ++i) { zmq_msg_t& dest = tmp[i].msg; if( 0 != zmq_msg_init(&dest) ) { throw zmq_internal_exception(); } zmq_msg_t& src = _parts[i].msg; if( 0 != zmq_msg_move(&dest, &src) ) { throw zmq_internal_exception(); } } std::swap(tmp, _parts); zmq_msg_t& msg = _parts.back().msg; if( 0 != zmq_msg_init(&msg) ) { throw zmq_internal_exception(); } return msg; } std::string message::get(size_t const& part /* = 0 */) const { return std::string(static_cast(raw_data(part)), size(part)); } // Move operators will take ownership of message parts without copying void message::move(void* part, size_t& size, release_function const& release) { parts_type tmp(_parts.size() + 1); for(size_t i = 0; i < _parts.size(); ++i) { zmq_msg_t& dest = tmp[i].msg; if( 0 != zmq_msg_init(&dest) ) { throw zmq_internal_exception(); } zmq_msg_t& src = _parts[i].msg; if( 0 != zmq_msg_move(&dest, &src) ) { throw zmq_internal_exception(); } } std::swap(tmp, _parts); callback_releaser* hint = new callback_releaser(); hint->func = release; zmq_msg_t& msg = _parts.back().msg; if (0 != zmq_msg_init_data(&msg, part, size, &message::release_callback, hint)) { throw zmq_internal_exception(); } } void message::add(void const* part, size_t const& size) { parts_type tmp(_parts.size() + 1); for(size_t i = 0; i < _parts.size(); ++i) { zmq_msg_t& dest = tmp[i].msg; if( 0 != zmq_msg_init(&dest) ) { throw zmq_internal_exception(); } zmq_msg_t& src = _parts[i].msg; if( 0 != zmq_msg_move(&dest, &src) ) { throw zmq_internal_exception(); } } std::swap(tmp, _parts); zmq_msg_t& msg = _parts.back().msg; if( 0 != zmq_msg_init_size(&msg, size) ) { throw zmq_internal_exception(); } void* msg_data = zmq_msg_data(&msg); memcpy(msg_data, part, size); } // Stream reader style void message::reset_read_cursor() { _read_cursor = 0; } void message::get(int8_t& integer, size_t const& part) const { assert(sizeof(int8_t) == size(part)); int8_t const* byte = static_cast(raw_data(part)); integer = *byte; } void message::get(int16_t& integer, size_t const& part) const { assert(sizeof(int16_t) == size(part)); uint16_t const* network_order = static_cast(raw_data(part)); integer = static_cast(ntohs(*network_order)); } void message::get(int32_t& integer, size_t const& part) const { assert(sizeof(int32_t) == size(part)); uint32_t const* network_order = static_cast(raw_data(part)); integer = static_cast(htonl(*network_order)); } void message::get(int64_t& integer, size_t const& part) const { assert(sizeof(int64_t) == size(part)); uint64_t const* network_order = static_cast(raw_data(part)); integer = static_cast(htonll(*network_order)); } void message::get(uint8_t& unsigned_integer, size_t const& part) const { assert(sizeof(uint8_t) == size(part)); uint8_t const* byte = static_cast(raw_data(part)); unsigned_integer = *byte; } void message::get(uint16_t& unsigned_integer, size_t const& part) const { assert(sizeof(uint16_t) == size(part)); uint16_t const* network_order = static_cast(raw_data(part)); unsigned_integer = ntohs(*network_order); } void message::get(uint32_t& unsigned_integer, size_t const& part) const { assert(sizeof(uint32_t) == size(part)); uint32_t const* network_order = static_cast(raw_data(part)); unsigned_integer = ntohl(*network_order); } void message::get(uint64_t& unsigned_integer, size_t const& part) const { assert(sizeof(uint64_t) == size(part)); uint64_t const* network_order = static_cast(raw_data(part)); unsigned_integer = ntohll(*network_order); } void message::get(float& floating_point, size_t const& part) const { assert(sizeof(uint32_t) == size(part)); uint32_t const* network_order = static_cast(raw_data(part)); uint32_t host_order = ntohl(*network_order); float* temp = reinterpret_cast(&host_order); floating_point = *temp; } void message::get(double& double_precision, size_t const& part) const { assert(sizeof(uint64_t) == size(part)); uint64_t const* network_order = static_cast(raw_data(part)); uint64_t host_order = ntohll(*network_order); double* temp = reinterpret_cast(&host_order); double_precision = *temp; } void message::get(bool& boolean, size_t const& part) const { assert(sizeof(uint8_t) == size(part)); uint8_t const* byte = static_cast(raw_data(part)); boolean = (*byte != 0); } void message::get(std::string& string, size_t const& part) const { string.assign( get(part) ); } // Stream writer style - these all use copy styles message& message::operator<<(int8_t const& integer) { add(&integer, sizeof(int8_t)); return *this; } message& message::operator<<(int16_t const& integer) { uint16_t network_order = htons(static_cast(integer)); add(&network_order, sizeof(uint16_t)); return *this; } message& message::operator<<(int32_t const& integer) { uint32_t network_order = htonl(static_cast(integer)); add(&network_order, sizeof(uint32_t)); return *this; } message& message::operator<<(int64_t const& integer) { uint64_t network_order = htonll(static_cast(integer)); add(&network_order, sizeof(uint64_t)); return *this; } message& message::operator<<(uint8_t const& unsigned_integer) { add(&unsigned_integer, sizeof(uint8_t)); return *this; } message& message::operator<<(uint16_t const& unsigned_integer) { uint16_t network_order = htons(unsigned_integer); add(&network_order, sizeof(uint16_t)); return *this; } message& message::operator<<(uint32_t const& unsigned_integer) { uint32_t network_order = htonl(unsigned_integer); add(&network_order, sizeof(uint32_t)); return *this; } message& message::operator<<(uint64_t const& unsigned_integer) { uint64_t network_order = htonll(unsigned_integer); add(&network_order, sizeof(uint64_t)); return *this; } message& message::operator<<(float const& floating_point) { assert(sizeof(float) == 4); uint32_t const host_order = *reinterpret_cast(&floating_point); uint32_t network_order = htonl(host_order); add(&network_order, sizeof(uint32_t)); return *this; } message& message::operator<<(double const& double_precision) { assert(sizeof(double) == 8); uint64_t const host_order = *reinterpret_cast(&double_precision); uint64_t network_order = htonll(host_order); add(&network_order, sizeof(uint64_t)); return *this; } message& message::operator<<(bool const& boolean) { uint8_t byte = (boolean) ? 1 : 0; add(&byte, sizeof(uint8_t)); return *this; } message& message::operator<<(char const* c_string) { add(c_string, strlen(c_string)); return *this; } message& message::operator<<(std::string const& string) { add(string.data(), string.size()); return *this; } message::message(message&& source) noexcept : _parts() , _read_cursor(0) { std::swap(_parts, source._parts); } message& message::operator=(message&& source) noexcept { std::swap(_parts, source._parts); return *this; } message message::copy() { message msg; msg.copy(*this); return msg; } void message::copy(message& source) { _parts.resize(source._parts.size()); for(size_t i = 0; i < source._parts.size(); ++i) { if( 0 != zmq_msg_init_size(&_parts[i].msg, zmq_msg_size(&source._parts[i].msg)) ) { throw zmq_internal_exception(); } if( 0 != zmq_msg_copy(&_parts[i].msg, &source._parts[i].msg) ) { throw zmq_internal_exception(); } } // we don't need a copy of the releasers as we did data copies of the internal data, //_releasers = source._releasers; //_strings = source._strings } // Used for internal tracking void message::sent(size_t const& part) { // sanity check assert(!_parts[part].sent); _parts[part].sent = true; } // Note that these releasers are not thread safe, the only safety is provided by // the socket class taking ownership so no updates can happen while zmq does it's thing // If used in a custom class this has to be dealt with. void message::release_callback(void* data, void* hint) { callback_releaser* releaser = static_cast(hint); releaser->func(data); delete releaser; } } zmqpp-3.2.0/src/zmqpp/message.hpp000066400000000000000000000115321223647374400167740ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_MESSAGE_HPP_ #define ZMQPP_MESSAGE_HPP_ #include #include #include #include #include #include #include "compatibility.hpp" namespace zmqpp { struct zmq_msg_wrapper; /*! * \brief a zmq message with optional multipart support * * A zmq message is made up of one or more parts which are sent together to * the target endpoints. zmq guarantees either the whole message or none * of the message will be delivered. */ class message { public: /*! * \brief callback to release user allocated data. * * The release function will be called on any void* moved part. * It must be thread safe to the extent that the callback may occur on * one of the context threads. * * The function called will be passed a single variable which is the * pointer to the memory allocated. */ typedef std::function release_function; message(); ~message(); size_t parts() const; size_t size(size_t const& part) const; std::string get(size_t const& part) const; void get(int8_t& integer, size_t const& part) const; void get(int16_t& integer, size_t const& part) const; void get(int32_t& integer, size_t const& part) const; void get(int64_t& integer, size_t const& part) const; void get(uint8_t& unsigned_integer, size_t const& part) const; void get(uint16_t& unsigned_integer, size_t const& part) const; void get(uint32_t& unsigned_integer, size_t const& part) const; void get(uint64_t& unsigned_integer, size_t const& part) const; void get(float& floating_point, size_t const& part) const; void get(double& double_precision, size_t const& part) const; void get(bool& boolean, size_t const& part) const; void get(std::string& string, size_t const& part) const; // Warn: If a pointer type is requested the message (well zmq) still 'owns' // the data and will release it when the message object is freed. template Type get(size_t const& part) { Type value; get(value, part); return value; } // Raw get data operations, useful with data structures more than anything else // Warn: The message (well zmq) still 'owns' the data and will release it // when the message object is freed. template void get(Type*& value, size_t const& part) const { value = static_cast(raw_data(part)); } // Warn: The message (well zmq) still 'owns' the data and will release it // when the message object is freed. template void get(Type** value, size_t const& part) const { *value = static_cast(raw_data(part)); } // Move operators will take ownership of message parts without copying void move(void* part, size_t& size, release_function const& release); // Raw move data operation, useful with data structures more than anything else template void move(Object *part) { move(part, sizeof(Object), &deleter_callback); } // Copy operators will take copies of any data void add(void const* part, size_t const& size); template void add(Type const& part) { *this << part; } // Stream reader style void reset_read_cursor(); template message& operator>>(Type& value) { get(value, _read_cursor++); return *this; } // Stream writer style - these all use copy styles message& operator<<(int8_t const& integer); message& operator<<(int16_t const& integer); message& operator<<(int32_t const& integer); message& operator<<(int64_t const& integer); message& operator<<(uint8_t const& unsigned_integer); message& operator<<(uint16_t const& unsigned_integer); message& operator<<(uint32_t const& unsigned_integer); message& operator<<(uint64_t const& unsigned_integer); message& operator<<(float const& floating_point); message& operator<<(double const& double_precision); message& operator<<(bool const& boolean); message& operator<<(char const* c_string); message& operator<<(std::string const& string); // Move supporting message(message&& source) noexcept; message& operator=(message&& source) noexcept; // Copy support message copy(); void copy(message& source); // Used for internal tracking void sent(size_t const& part); // Access to raw zmq details void const* raw_data(size_t const& part = 0) const; zmq_msg_t& raw_msg(size_t const& part = 0); zmq_msg_t& raw_new_msg(); private: typedef std::vector parts_type; parts_type _parts; size_t _read_cursor; // Disable implicit copy support, code must request a copy to clone message(message const&) noexcept ZMQPP_EXPLICITLY_DELETED; message& operator=(message const&) noexcept ZMQPP_EXPLICITLY_DELETED; static void release_callback(void* data, void* hint); template static void deleter_callback(void* data) { delete static_cast(data); } }; } #endif /* ZMQPP_MESSAGE_HPP_ */ zmqpp-3.2.0/src/zmqpp/poller.cpp000066400000000000000000000067321223647374400166460ustar00rootroot00000000000000/* * Created on: 16 Aug 2011 * Author: Ben Gray (@benjamg) */ #include "exception.hpp" #include "socket.hpp" #include "poller.hpp" #include namespace zmqpp { const long poller::wait_forever = -1; const short poller::poll_none = 0; const short poller::poll_in = ZMQ_POLLIN; const short poller::poll_out = ZMQ_POLLOUT; const short poller::poll_error = ZMQ_POLLERR; poller::poller() : _items() , _index() , _fdindex() { } poller::~poller() { _items.clear(); _index.clear(); _fdindex.clear(); } void poller::add(socket& socket, short const& event /* = POLL_IN */) { zmq_pollitem_t item { socket, 0, event, 0 }; size_t index = _items.size(); _items.push_back(item); _index[socket] = index; } void poller::add(int const& descriptor, short const& event /* = POLL_IN */) { zmq_pollitem_t item { nullptr, descriptor, event, 0 }; size_t index = _items.size(); _items.push_back(item); _fdindex[descriptor] = index; } bool poller::has(socket_t const& socket) { return _index.find(socket) != _index.end(); } bool poller::has(int const& descriptor) { return _fdindex.find(descriptor) != _fdindex.end(); } void poller::reindex(size_t const index) { if ( nullptr != _items[index].socket ) { auto found = _index.find( _items[index].socket ); if (_index.end() == found) { throw exception("unable to reindex socket in poller"); } found->second = index; } else { auto found = _fdindex.find( _items[index].fd ); if (_fdindex.end() == found) { throw exception("unable to reindex file descriptor in poller"); } found->second = index; } } void poller::remove(socket_t const& socket) { auto found = _index.find(socket); if (_index.end() == found) { return; } if ( _items.size() - 1 == found->second ) { _items.pop_back(); _index.erase(found); return; } std::swap(_items[found->second], _items.back()); _items.pop_back(); auto index = found->second; _index.erase(found); reindex( index ); } void poller::remove(int const& descriptor) { auto found = _fdindex.find(descriptor); if (_fdindex.end() == found) { return; } if ( _items.size() - 1 == found->second ) { _items.pop_back(); _fdindex.erase(found); return; } std::swap(_items[found->second], _items.back()); _items.pop_back(); auto index = found->second; _fdindex.erase(found); reindex( index ); } void poller::check_for(socket const& socket, short const& event) { auto found = _index.find(socket); if (_index.end() == found) { throw exception("this socket is not represented within this poller"); } _items[found->second].events = event; } void poller::check_for(int const& descriptor, short const& event) { auto found = _fdindex.find(descriptor); if (_fdindex.end() == found) { throw exception("this socket is not represented within this poller"); } _items[found->second].events = event; } bool poller::poll(long timeout /* = WAIT_FOREVER */) { int result = zmq_poll(_items.data(), _items.size(), timeout); if (result < 0) { throw zmq_internal_exception(); } return (result > 0); } short poller::events(socket const& socket) const { auto found = _index.find(socket); if (_index.end() == found) { throw exception("this socket is not represented within this poller"); } return _items[found->second].revents; } short poller::events(int const& descriptor) const { auto found = _fdindex.find(descriptor); if (_fdindex.end() == found) { throw exception("this file descriptor is not represented within this poller"); } return _items[found->second].revents; } } zmqpp-3.2.0/src/zmqpp/poller.hpp000066400000000000000000000114631223647374400166500ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_POLLER_HPP_ #define ZMQPP_POLLER_HPP_ #include #include #include "compatibility.hpp" namespace zmqpp { class socket; typedef socket socket_t; /*! * Polling wrapper. * * Allows access to polling for any number of sockets or file descriptors. */ class poller { public: static const long wait_forever; /*!< Block forever flag, default setting. */ static const short poll_none; /*!< No polling flags set. */ static const short poll_in; /*!< Monitor inbound flag. */ static const short poll_out; /*!< Monitor output flag. */ static const short poll_error; /*!< Monitor error flag.\n Only for file descriptors. */ /*! * Construct an empty polling model. */ poller(); /*! * Cleanup poller. * * Any sockets will need to be closed separately. */ ~poller(); /*! * Add a socket to the polling model and set which events to monitor. * * \param socket the socket to monitor. * \param event the event flags to monitor on the socket. */ void add(socket_t& socket, short const& event = poll_in); /*! * Add a file descriptor to the polling model and set which events to monitor. * * \param descriptor the file descriptor to monitor. * \param event the event flags to monitor. */ void add(int const& descriptor, short const& event = poll_in | poll_error); /*! * Check if we are monitoring a given socket with this poller. * * \param socket the socket to check. * \return true if it is there. */ bool has(socket_t const& socket); /*! * Check if we are monitoring a given file descriptor with this poller. * * \param descriptor the file descriptor to check. * \return true if it is there. */ bool has(int const& descriptor); /*! * Stop monitoring a socket. * * \param socket the socket to stop monitoring. */ void remove(socket_t const& socket); /*! * Stop monitoring a file descriptor. * * \param descriptor the file descriptor to stop monitoring. */ void remove(int const& descriptor); /*! * Update the monitored event flags for a given socket. * * \param socket the socket to update event flags. * \param event the event flags to monitor on the socket. */ void check_for(socket_t const& socket, short const& event); /*! * Update the monitored event flags for a given file descriptor. * * \param descriptor the file descriptor to update event flags. * \param event the event flags to monitor on the socket. */ void check_for(int const& descriptor, short const& event); /*! * Poll for monitored events. * * By default this method will block forever or until at least one of the monitored * sockets or file descriptors has events. * * If a timeout is set and was reached then this function returns false. * * \param timeout milliseconds to timeout. * \return true if there is an event.. */ bool poll(long timeout = wait_forever); /*! * Get the event flags triggered for a socket. * * \param socket the socket to get triggered event flags for. * \return the event flags. */ short events(socket_t const& socket) const; /*! * Get the event flags triggered for a file descriptor. * * \param descriptor the file descriptor to get triggered event flags for. * \return the event flags. */ short events(int const& descriptor) const; /*! * Check either a file descriptor or socket for input events. * * Templated helper method that calls through to event and checks for a given flag * * \param watchable either a file descriptor or socket known to the poller. * \return true if there is input. */ template bool has_input(Watched const& watchable) const { return events(watchable) & poll_in; } /*! * Check either a file descriptor or socket for output events. * * Templated helper method that calls through to event and checks for a given flag * * \param watchable either a file descriptor or socket known to the poller. * \return true if there is output. */ template bool has_output(Watched const& watchable) const { return events(watchable) & poll_out; } /*! * Check a file descriptor. * * Templated helper method that calls through to event and checks for a given flag * * Technically this template works for sockets as well but the error flag is never set for * sockets so I have no idea why someone would call it. * * \param watchable a file descriptor know to the poller. * \return true if there is an error. */ template bool has_error(Watched const& watchable) const { return events(watchable) & poll_error; } private: std::vector _items; std::unordered_map _index; std::unordered_map _fdindex; void reindex(size_t const index); }; } #endif /* ZMQPP_POLLER_HPP_ */ zmqpp-3.2.0/src/zmqpp/socket.cpp000066400000000000000000000424161223647374400166400ustar00rootroot00000000000000/* * Created on: 9 Aug 2011 * Author: Ben Gray (@benjamg) */ #include #include #include #include #include "context.hpp" #include "exception.hpp" #include "message.hpp" #include "socket.hpp" namespace zmqpp { const int socket::normal; const int socket::dont_wait; const int socket::send_more; #ifdef ZMQ_EXPERIMENTAL_LABELS const int socket::send_label; #endif const int max_socket_option_buffer_size = 256; const int max_stream_buffer_size = 4096; socket::socket(const context& context, socket_type const& type) : _socket(nullptr) , _type(type) , _recv_buffer() { _socket = zmq_socket(context, static_cast(type)); if(nullptr == _socket) { throw zmq_internal_exception(); } zmq_msg_init(&_recv_buffer); } socket::~socket() { zmq_msg_close(&_recv_buffer); if (nullptr != _socket) { #ifndef NDEBUG // unused assert variable in release int result = zmq_close(_socket); assert(0 == result); #else zmq_close(_socket); #endif // NDEBUG _socket = nullptr; } } void socket::bind(endpoint_t const& endpoint) { int result = zmq_bind(_socket, endpoint.c_str()); if (0 != result) { throw zmq_internal_exception(); } } void socket::unbind(endpoint_t const& endpoint) { int result = zmq_unbind(_socket, endpoint.c_str()); if (0 != result) { throw zmq_internal_exception(); } } void socket::connect(endpoint_t const& endpoint) { int result = zmq_connect(_socket, endpoint.c_str()); if (0 != result) { throw zmq_internal_exception(); } } void socket::disconnect(endpoint_t const& endpoint) { int result = zmq_disconnect(_socket, endpoint.c_str()); if (0 != result) { throw zmq_internal_exception(); } } void socket::close() { int result = zmq_close(_socket); if (0 != result) { throw zmq_internal_exception(); } _socket = nullptr; } bool socket::send(message& message, bool const& dont_block /* = false */) { size_t parts = message.parts(); if (parts == 0) { throw std::invalid_argument("sending requires messages have at least one part"); } for(size_t i = 0; i < parts; ++i) { int flag = socket::normal; if(dont_block) { flag |= socket::dont_wait; } if(i < (parts - 1)) { flag |= socket::send_more; } #if (ZMQ_VERSION_MAJOR == 2) int result = zmq_send( _socket, &message.raw_msg(i), flag ); #elif (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_sendmsg( _socket, &message.raw_msg(i), flag ); #else int result = zmq_msg_send( &message.raw_msg(i), _socket, flag ); #endif if (result < 0) { // the zmq framework should not block if the first part is accepted // so we should only ever get this error on the first part if((0 == i) && (EAGAIN == zmq_errno())) { return false; } // sanity checking assert(EAGAIN != zmq_errno()); throw zmq_internal_exception(); } message.sent(i); } // Leave message reference in a stable state zmqpp::message local; std::swap(local, message); return true; } bool socket::receive(message& message, bool const& dont_block /* = false */) { if (message.parts() > 0) { throw exception("receiving can only be done to empty messages"); } int flags = (dont_block) ? socket::dont_wait : socket::normal; bool more = true; while(more) { #if (ZMQ_VERSION_MAJOR == 2) int result = zmq_recv( _socket, &_recv_buffer, flags ); #elif (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_recvmsg( _socket, &_recv_buffer, flags ); #else int result = zmq_msg_recv( &_recv_buffer, _socket, flags ); #endif if(result < 0) { if ((0 == message.parts()) && (EAGAIN == zmq_errno())) { return false; } assert(EAGAIN == zmq_errno()); throw zmq_internal_exception(); } zmq_msg_t& dest = message.raw_new_msg(); zmq_msg_move(&dest, &_recv_buffer); get(socket_option::receive_more, more); } return true; } bool socket::send(std::string const& string, int const& flags /* = NORMAL */) { return send_raw(string.data(), string.size(), flags); } bool socket::receive(std::string& string, int const& flags /* = NORMAL */) { #if (ZMQ_VERSION_MAJOR == 2) int result = zmq_recv( _socket, &_recv_buffer, flags ); #elif (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_recvmsg( _socket, &_recv_buffer, flags ); #else int result = zmq_msg_recv( &_recv_buffer, _socket, flags ); #endif if(result >= 0) { string.reserve(zmq_msg_size(&_recv_buffer)); string.assign(static_cast(zmq_msg_data(&_recv_buffer)), zmq_msg_size(&_recv_buffer)); return true; } if (EAGAIN == zmq_errno()) { return false; } throw zmq_internal_exception(); } bool socket::send_raw(char const* buffer, int const& length, int const& flags /* = NORMAL */) { #if (ZMQ_VERSION_MAJOR == 2) zmq_msg_t msg; int result = zmq_msg_init_size(&msg, length); if (result != 0) { zmq_internal_exception(); } memcpy(zmq_msg_data(&msg), buffer, length); result = zmq_send(_socket, &msg, flags); #else int result = zmq_send(_socket, buffer, length, flags); #endif if(result >= 0) { return true; } #if (ZMQ_VERSION_MAJOR == 2) // only actually need to close this on error zmq_msg_close(&msg); #endif if (EAGAIN == zmq_errno()) { return false; } throw zmq_internal_exception(); } bool socket::receive_raw(char* buffer, int& length, int const& flags /* = NORMAL */) { #if (ZMQ_VERSION_MAJOR == 2) int result = zmq_recv( _socket, &_recv_buffer, flags ); #elif (ZMQ_VERSION_MAJOR < 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR < 2)) int result = zmq_recvmsg( _socket, &_recv_buffer, flags ); #else int result = zmq_msg_recv( &_recv_buffer, _socket, flags ); #endif if(result >= 0) { length = zmq_msg_size(&_recv_buffer); memcpy(buffer, zmq_msg_data(&_recv_buffer), length); return true; } if (EAGAIN == zmq_errno()) { return false; } throw zmq_internal_exception(); } // Helper void socket::subscribe(std::string const& topic) { set(socket_option::subscribe, topic); } void socket::unsubscribe(std::string const& topic) { set(socket_option::unsubscribe, topic); } bool socket::has_more_parts() const { return get(socket_option::receive_more); } // Set socket options for different types of option void socket::set(socket_option const& option, int const& value) { switch(option) { // unsigned 64bit Integers #if (ZMQ_VERSION_MAJOR == 2) case socket_option::high_water_mark: case socket_option::send_buffer_size: case socket_option::receive_buffer_size: #endif case socket_option::affinity: if (value < 0) { throw exception("attempting to set an unsigned 64 bit integer option with a negative integer"); } set(option, static_cast(value)); break; // 64bit Integers #if (ZMQ_VERSION_MAJOR == 2) case socket_option::rate: case socket_option::recovery_interval: case socket_option::recovery_interval_seconds: case socket_option::swap_size: #else case socket_option::max_messsage_size: #endif set(option, static_cast(value)); break; // Boolean #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) case socket_option::ipv4_only: #endif #if (ZMQ_VERSION_MAJOR == 2) case socket_option::multicast_loopback: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::delay_attach_on_connect: case socket_option::router_mandatory: case socket_option::xpub_verbose: #endif if (value == 0) { set(option, false); } else if (value == 1) { set(option, true); } else { throw exception("attempting to set a boolean option with a non 0 or 1 integer"); } break; // Default or Boolean #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::tcp_keepalive: if (value < -1 || value > 1) { throw exception("attempting to set a default or boolean option with a non -1, 0 or 1 integer"); } if (0 != zmq_setsockopt(_socket, static_cast(option), &value, sizeof(value))) { throw zmq_internal_exception(); } break; #endif // Integers that require +ve numbers #if (ZMQ_VERSION_MAJOR == 2) case socket_option::reconnect_interval_max: #else case socket_option::reconnect_interval_max: case socket_option::send_buffer_size: case socket_option::recovery_interval: case socket_option::receive_buffer_size: case socket_option::send_high_water_mark: case socket_option::receive_high_water_mark: case socket_option::multicast_hops: case socket_option::rate: #endif case socket_option::backlog: if (value < 0) { throw exception("attempting to set a positive only integer option with a negative integer"); } // Integers case socket_option::reconnect_interval: case socket_option::linger: case socket_option::receive_timeout: case socket_option::send_timeout: #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::tcp_keepalive_idle: case socket_option::tcp_keepalive_count: case socket_option::tcp_keepalive_interval: #endif if (0 != zmq_setsockopt(_socket, static_cast(option), &value, sizeof(value))) { throw zmq_internal_exception(); } break; default: throw exception("attempting to set a non signed integer option with a signed integer value"); } } void socket::set(socket_option const& option, bool const& value) { switch(option) { #if (ZMQ_VERSION_MAJOR == 2) case socket_option::multicast_loopback: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) case socket_option::ipv4_only: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::delay_attach_on_connect: case socket_option::router_mandatory: case socket_option::xpub_verbose: #endif zmq_setsockopt(_socket, static_cast(option), &value, sizeof(value)); break; default: throw exception("attempting to set a non boolean option with a boolean value"); } } void socket::set(socket_option const& option, uint64_t const& value) { switch(option) { #if (ZMQ_VERSION_MAJOR == 2) // unsigned 64bit Integers case socket_option::high_water_mark: case socket_option::send_buffer_size: case socket_option::receive_buffer_size: #endif case socket_option::affinity: if (0 != zmq_setsockopt(_socket, static_cast(option), &value, sizeof(value))) { throw zmq_internal_exception(); } break; default: throw exception("attempting to set a non unsigned 64 bit integer option with a unsigned 64 bit integer value"); } } void socket::set(socket_option const& option, int64_t const& value) { switch(option) { #if (ZMQ_VERSION_MAJOR == 2) case socket_option::rate: case socket_option::recovery_interval: case socket_option::recovery_interval_seconds: case socket_option::swap_size: #else case socket_option::max_messsage_size: #endif // zmq only allowed +ve int64_t options if (value < 0) { throw exception("attempting to set a positive only 64 bit integer option with a negative 64bit integer"); } if (0 != zmq_setsockopt(_socket, static_cast(option), &value, sizeof(value))) { throw zmq_internal_exception(); } break; default: throw exception("attempting to set a non 64 bit integer option with a 64 bit integer value"); } } void socket::set(socket_option const& option, char const* value, size_t const length) { switch(option) { case socket_option::identity: case socket_option::subscribe: case socket_option::unsubscribe: #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::tcp_accept_filter: #endif if (0 != zmq_setsockopt(_socket, static_cast(option), value, length)) { throw zmq_internal_exception(); } break; default: throw exception("attempting to set a non string option with a string value"); } } // Get socket options, multiple versions for easy of use void socket::get(socket_option const& option, int& value) const { size_t value_size = sizeof(int); switch(option) { #if (ZMQ_VERSION_MAJOR == 2) case socket_option::receive_more: case socket_option::multicast_loopback: value = static_cast(get(option)); break; #endif case socket_option::type: case socket_option::linger: case socket_option::backlog: case socket_option::reconnect_interval: case socket_option::reconnect_interval_max: case socket_option::receive_timeout: case socket_option::send_timeout: case socket_option::file_descriptor: case socket_option::events: #if (ZMQ_VERSION_MAJOR > 2) case socket_option::receive_more: case socket_option::send_buffer_size: case socket_option::receive_buffer_size: case socket_option::rate: case socket_option::recovery_interval: case socket_option::send_high_water_mark: case socket_option::receive_high_water_mark: case socket_option::multicast_hops: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) case socket_option::ipv4_only: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::delay_attach_on_connect: case socket_option::tcp_keepalive: case socket_option::tcp_keepalive_idle: case socket_option::tcp_keepalive_count: case socket_option::tcp_keepalive_interval: #endif #ifdef ZMQ_EXPERIMENTAL_LABELS case socket_option::receive_label: #endif if (0 != zmq_getsockopt(_socket, static_cast(option), &value, &value_size)) { throw zmq_internal_exception(); } // sanity check assert(value_size <= sizeof(int)); break; default: throw exception("attempting to get a non integer option with an integer value"); } } void socket::get(socket_option const& option, bool& value) const { #if (ZMQ_VERSION_MAJOR == 2) int64_t int_value = 0; size_t value_size = sizeof(int64_t); #else int int_value = 0; size_t value_size = sizeof(int); #endif switch(option) { case socket_option::receive_more: #if (ZMQ_VERSION_MAJOR == 2) case socket_option::multicast_loopback: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) case socket_option::ipv4_only: #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::delay_attach_on_connect: #endif #ifdef ZMQ_EXPERIMENTAL_LABELS case socket_option::receive_label: #endif if (0 != zmq_getsockopt(_socket, static_cast(option), &int_value, &value_size)) { throw zmq_internal_exception(); } value = (int_value == 1) ? true : false; break; default: throw exception("attempting to get a non boolean option with a boolean value"); } } void socket::get(socket_option const& option, uint64_t& value) const { size_t value_size = sizeof(uint64_t); switch(option) { #if (ZMQ_VERSION_MAJOR == 2) case socket_option::high_water_mark: case socket_option::send_buffer_size: case socket_option::receive_buffer_size: #endif case socket_option::affinity: if(0 != zmq_getsockopt(_socket, static_cast(option), &value, &value_size)) { throw zmq_internal_exception(); } break; default: throw exception("attempting to get a non unsigned 64 bit integer option with an unsigned 64 bit integer value"); } } void socket::get(socket_option const& option, int64_t& value) const { size_t value_size = sizeof(int64_t); switch(option) { #if (ZMQ_VERSION_MAJOR == 2) case socket_option::rate: case socket_option::recovery_interval: case socket_option::recovery_interval_seconds: case socket_option::swap_size: case socket_option::receive_more: case socket_option::multicast_loopback: #else case socket_option::max_messsage_size: #endif if(0 != zmq_getsockopt(_socket, static_cast(option), &value, &value_size)) { throw zmq_internal_exception(); } break; default: throw exception("attempting to get a non 64 bit integer option with an 64 bit integer value"); } } void socket::get(socket_option const& option, std::string& value) const { static std::array buffer; size_t size = max_socket_option_buffer_size; switch(option) { case socket_option::identity: #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) case socket_option::last_endpoint: #endif if(0 != zmq_getsockopt(_socket, static_cast(option), buffer.data(), &size)) { throw zmq_internal_exception(); } value.assign(buffer.data(), size); break; default: throw exception("attempting to get a non string option with a string value"); } } socket::socket(socket&& source) noexcept : _socket(source._socket) , _type(source._type) , _recv_buffer() { // we steal the zmq_msg_t from the valid socket, we only init our own because it's cheap // and zmq_msg_move does a valid check zmq_msg_init(&_recv_buffer); zmq_msg_move(&_recv_buffer, &source._recv_buffer); // Clean up source a little, we will handle the deinit, it doesn't need to source._socket = nullptr; } socket& socket::operator=(socket&& source) noexcept { std::swap(_socket, source._socket); _type = source._type; // just clone? // we steal the zmq_msg_t from the valid socket, we only init our own because it's cheap // and zmq_msg_move does a valid check zmq_msg_init(&_recv_buffer); zmq_msg_move(&_recv_buffer, &source._recv_buffer); return *this; } socket::operator bool() const { return nullptr != _socket; } socket::operator void*() const { return _socket; } void socket::track_message(message const& /* message */, uint32_t const& parts, bool& should_delete) { if (parts == 0) { should_delete = true; } } } zmqpp-3.2.0/src/zmqpp/socket.hpp000066400000000000000000000340011223647374400166340ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_SOCKET_HPP_ #define ZMQPP_SOCKET_HPP_ #include #include #include #include #include "compatibility.hpp" #include "socket_types.hpp" #include "socket_options.hpp" namespace zmqpp { class context; class message; typedef std::string endpoint_t; typedef context context_t; typedef message message_t; /*! * The socket class represents the zmq sockets. * * A socket can be bound and/or connected to as many endpoints as required * with the sole exception of a ::pair socket. * * The routing is handled by zmq based on the type set. * * The bound side of an inproc connection must occur first and inproc can only * connect to other inproc sockets of the same context. * * This class is c++0x move supporting and cannot be copied. */ class socket { public: static const int normal = 0; /*!< /brief default send type, no flags set */ #if (ZMQ_VERSION_MAJOR == 2) static const int dont_wait = ZMQ_NOBLOCK; /*!< /brief don't block if sending is not currently possible */ #else static const int dont_wait = ZMQ_DONTWAIT; /*!< /brief don't block if sending is not currently possible */ #endif static const int send_more = ZMQ_SNDMORE; /*!< /brief more parts will follow this one */ #ifdef ZMQ_EXPERIMENTAL_LABELS static const int send_label = ZMQ_SNDLABEL; /*!< /brief this message part is an internal zmq label */ #endif /*! * Create a socket for a given type. * * \param context the zmq context under which the socket will live * \param type a valid ::socket_type for the socket */ socket(context_t const& context, socket_type const& type); /*! * This will close any socket still open before returning */ ~socket(); /*! * Get the type of the socket, this works on zmqpp types and not the zmq internal types. * Use the socket::get method if you wish to intergoate the zmq internal ones. * * \return the type of the socket */ socket_type type() const { return _type; } /*! * Asynchronously binds to an endpoint. * * \param endpoint the zmq endpoint to bind to */ void bind(endpoint_t const& endpoint); /*! * Unbinds from a previously bound endpoint. * * \param endpoint the zmq endpoint to bind to */ void unbind(endpoint_t const& endpoint); /*! * Asynchronously connects to an endpoint. * If the endpoint is not inproc then zmq will happily keep trying * to connect until there is something there. * * Inproc sockets must have a valid target already bound before connection * will work. * * \param endpoint the zmq endpoint to connect to */ void connect(endpoint_t const& endpoint); /*! * Asynchronously connects to multiple endpoints. * If the endpoint is not inproc then zmq will happily keep trying * to connect until there is something there. * * Inproc sockets must have a valid target already bound before connection * will work. * * This is a helper function that wraps the single item connect in a loop * * \param connections_begin the starting iterator for zmq endpoints. * \param connections_end the final iterator for zmq endpoints. */ template void connect(InputIterator const& connections_begin, InputIterator const& connections_end) { for(InputIterator it = connections_begin; it != connections_end; ++it) { connect(*it); } } /*! * Disconnects a previously connected endpoint. * * \param endpoint the zmq endpoint to disconnect from */ void disconnect(endpoint_t const& endpoint); /*! * Disconnects from multiple previously connected endpoints. * * This is a helper function that wraps the single item disconnect in a loop * * \param disconnections_begin the starting iterator for zmq endpoints. * \param disconnections_end the final iterator for zmq endpoints. */ template void disconnect(InputIterator const& disconnections_begin, InputIterator const& disconnections_end) { for(InputIterator it = disconnections_begin; it != disconnections_end; ++it) { disconnect(*it); } } /*! * Closes the internal zmq socket and marks this instance * as invalid. */ void close(); /*! * Sends the message over the connection, this may be a multipart message. * * If dont_block is true and we are unable to add a new message then this * function will return false. * * \param message message to send * \param dont_block boolean to dictate if we wait while sending. * \return true if message sent, false if it would have blocked */ bool send(message_t& message, bool const& dont_block = false); /*! * Gets a message from the connection, this may be a multipart message. * * If dont_block is true and we are unable to get a message then this * function will return false. * * \param message reference to fill with received data * \param dont_block boolean to dictate if we wait for data. * \return true if message sent, false if it would have blocked */ bool receive(message_t& message, bool const& dont_block = false); /*! * Sends the byte data held by the string as the next message part. * * If the socket::DONT_WAIT flag and we are unable to add a new message to * socket then this function will return false. * * \param string message part to send * \param flags message send flags * \return true if message part sent, false if it would have blocked */ bool send(std::string const& string, int const& flags = normal); /*! * If there is a message ready then get the next part as a string * * If the socket::DONT_WAIT flag and there is no message ready to receive * then this function will return false. * * \param string message part to receive into * \param flags message receive flags * \return true if message part received, false if it would have blocked */ bool receive(std::string& string, int const& flags = normal); /*! * Sends the byte data pointed to by buffer as the next part of the message. * * If the socket::DONT_WAIT flag and we are unable to add a new message to * socket then this function will return false. * * \param buffer byte buffer pointer to start writing from * \param length max length of the buffer * \param flags message send flags * \return true if message part sent, false if it would have blocked */ bool send_raw(char const* buffer, int const& length, int const& flags = normal); /*! * \warning If the buffer is not large enough for the message part then the * data will be truncated. The rest of the part is lost forever. * * If there is a message ready then get the next part of it as a raw * byte buffer. * * If the socket::DONT_WAIT flag and there is no message ready to receive * then this function will return false. * * \param buffer byte buffer pointer to start writing to * \param length max length of the buffer * \param flags message receive flags * \return true if message part received, false if it would have blocked */ bool receive_raw(char* buffer, int& length, int const& flags = normal); /*! * * Subscribe to a topic * * Helper function that is equivalent of calling * \code * set(zmqpp::socket_option::subscribe, topic); * \endcode * * This method is only useful for subscribe type sockets. * * \param topic the topic to subscribe to. */ void subscribe(std::string const& topic); /*! * Subscribe to a topic * * Helper function that is equivalent of a loop calling * \code * set(zmqpp::socket_option::subscribe, topic); * \endcode * * This method is only useful for subscribe type sockets. * * Generally this will be used with stl collections using begin() and * end() functions to get the iterators. * For this reason the end loop runs until the end iterator, not inclusive * of it. * * \param topics_begin the starting iterator for topics. * \param topics_end the final iterator for topics. */ template void subscribe(InputIterator const& topics_begin, InputIterator const& topics_end) { for(InputIterator it = topics_begin; it != topics_end; ++it) { subscribe(*it); } } /*! * Unsubscribe from a topic * * Helper function that is equivalent of calling * \code * set(zmqpp::socket_option::unsubscribe, topic); * \endcode * * This method is only useful for subscribe type sockets. * * \param topic the topic to unsubscribe from. */ void unsubscribe(std::string const& topic); /*! * Unsubscribe from a topic * * Helper function that is equivalent of a loop calling * \code * set(zmqpp::socket_option::unsubscribe, topic); * \endcode * * This method is only useful for subscribe type sockets. * * Generally this will be used with stl collections using begin() and * end() functions to get the iterators. * For this reason the end loop runs until the end iterator, not inclusive * of it. * * \param topics_begin the starting iterator for topics. * \param topics_end the final iterator for topics. */ template void unsubscribe(InputIterator const& topics_begin, InputIterator const& topics_end) { for(InputIterator it = topics_begin; it != topics_end; ++it) { unsubscribe(*it); } } /*! * If the last receive part call to the socket resulted * in a label or a non-terminating part of a multipart * message this will return true. * * \return true if there are more parts */ bool has_more_parts() const; /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param value to set the option to */ void set(socket_option const& option, int const& value); /*! * Set the value of an option in the underlaying zmq socket. * * \since 2.0.0 (built against 0mq version 3.1.x or later) * * \param option a valid ::socket_option * \param value to set the option to */ void set(socket_option const& option, bool const& value); /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param value to set the option to */ void set(socket_option const& option, uint64_t const& value); /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param value to set the option to */ void set(socket_option const& option, int64_t const& value); /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param pointer to raw byte value to set the option to * \param length the size of the raw byte value */ void set(socket_option const& option, char const* value, size_t const length); /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param pointer to null terminated cstring value to set the option to */ inline void set(socket_option const& option, char const* value) { set(option, value, strlen(value)); } /*! * Set the value of an option in the underlaying zmq socket. * * \param option a valid ::socket_option * \param value to set the option to */ inline void set(socket_option const& option, std::string const& value) { set(option, value.c_str(), value.length()); } /*! * Get a socket option from the underlaying zmq socket. * * \param option a valid ::socket_option * \param value referenced int to return value in */ void get(socket_option const& option, int& value) const; /*! * Get a socket option from the underlaying zmq socket. * * \param option a valid ::socket_option * \param value referenced bool to return value in */ void get(socket_option const& option, bool& value) const; /*! * Get a socket option from the underlaying zmq socket. * * \param option a valid ::socket_option * \param value referenced uint64_t to return value in */ void get(socket_option const& option, uint64_t& value) const; /*! * Get a socket option from the underlaying zmq socket. * * \param option a valid ::socket_option * \param value referenced uint64_t to return value in */ void get(socket_option const& option, int64_t& value) const; /*! * Get a socket option from the underlaying zmq socket. * * \param option a valid ::socket_option * \param value referenced std::string to return value in */ void get(socket_option const& option, std::string& value) const; /*! * For those that don't want to get into a referenced value this templated method * will return the value instead. * * \param option a valid ::socket_option * \return socket option value */ template Type get(socket_option const& option) const { Type value = Type(); get(option, value); return value; } /*! * Move constructor * * Moves the internals of source to this object, there is no guarantee * that source will be left in a valid state. * * This constructor is noexcept and so will not throw exceptions * * \param source target socket to steal internals from */ socket(socket&& source) noexcept; /*! * Move operator * * Moves the internals of source to this object, there is no guarantee * that source will be left in a valid state. * * This function is noexcept and so will not throw exceptions * * \param source target socket to steal internals from * \return socket reference to this */ socket& operator=(socket&& source) noexcept; /*! * Check the socket is still valid * * This tests the internal state of the socket. * If creation failed for some reason or if the move functions were used * to move the socket internals to another instance this will return false. * * \return true if the socket is valid */ operator bool() const; /*! * Access to the raw 0mq context * * \return void pointer to the underlying 0mq socket */ operator void*() const; private: void* _socket; socket_type _type; zmq_msg_t _recv_buffer; // No copy socket(socket const&) noexcept ZMQPP_EXPLICITLY_DELETED; socket& operator=(socket const&) noexcept ZMQPP_EXPLICITLY_DELETED; void track_message(message_t const&, uint32_t const&, bool&); }; } #endif /* ZMQPP_SOCKET_HPP_ */ zmqpp-3.2.0/src/zmqpp/socket_options.hpp000066400000000000000000000102471223647374400204150ustar00rootroot00000000000000/** * \file * * \date 23 Sep 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_SOCKET_OPTIONS_HPP_ #define ZMQPP_SOCKET_OPTIONS_HPP_ namespace zmqpp { /** \todo Expand the information on the options to make it actually useful. */ /*! * \brief possible Socket options in zmq */ enum class socket_option { affinity = ZMQ_AFFINITY, /*!< I/O thread affinity */ identity = ZMQ_IDENTITY, /*!< Socket identity */ subscribe = ZMQ_SUBSCRIBE, /*!< Add topic subscription - set only */ unsubscribe = ZMQ_UNSUBSCRIBE, /*!< Remove topic subscription - set only */ rate = ZMQ_RATE, /*!< Multicast data rate */ send_buffer_size = ZMQ_SNDBUF, /*!< Kernel transmission buffer size */ receive_buffer_size = ZMQ_RCVBUF, /*!< Kernel receive buffer size */ receive_more = ZMQ_RCVMORE, /*!< Can receive more parts - get only */ file_descriptor = ZMQ_FD, /*!< Socket file descriptor - get only */ events = ZMQ_EVENTS, /*!< Socket event flags - get only */ type = ZMQ_TYPE, /*!< Socket type - get only */ linger = ZMQ_LINGER, /*!< Socket linger timeout */ backlog = ZMQ_BACKLOG, /*!< Maximum length of outstanding connections - get only */ #if (ZMQ_VERSION_MAJOR == 2) // Note that this is inverse of the zmq names for version 2.x recovery_interval_seconds = ZMQ_RECOVERY_IVL, /*!< Multicast recovery interval in seconds */ recovery_interval = ZMQ_RECOVERY_IVL_MSEC, /*!< Multicast recovery interval in milliseconds */ #else recovery_interval = ZMQ_RECOVERY_IVL, /*!< Multicast recovery interval in milliseconds */ #endif reconnect_interval = ZMQ_RECONNECT_IVL, /*!< Reconnection interval */ reconnect_interval_max = ZMQ_RECONNECT_IVL_MAX, /*!< Maximum reconnection interval */ receive_timeout = ZMQ_RCVTIMEO, /*!< Maximum inbound block timeout */ send_timeout = ZMQ_SNDTIMEO, /*!< Maximum outbound block timeout */ #if (ZMQ_VERSION_MAJOR == 2) high_water_mark = ZMQ_HWM, /*!< High-water mark for all messages */ swap_size = ZMQ_SWAP, /*!< Maximum socket swap size in bytes */ multicast_loopback = ZMQ_MCAST_LOOP, /*!< Allow multicast packet loopback */ #else max_messsage_size = ZMQ_MAXMSGSIZE, /*!< Maximum inbound message size */ send_high_water_mark = ZMQ_SNDHWM, /*!< High-water mark for outbound messages */ receive_high_water_mark = ZMQ_RCVHWM, /*!< High-water mark for inbound messages */ multicast_hops = ZMQ_MULTICAST_HOPS, /*!< Maximum number of multicast hops */ #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 1)) ipv4_only = ZMQ_IPV4ONLY, #endif #if (ZMQ_VERSION_MAJOR > 3) or ((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) delay_attach_on_connect = ZMQ_DELAY_ATTACH_ON_CONNECT, /*!< Delay buffer attachment until connect complete */ last_endpoint = ZMQ_LAST_ENDPOINT, /*!< Last bound endpoint - get only */ router_mandatory = ZMQ_ROUTER_MANDATORY, /*!< Require routable messages - set only */ xpub_verbose = ZMQ_XPUB_VERBOSE, /*!< Pass on existing subscriptions - set only */ tcp_keepalive = ZMQ_TCP_KEEPALIVE, /*!< Enable TCP keepalives */ tcp_keepalive_idle = ZMQ_TCP_KEEPALIVE_IDLE, /*!< TCP keepalive idle count (generally retry count) */ tcp_keepalive_count = ZMQ_TCP_KEEPALIVE_CNT, /*!< TCP keepalive retry count */ tcp_keepalive_interval = ZMQ_TCP_KEEPALIVE_INTVL, /*!< TCP keepalive interval */ tcp_accept_filter = ZMQ_TCP_ACCEPT_FILTER, /*!< Filter inbound connections - set only */ #endif #ifdef ZMQ_EXPERIMENTAL_LABELS receive_label = ZMQ_RCVLABEL, /*!< Received label part - get only */ #endif }; } #endif /* ZMQPP_SOCKET_OPTIONS_HPP_ */ zmqpp-3.2.0/src/zmqpp/socket_types.hpp000066400000000000000000000116501223647374400200650ustar00rootroot00000000000000/** * \file * * \date 23 Sep 2011 * \author Ben Gray (\@benjamg) */ #ifndef ZMQPP_SOCKET_TYPES_HPP_ #define ZMQPP_SOCKET_TYPES_HPP_ namespace zmqpp { /*! * \brief Socket types allowed by zmq * * The socket type choose at creation must be one of these types. * * Each is designed for a different use and has different limitations. */ enum class socket_type { /*! * One to one - two way connection.\n * Connect to ::pair.\n * A \c pair socket has to be connected only one other pair socket and allows * two way communication between them. */ pair = ZMQ_PAIR, /*! * One to many - fan out.\n * Connect to ::subscribe or ::xsubscribe.\n * Socket is send only.\n * Socket will drop messages and not block.\n * \c publish sockets allow sending of the same message to many subscribers * each subscriber can limit what is sent through the socket_option::subscribe * settings. */ publish = ZMQ_PUB, /*! * \note It seems doxygen can't work out which data is for the socket type and * which is for the socket option so both get listed for both. * * One to many - fair-queued.\n * Connect to ::publish or ::xpublish.\n * Socket is receive only.\n * The \c subscribe socket can connection to any number of publishers and will * fairly pull messages from each. The socket_option::subscribe settings can * be use to limit which messages are received and by default none are. */ subscribe = ZMQ_SUB, /*! * One to many - fair-queued.\n * Connect to ::push.\n * Socket is receive only.\n * The \c pull socket fairly pulls messages from all pushers it is connected * to. */ pull = ZMQ_PULL, /*! * One to many - load-balanced.\n * Connect to ::pull.\n * Socket is send only.\n * Socket will block if unable to send.\n * The \c push socket fairly distributes messages between any connected * puller sockets. */ push = ZMQ_PUSH, /*! * One to many - fair-queued outgoing, last peer incoming.\n * Connect to ::reply or ::xreply.\n * Socket flips between send and receive only.\n * Socket will block if unable to send.\n * The \c request socket will fairly balance requests sent out to a * replier and then can only be used to receive until that replier * sends a reply. */ request = ZMQ_REQ, /*! * One to many - load-balanced incoming, last peer outgoing.\n * Connect to ::request or ::xrequest.\n * Socket flips between send and receive only.\n * Socket will drop messages and not block.\n * The \c reply socket can only receive until it pulls a message from a * requester at which point it can only send until the reply is sent. */ reply = ZMQ_REP, /*! * One to many - fan out.\n * Connect to ::subscribe or ::xsubscribe.\n * Socket is send only with the exception of special subscription messages.\n * Socket will drop messages and not block.\n * \c xpublish act the same as ::publish sockets however also allow special * subscription messages to be received from subscribers. */ xpublish = ZMQ_XPUB, /*! * One to many - fair-queued.\n * Connect to ::publish or ::xpublish.\n * Socket is receive only with the exception of special subscription messages\n * \c xsubscribe act the same as ::subscribe sockets however also allow special * subscription messages to be send to connected publishers. */ xsubscribe = ZMQ_XSUB, /*! * One to many - fair-queued incoming, load-balanced outgoing.\n * Connect to ::reply or ::xreply.\n * Socket will block if unable to send.\n * An \c xrequest socket balances requests between repliers and pulls replies * back in a fair manner. Each request is expected to have exactly one reply. */ xrequest = ZMQ_XREQ, /*! * One to many - fair-queued incoming, targeted outgoing.\n * Connect to ::request or ::xrequest.\n * Socket will drop messages and not block.\n * An \c xreply socket fairly pulls in requests from requesters and will * label requests so it can return replies back to the correct target. */ xreply = ZMQ_XREP, // To match for people who prefer the shorter versions pub = ZMQ_PUB, /*!< version of ::publish to match zmq name convention */ sub = ZMQ_SUB, /*!< version of ::subscribe to match zmq name convention */ req = ZMQ_REQ, /*!< version of ::request to match zmq name convention */ rep = ZMQ_REP, /*!< version of ::reply to match zmq name convention */ xpub = ZMQ_XPUB, /*!< version of ::xpublish to match zmq name convention */ xsub = ZMQ_XSUB, /*!< version of ::xsubscribe to match zmq name convention */ xreq = ZMQ_XREQ, /*!< version of ::xrequest to match zmq name convention */ xrep = ZMQ_XREP, /*!< version of ::xreply to match zmq name convention */ // For completion router = ZMQ_ROUTER, /*!< \deprecated Matches zmq 2.x xrep functionality. */ dealer = ZMQ_DEALER /*!< \deprecated Matches zmq 2.x xreq functionality. */ }; } #endif /* ZMQPP_SOCKET_TYPES_HPP_ */ zmqpp-3.2.0/src/zmqpp/zmqpp.cpp000066400000000000000000000007441223647374400165150ustar00rootroot00000000000000/* * Created on: 18 Aug 2011 * Author: Ben Gray (@benjamg) */ #include "zmqpp.hpp" namespace zmqpp { std::string version() { return BUILD_VERSION; } void version(uint8_t& major, uint8_t& minor, uint8_t& revision) { major = ZMQPP_VERSION_MAJOR; minor = ZMQPP_VERSION_MINOR; revision = ZMQPP_VERSION_REVISION; } void zmq_version(uint8_t& major, uint8_t& minor, uint8_t& patch) { major = ZMQ_VERSION_MAJOR; minor = ZMQ_VERSION_MINOR; patch = ZMQ_VERSION_PATCH; } } zmqpp-3.2.0/src/zmqpp/zmqpp.hpp000066400000000000000000000071721223647374400165240ustar00rootroot00000000000000/** * \file * * \date 9 Aug 2011 * \author Ben Gray (\@benjamg) * * License: http://www.opensource.org/licenses/MIT * * Copyright (C) 2011 by Ben Gray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef ZMQPP_ZMQPP_HPP_ #define ZMQPP_ZMQPP_HPP_ /** * \def ZMQPP_VERSION_MAJOR * zmqpp major version number, generated at compile time */ #define ZMQPP_VERSION_MAJOR BUILD_VERSION_MAJOR /** * \def ZMQPP_VERSION_MINOR * zmqpp minor version number, generated at compile time */ #define ZMQPP_VERSION_MINOR BUILD_VERSION_MINOR /** * \def ZMQPP_VERSION_REVISION * zmqpp version revision number, generated at compile time */ #define ZMQPP_VERSION_REVISION BUILD_VERSION_REVISION #include #include "compatibility.hpp" #include "context.hpp" #include "exception.hpp" #include "message.hpp" #include "poller.hpp" #include "socket.hpp" /*! * \brief C++ wrapper around zmq * * All zmq++ / zmqpp functions, constants and classes live within this namespace, */ namespace zmqpp { /*! * Returns the current major.minor.revision version number as a string. * * \return string version number. */ std::string version(); /*! * Retrieve the parts of the zmqpp version number. * * Set the three parameters to values representing the zmqpp version number. * These values are generated at library compile time. * * \param major an unsigned 8 bit reference to set to the major version. * \param minor an unsigned 8 bit reference to set to the minor version. * \param revision an unsigned 8 bit reference to set the current revision. */ void version(uint8_t& major, uint8_t& minor, uint8_t& revision); /*! * Retrieve the parts of the 0mq version this library was built against. * * Because sections of the library are optionally compiled in or ignored * depending on the version of 0mq it was compiled against this method is * provided to allow sanity checking for usage. * * Set the three parameters to values representing the 0mq version number. * These values are generated at library compile time. * * \param major an unsigned 8 bit reference to set to the major version. * \param minor an unsigned 8 bit reference to set to the minor version. * \param revision an unsigned 8 bit reference to set the current revision. */ void zmq_version(uint8_t& major, uint8_t& minor, uint8_t& patch); typedef context context_t; /*!< \brief context type */ typedef std::string endpoint_t; /*!< \brief endpoint type */ typedef message message_t; /*!< \brief message type */ typedef poller poller_t; /*!< \brief poller type */ typedef socket socket_t; /*!< \brief socket type */ } #endif /* ZMQPP_ZMQPP_HPP_ */ zmqpp-3.2.0/zmqpp.doxygen.conf000066400000000000000000002127171223647374400164030ustar00rootroot00000000000000# Doxyfile 1.7.3 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = zmq++ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description for a project that appears at the top of each page and should give viewer a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "C++ bindings for 0mq" # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ./docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even if there is only one candidate or it is obvious which candidate to choose by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ./src/zmqpp # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = ZMQPP_COMPARABLE_ENUM \ ZMQPP_REQUIRED_ZMQ_MAJOR \ ZMQPP_REQUIRED_ZMQ_MINOR \ zmqpp::zmq_msg_wrapper \ zmqpp::callback_releaser \ zmq_msg_wrapper \ callback_releaser \ max_socket_option_buffer_size \ max_stream_buffer_size # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [0,1..20]) # that doxygen will group on one line in the generated HTML documentation. # Note that a value of 0 will completely suppress the enum values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the mathjax.org site, so you can quickly see the result without installing # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = ZMQ_VERSION_MAJOR=1000 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that overrules the definition found in the source code. EXPAND_AS_DEFINED = ZMQPP_COMPARABLE_ENUM # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called Helvetica to the output # directory and reference it in all dot files that doxygen generates. # When you want a differently looking font you can specify the font name # using DOT_FONTNAME. You need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, svg, gif or svg. # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES