Bindings, from the comfort and speed of C++ and without Qt.

Overview

KDBindings

Bindings, from the comfort and speed of C++ and without Qt.

From plain C++ you get:

  • Signals + Slots.
  • Properties templated on the contained type.
  • Property bindings allowing reactive code to be written without having to do all the low-level, error prone plumbing by hand.
  • Lazy evaluation of property bindings.
  • No more broken bindings.
  • Totally stand-alone "header-only" library. No heavy Qt dependency.
  • Can still be used with Qt if you so wish.

Using KDBindings

KDBindings requires a C++ compiler with C++17 support.

Find more information at:

Contact

Stay up-to-date with KDAB product announcements:

Licensing

KDBindings is (C) 2020-2021, Klarälvdalens Datakonsult AB, and is available under the terms of the MIT license.

Contact KDAB at [email protected] if you need different licensing options.

KDBindings includes these source files, also available under the terms of the MIT license:

  • doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD (C) 2016-2021 Viktor Kirilov [email protected]
  • genindex_array.h (C) 2021 Jeremy Burns (adapted by KDAB for KDBindings)

Get Involved

Please submit your contributions or issue reports from our GitHub space at https://github.com/KDAB/KDBindings

Contact [email protected] for more information.

About KDAB

KDBindings is supported and maintained by Klarälvdalens Datakonsult AB (KDAB).

The KDAB Group is the global No.1 software consultancy for Qt, C++ and OpenGL applications across desktop, embedded and mobile platforms.

The KDAB Group provides consulting and mentoring for developing Qt applications from scratch and in porting from all popular and legacy frameworks to Qt. We continue to help develop parts of Qt and are one of the major contributors to the Qt Project. We can give advanced or standard trainings anywhere around the globe on Qt as well as C++, OpenGL, 3D and more.

Please visit https://www.kdab.com to meet the people who write code like this.

Comments
  • Introduce ScopedConnectionHandle

    Introduce ScopedConnectionHandle

    Currently we have to disconnect the slot ourselves when its not needed. This is a bit error prone as we might forget to disconnect a slot in some cases leading to use after frees and invalid reads.

    This change proposes ScopedConnectionHandle which is a thin wrapper over ConnectionHandle. It automatically disconnects on scope exit.

    opened by Waqar144 3
  • Property: Remove noexcept from move constructor

    Property: Remove noexcept from move constructor

    As @jm4R noted in #24, because a Property emits the moved signal when moved, its move constructor cannot promise noexcept.

    This also warrants a minor version bump to v1.0.1

    This PR closes #24

    opened by LeonMatthesKDAB 3
  • Property move constructor cannot promise noexcept

    Property move constructor cannot promise noexcept

    The move constructor of Property is marked noexcept, but - as long as it emmits public moved signal - it can throw from any slot. Simple example:

    TEST_CASE("Nothrow move")
    {
        try {
            std::set_terminate([] {
                std::cerr << "TERMINATED" << std::endl;
            });
            Property<int> p;
            p.moved().connect([&] { throw 0; });
    
            Property<int> p2 = std::move(p);
        } catch (int) {
        }
    }
    

    The program will call std::terminate as it throws from noexcept function.

    bug 
    opened by jm4R 2
  • doxybook: Set settings to generate relative links

    doxybook: Set settings to generate relative links

    Note: Requires all doxybook output to be in the same folder. However, now links from the /latest/ version will always also point to /latest/. Furthermore we can set all canonical links to point to /latest/. This should improve our SEO for all pages where we have multiple versions.

    As the links for our subpages have now changed, we should check that we don't have any outside links pointing to specific classes (i.e. in our blog posts) or set up redirects for any Classes/, Namespaces/, Examples/ sub-links.

    This might also warrant a change in the Minor version number, so that all old links to 1.0.0 docs still work.

    opened by LeonMatthesKDAB 1
  • Property: Make moved Signal private

    Property: Make moved Signal private

    The moved Signal is problematic, as we can no longer guarantee noexcept move behavior of Properties, if anyone is allowed to connect a slot to the moved Signal. (See #24)

    By making the moved Signal private within KDBindings, we can have control over what code is executed by it. This allows us to keep the noexcept guarantee on the Property move constructor/assignment.

    This also warrants a version bump to v1.0.1

    Note: I had to remove a test from tst_property.cpp which needed access to the moved Signal. However, this is fine as the only behavior that the moved Signal can now influence is the observation by a PropertyNode. This is tested in tst_node.cpp.

    Closes #24

    bug 
    opened by LeonMatthesKDAB 0
  • Automatically integrate version in docs baseUrl

    Automatically integrate version in docs baseUrl

    This change uses CMake's "configure_file" command to enter the current KDBindings version number into the baseUrl used by mkdocs as well as doxybook2.

    This should fix the links for on docs.kdab.com.

    opened by LeonMatthesKDAB 0
  • Handling of members of aggregate types

    Handling of members of aggregate types

    When T is an aggregate type, eg struct Rect { int x; int y; int width; int height; }

    It would be great to be able to access members of Property, i.e that:

    Property<Rect> r;
    auto widthProp = makeBoundProperty(r.width);
    

    This slightly overlaps with what @lemirep is asking about in #28, except in my case the aggregate does not contain Property<> members. The desired behaviour can be done using a function argument to makeBoundProperty : the question is whether some overload of operator-dot (and ->, presumably) could synthesise the access.

    enhancement 
    opened by zakalawe 2
  • Allow having bindings referencing const Properties

    Allow having bindings referencing const Properties

    At the moment I cannot use a const Property in a binding.

    const Property<float> someValue = makeBinding(someExpression);
    Property<float> boundValue = makeBinding(someValue); // This does not compile
    

    A const Property means it cannot be assigned to again but its value still might change (if the value of the const property is a binding). Therefore, being able to use a const Property in a binding would make sense.

    bug 
    opened by lemirep 1
  • Handle Cascading Bindings

    Handle Cascading Bindings

    Often, I have to deal with a Property<T*> p where T itself contains properties. Given the property p is using a pointer type, I cannot binding directly to p->someProperty given p might be null. Therefore I would need to have a way to create a binding to a function that can itself return binding to another property or a value depending on whether p() is null.

    // GIVEN
    struct TypeA {
    Property<float> value { 1.0f };
    };
    
    struct TypeB {
    Property<TypeA *> a { nullptr };
    };
    
    // WHEN
    TypeB myB;
    
    // In a perfect world I would do Property<float> v = makeBinding(myB.a->value);
    // Except I can't if myB.a is null
    
    // THEN
    CHECk(myB.a() == nullptr);
    
    // WHEN
    Property<float> v = makeBinding([] (TypeA *a) { 
                                        if (a)
                                           return makeBinding(a->value);
                                        return 0.0f; // or a binding to a default property
                                    }, myB.a);
    
    // THEN -> Returns default value
    CHECK(v() == 0.0f);
    
    // WHEN
    TypeA myA;
    myB.a = &myA;
    
    // THEN -> Return bound value
    CHECK(v() == 1.0f);
    
    enhancement 
    opened by lemirep 0
  • Draft - Deferred connection evaluation

    Draft - Deferred connection evaluation

    Having the ability to control when a connection is emitted could be advantageous, especially in a multi-threaded context, where a worker thread might emit a signal, but the slot should be called in an event loop on a GUI thread.

    To control when exactly a connection is evaluated, implement a ConnectionEvaluator, similar to the BindingEvaluator, that can control when exactly a slot is called.

    Add a function connectDeferred (or similar) that takes a ConnectionEvaluator as the first argument, then takes the same arguments as the normal connect function. This slot would then queue the actual function to be called in the ConnectionEvaluator. The queued functions in the ConnectionEvaluator could then be called at any time, similar to how evaluateAll works on the BindingEvaluator. The difference here would be that connections might actually be emitted multiple times between calls to the evaluator, so these calls would then also need to be emitted multiple times.

    enhancement question 
    opened by LeonMatthesKDAB 0
  • Draft - Multi-Threaded bindings

    Draft - Multi-Threaded bindings

    Use Thread 1 with normal signal evaluation to mark a binding as dirty.

    Then have all the dependent properties associated with a BindingEvaluator. This binding evaluator would then be evaluated by Thread 2 (typically GUI Thread), so the evaluation actually happens on a separate thread.

    For this to work the following would need to be thread-safe:

    1. Marking of a binding as dirty.
    2. Reading from a Property & updating the bindings internal cache
    3. Disconnecting/Connecting of Signals when creating a Binding
    enhancement question 
    opened by LeonMatthesKDAB 0
  • Draft - Single Shot Connection

    Draft - Single Shot Connection

    A single shot connection could possibly be implemented by creating a binding that captures its own ConnectionHandle and disconnects it when the signal is emitted.

    Open question: How to capture the ConnectionHandle in the slot itself?

    enhancement question 
    opened by LeonMatthesKDAB 0
Releases(v1.0.1)
Owner
KDAB
Klaralvdalens Datakonsult AB
KDAB
Speed Running and Competition Doom. For strictly vanilla speed runs and competitions - forked from CNDoom

Speed Running and Competition Doom Speed Running and Competition Doom is based on Chocolate Doom and aims to accurately reproduce the original DOS ver

Gibbon 3 May 24, 2022
Anti-Grain Evolution. 2D graphics engine for Speed and Quality in C++.

Anti-Grain Evolution This project is based on ideas found in Maxim (mcseem) Shemanarev's Anti-Grain Geometry library, but oriented towards maximizing

Artem G. 99 Oct 31, 2022
Use this to speed up your final project and reduce code bloat

224 Superior Serial.print statements Use this to speed up your final project and reduce code bloat! And we learn about printing formatted strings usin

Ralph Bacon 28 Jan 4, 2023
A Gen implementation in C. With memory efficiency, portability and speed in mind

A Gen implementation in C. With memory efficiency, portability and speed in mind

Gen Programming Language 3 Jul 31, 2022
CRC32 slice-by-16 implementation in JS with an optional native binding to speed it up even futher

CRC32 slice-by-16 implementation in JS with an optional native binding to speed it up even futher. When used with Webpack/Browserify etc, it bundles the JS version.

Mathias Buus 8 Aug 4, 2021
Cold-start page provisioning speed test for WIndows

largepages This is a rudimentary test of cold-start memory paging on Windows that I put together for Raymond Chen's Tie, who was kind enough to ask it

Casey Muratori 31 Dec 8, 2022
Arduino code for a high speed 8000hz wired mouse using a teensy 4 MCU

teensy4_mouse Arduino code for a high speed 8000Hz wired mouse using a teensy 4 MCU. This code is inspired by https://github.com/mrjohnk/PMW3360DM-T2Q

Herbert Trip 9 Nov 19, 2022
Repository Containing the Code associated with the Paper: "Learning High-Speed Flight in the Wild"

Learning High-Speed Flight in the Wild This repo contains the code associated with the paper Learning Agile Flight in the Wild. For more information,

Robotics and Perception Group 396 Jan 3, 2023
Speed-up Version of ORB_SLAM3 by TBB library

ORB-SLAM3 Custom version, January 31st, 2022 Parallelize ORB feature extraction by TBB library, along with new update in V1.0, the speed is over real-

Long Vuong 12 Dec 7, 2022
Single-chip solution for Hi-speed USB2.0(480Mbps) JTAG/SPI Debugger based on RISC-V MCU CH32V30x/CH32V20x

480Mbps High Speed USB2.0 JTAG Debugger Open source information |-- bin |--------MCU: MCU target program |--------WIN APP |------------------USB20Jtag

RISC-V 58 Jan 5, 2023
rlua -- High level bindings between Rust and Lua

rlua -- High level bindings between Rust and Lua

Amethyst Foundation 1.4k Jan 2, 2023
Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more.

mach/glfw - Ziggified GLFW bindings Ziggified GLFW bindings that Mach engine uses, with 100% API coverage, zero-fuss installation, cross compilation,

Hexops 201 Dec 27, 2022
CppADCodeGen with an easy Eigen interface and Python bindings.

CppADCodeGenEigenPy CppADCodeGen with an easy Eigen interface and Python bindings. This project has been tested on Ubuntu 16.04, 18.04, and 20.04. It

Adam Heins 11 May 18, 2022
LLVM bindings for Node.js/JavaScript/TypeScript

llvm-bindings LLVM bindings for Node.js/JavaScript/TypeScript Supported OS macOS Ubuntu Windows Supported LLVM methods listed in the TypeScript defini

ApsarasX 250 Dec 18, 2022
C# bindings for Sokol using Sokol's binding generator

C# bindings for Sokol using Sokol's binding generator

Michal Strehovský 29 Jan 4, 2023
Android Bindings for QuickJS, A fine little javascript engine.

quickjs-android quickjs-android 是 QuickJS JavaScript 引擎的 Android 接口框架,整体基于面向对象设计,提供了自动GC功能,使用简单。armeabi-v7a 的大小仅 350KB,是 Google V8 不错的替代品,启动速度比 V8 快,内

Wiki 121 Dec 28, 2022
Zig bindings for the excellent CRoaring library

Zig-Roaring This library implements Zig bindings for the CRoaring library. Naming Any C function that begins with roaring_bitmap_ is a method of the B

Justin Whear 15 Dec 13, 2022
Python bindings of silk codec.

Python silk module. --- pysilk --- APIs See test\test.py. import pysilk as m m.silkEncode(buf , 24000) m.silkDecode(buf , 24000) #the first param is b

DCZ_Yewen 16 Oct 11, 2022
hb-xlib bindings for Harbour language.

hb-xlib hb-xlib is a Harbour module providing bindings for the Xlib graphics library. This project is intended for people who want to start to program

Rafał Jopek 1 Feb 6, 2022