Coder Social home page Coder Social logo

dali-addons-example's Introduction

AddOn Example

This repository is a framework that should be used in order to build DALi addons.

Creating new AddOn

In order to create a new AddOn create a directory witin ./dali/addons and add the cmake file with build setup. The file must have a cmake extension.

AddOn build cmake file

Sample build.cmake file:

SET(ADDON_NAME "name-of-addon")  
SET(ADDON_VERSION "1.0.0")  
SET(SOURCES ${CURRENT_DIR}/source_0.cpp
            ${CURRENT_DIR}/source_1.cpp)  
SET(ADDON_ENABLED 1)

ADDON_NAME - name of the final addon library ADDON_VERSION - version of addon SOURCES - list of the source files to build the addon ADDON_ENABLED - (optional, 1 by default), if 0 the addon is excluded from the build CURRENT_DIR - the path relative to the addon source directory (must not be changed!)

Implementing the new AddOn

To implement the new AddOn the class AddOnBase should be used. AddOnBase takes care of registering the AddOn with the AddOnManager and provides interface to create dispatch tables for AddOn exported functions.

Sample implementation

#include <dali/devel-api/addons/addon-base.h>
class SampleAddOn : public Dali::AddOns::AddOnBase  
{  
public:  
  void GetAddOnInfo( Dali::AddOnInfo& addonInfo ) override  
  {  
    addonInfo.name = "SampleAddOn";  
    addonInfo.type = Dali::AddOnType::GENERIC;  
    addonInfo.next = nullptr;  
    addonInfo.version = 0u;  
  }  
  
  DispatchTable* GetGlobalDispatchTable() override  
  {  
    static DispatchTable dispatchTable;  
    if( dispatchTable.Empty() )  
    {  
      dispatchTable["TestFunction"]       = SampleAddOnNS::TestFunction;  
      dispatchTable["TestFunction2"]      = SampleAddOnNS::TestFunction2;  
      dispatchTable["TestFunctionAlias2"] = SampleAddOnNS::TestFunction2;  
    }  
    return &dispatchTable;  
  }  
  
  DispatchTable* GetInstanceDispatchTable() override  
  {  
    static DispatchTable dispatchTable;  
    if( dispatchTable.Empty() )  
    {  
      dispatchTable["TestInstanceFunction"]  = SampleAddOnNS::TestInstanceFunction;  
      dispatchTable["TestInstanceFunction2"] = SampleAddOnNS::TestInstance1;  
      dispatchTable["TestInstanceFunction3"] = SampleAddOnNS::TestInstance3;  
    }  
    return &dispatchTable; 
  }  
};  
  
REGISTER_ADDON_CLASS( SampleAddOn );

AddOnBase interface

void AddOnBase::GetAddOnInfo( Dali::AddOnInfo& addonInfo ) Function fills the Dali::AddOnInfo structure. Must be overriden by derived class.

DispatchTable* AddOnBase::GetGlobalDispatchTable() Returns valid global dispatch table or nullptr when dispatch table is unspecified.

DispatchTable* AddOnBase::GetInstanceDispatchTable() Returns valid instance dispatch table or nullptr when dispatch table is unspecified.

REGISTER_ADDON_CLASS( CLASS_NAME ) Macro registers the derived AddOn class and creates library entry point.

Setting up the dispatch table

The DispatchTable is a map-like type. It allows to create aliases for AddOn implemented functions. To add a new entry or modify existing use index operator with a string as parameter, for example:

dispatchTable["FunctionName"] = FunctionPointer;

The DispatchTable may be modified in the runtime in order to change the AddOn behaviour. For example, it is possible to map different functions in case of debugging the addon.

Building the AddOn

AddOns may use DALi internal source code.

Ubuntu

All the DALi repositories must be present next to dali-addons-example. The DESKTOP_PREFIX variable must be set (as for whole DALi build in general).

cd dali-addons-example/build/tizen
cmake .
make install

The AddOns will install at ${DESKTOP_PREFIX}/opt/lib.

Tizen

First all DALi repositories must be built using GBS and be deployed to RPMS directory of the GBS root. The Tizen AddOns build system will use the *-debugsource-*.rpm packages.

Use GBS to build Tizen addons (as for DALi libs):

gbs -c gbs.conf build --keep-packs --define "enable_trace 1" --define "enable-debug 1" --include-all --ccache --define "jobs 4"

dali-addons-example's People

Contributors

adeelkazmi avatar jsr184 avatar

Watchers

James Cloos avatar  avatar Jiyun Yang avatar  avatar  avatar  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.