Giter Site home page Giter Site logo

Introduction

welcome to ZFFramework, a cross-platform and powerful application framework in C++

everything here starts with "ZF", which stands for "Zero Framework"

  • it's not a traditional framework, can be loaded like a dynamic library, plug and play
  • designed to be able to run at any platform that supplies C++03 compatible implementation

Homepage:

Quick overview

cpp hello world

this piece of code shows how to show a hello world on UI and log output

#include "ZFUIWidget.h" // for common UI module
ZFMAIN_ENTRY() { // app starts from here
    // show a hello world to log output
    zfLog() << "hello wolrd";

    // show a window (full screen by default)
    zfblockedAlloc(ZFUIWindow, window);
    window->windowShow();

    // show a hello world as a text view
    zfblockedAlloc(ZFUITextView, textView);
    window->childAdd(textView)->c_alignTop()->c_margin(40);
    textView->text("hello world");

    // button and click (as observer)
    zfblockedAlloc(ZFUIButtonBasic, button);
    window->childAdd(button)->c_alignBottom()->c_margin(40);
    button->label()->text("click me");
    ZFLISTENER(onClick) {
        ZFUIButtonBasic *button = zfargs.sender();
        zfLogTrim() << "button clicked: " << button;
    } ZFLISTENER_END()
    button->onClick(onClick);
}

lua hello world

this piece of code shows equivalent lua code to use ZFFramework, all the lua bindings are automatically done by reflection!

zfLog('hello world')

local window = ZFUIWindow()
window:windowShow()

local textView = zfAlloc('ZFUITextView')
window:childAdd(textView):alignTop():margin(40)
textView:text('hello wolrd')

local button = ZFUIButtonBasic.ClassData():newInstance()
window:childAdd(button):alignBottom():margin(40)
button:label():text('click me')
button:onClick(
    function (zfargs)
        zfLog('button clicked: %s', zfargs:sender())
    end,
    button:objectHolder())

further more, it's easy to run lua code in thread (real native thread, not lua coroutine):

local capture = 123
zfLog('thread: %s, capture: %s', ZFThread.currentThread(), capture)
zfasync(function(zfargs)
        zfLog('thread: %s, capture: %s', ZFThread.currentThread(), capture)
    end)

powerful dynamic register

both lua and cpp can dynamic register class and method

#include "ZFLua.h"
ZFMAIN_ENTRY() {
    ZFDynamic()
        .classBegin("MyBaseView", "ZFUIView")
            .method("void", "testFunc", ZFMP()
                .mp("zfstring", "testParam0")
                , [](const ZFArgs &zfargs) {
                    ZFMethodInvokeData *m = zfargs.param0();
                    zfLogTrim() << m->invokerMethod << " called, param0: " << m->param0;
                })
        .classEnd();

    ZFLuaExecute(
        "ZFDynamic()\n"
        "    :classBegin('MyChildView', 'MyBaseView')\n"
        "        :method('void', 'testFunc', ZFMP()\n"
        "            :mp('zfstring', 'testParam0')\n"
        "            , function(zfargs)\n"
        "                local m = zfargs:param0()\n"
        "                m:callSuper()\n"
        "                zfLogTrim('%s called, param0: %s', m:invokerMethod(), m:param0())\n"
        "            end)\n"
        "    :classEnd()\n"
        "\n"
        "local myView = MyChildView()\n"
        "myView:testFunc('luaParam0')\n"
    );

    zfauto obj = ZFClass::classForName("MyChildView")->newInstance();
    obj->invoke("testFunc", zflineAlloc(v_zfstring, "cppParam0"));

    ZFMethodAlias(ZFMethodForName("MyChildView", "testFunc"), "testAliased");
    ZFLuaExecute(
        "local myView = MyChildView()\n"
        "myView:testAliased('luaParam0')\n"
    );
}

powerful abstract IO

chain http file and zip file, and R/W contents in the zip file just like normal local file

#include "ZFCore.h"
ZFMAIN_ENTRY() {
    ZFResExtPathAdd("ZFCompress:http:http://192.168.xxx.xxx/xxx.zip|");
    ZFInputRead(zfLogTrim(), ZFInputForRes("path/in/zip/file.txt"));
    ZFPathInfoTreePrint(ZFPathInfo("res:"));
}

Getting started

  • Download necessary files
  • Setup set up necessary environment for ZFFramework
  • Tutorial quick tutorial to code with ZFFramework
  • FAQ

Detailed

Requirement

  • for the core modlue:

    • C++03 compatible compiler (require templates, no boost/RTTI/exceptions required)
    • STL containers (require: map/unordered_map/vector/deque/list), or supply custom wrapper
  • for the implementation module:

    • depends on the actual platform implementation

Main features

  • minimum requirement

  • powerful reflection, serialzation, styleable logic

    • for how powerful ZFFramework is, you may refer to Feature page
    • automatic lua binding, no extra bind code or config are necessary
    • automatic serialization
    • enhanced global event observer and event filter
  • fully modularization, "core + protocol + dynamic implementation" design

    support any platform if you are able to supply a native C++ implementation, most of implementation can be replaced easily, and implementation is required only if its owner module being used

  • easy to communicate with native code

    even to embed UI elements and native UI elements with each other

  • UI module to write cross-platform UI easily

  • built-in auto scale logic to support multiple screen size

    you have no need to write size-dependent code in both app and implementation

Current status

  • finished
    • core module (memory management, reflection, serialization)
    • basic UI module (view, window, label, image view, button, layout, scroll view, list view)
    • basic algorithm (xml, json, regexp, md5, base64, crc32, encryption, compression)
    • common platform implementations (iOS, Android, Qt)
    • auto lua binding by reflection
  • working
    • more useful UI modules
    • basic network module
    • basic database module
  • future
    • standalone visual UI editor
    • more IDE / compile env integrations
    • more platform implementations

What we do

  • aiming to be portable and can be ported easily, aiming to be lightweighted and able to be embeded easily, you may simply drag and drop all src files to your build system
  • fully dynamic, extensible

License

ZFFramework is under MIT license (see here), feel free to copy or modify or use it

if you like my work, buy me a coffee?

zfframework's Projects

eluna icon eluna

simple library to bind C/C++ and Lua(support lua 5.3/5.2/5.1)

zfframework icon zfframework

cross-platform C++ application framework, fully dynamic reflection/serialization, automatic lua binding by reflection

zfloader icon zfloader

a dummy app that load zf.lua from external storage

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.