Giter VIP home page Giter VIP logo

nzmqt's Introduction

nzmqt - A lightweight C++ Qt binding for ZeroMQ

nzmqt is a re-implementation of the approach taken by the zeromqt library. The idea is to integrate ZeroMQ into the Qt event loop, mapping ZeroMQ message events onto Qt signals. The original implementation also provides a Qt-like API which allows to represent messages as QByteArray instances. While I took this idea and the original implementation as a source of information, I've done a completely new implementation. Not only in order to get rid of some short comings, but also because I wanted to be sure I can use the code in my projects without problems, because until now zeromqt's author hasn't officially released his work under a certain (open source) license. Consequently, nzmqt is released to the public under the simplified BSD license. So you can use the code in your projects without any fear.

While zeromqt works fine for non-multi-part messages, it doesn't support multi-part messages yet. Also, a lot of code duplicates code of ZeroMQ's standard C++ binding. But this requires to take care of both implementations. So in contrast to the original implementation, nzmqt reuses as much code of ZeroMQ's original C++ binding as possible by using inheritance. Additionally, several things have been changed from a user's perspective. In summary, nzmqt contains the following changes compared to zeromqt:

  • The implementation is a complete re-write in the sense that it doesn't duplicate code of ZeroMQ's official C++ binding anymore. Instead, it builds upon existing code through inheritance and, hence, it will likely benefit from future bugfixes and enhancements targeted at ZeroMQ's C++ binding.
  • All classes are placed into a separate namespace 'nzmqt'.
  • This version now also supports ZeroMQ's multi-part messages.
  • The initial support for using Qt's way of handling errors using error codes has been dropped. Instead, this code only throws exception originally thrown by ZeroMQ's official C++ API. Note that although it looks like 'ZMQException' is a new custom exception class there is no custom exception class, but only a simple typedef which places the original exception class into the new namespace giving it a new name.
  • As with ZeroMQ's C++ binding all classes are contained within a singe header file which makes integrating this Qt binding very easy.
  • There is no 'ZmqContext' singleton anymore. Instead you can create your own 'ZMQContext' instance yourself.
  • The socket class 'ZMQSocket' now also inherits from QObject, so you can add it as a child to any QObject parent as you know it from Qt.
  • The code is officially licensed under the simplified BSD license.
  • Not only PUB-SUB, but also REQ-REP and PUSH-PULL are supported. (Note that other socket combinations might work, but they haven't been tested yet.)

Status

There are no known bugs.

Usage

As ZeroMQ's C++ binding this Qt binding only consists of a single C++ header file which you need to include in your project.

Consequently, using 'nzmqt' in a Qt project is as simple as adding that single header file to your project's .pro file as follows (assumed you use QT Creator).

HEADERS += nzmqt/nzmqt.hpp

If not already done, you also need to link against ZeroMQ library:

LIBS += -lzmq

Of course, you need to make sure the header file as well as the ZeroMQ library can be found by your compiler/linker.

As nzmqt uses C++ exceptions for error handling so you will need to catch them by overriding QCoreApplication::notify() method. The included sample will show you how this can be done.

Included Samples

Currently, there are samples showing PUB-SUB, REQ-REP and PUSH-PULL protocol with multi-part messages in action. They also show how to deal with exceptions in Qt.

More Information

nzmqt

nzmqt's People

Contributors

jonnydee avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.