Giter VIP home page Giter VIP logo

ofxplugin's Introduction

Introduction

Write a plugin in openFrameworks. Write an app which can load those plugins at runtime in openFrameworks. You have:

  • Application has main.cpp
  • Plugin has plugin.cpp

Example pattern:

  • Application contains an abstract class definition BaseShape
  • Plugin has a class CircleShape which inherits BaseShape
  • Application loads Plugin, and now can create instances of CircleShape

Naming conventions:

  • Module - A (non-abstract) class which the Plugin provides (this is the content of your plugin, your plugin may define 1 or more Modules)
  • ModuleBaseType - A (abstract) class which the Module inherits from
  • Factory<Module> - A class which can instantiate other classes, e.g. a Factory<MyModule> can create instances of MyModule class
  • FactoryRegister<ModuleBaseType> - A class which contains a list of Factorys. All the Factorys inside this register will create Modules which inherit from ModuleBaseType.

Requirements / Compatability

Currently runs on oF 0.9.0 in Windows. Thanks to work by @satoruhiga, ofxPlugin will compile in OSX without issues, but the main plugin loading features are still untested.

Tested on Visual Studio 2015, but should work on earlier versions too (be aware of changing the Platform Toolset option in all the relevant projects).

Addon dependencies

You must have the following addons available in your addons folder:

  • ofxSingleton (tested with 3af7ff04ff2fcb71a11c0960e8dfe32f043f4165 on 2015/10/08)
  • ofxAddonLib (tested with 6c3b3a6bfcaacf8b6340abb8444030e604b65e89 on 2015/10/08)

Notes

Usage pattern

A Factory is something which instantiates classes for you. For each module (i.e. class type), you'll have one Factory which can instantiate that class at runtime.

ofxPlugin provides a FactoryRegister where you can store all these factories. When you load a plugin, it adds the factories from that plugin to the FactoryRegister

Your ModuleBaseType must be a non abstract class, i.e. it cannot have something like virtual void draw() = 0;. This hurts I know, but it's necessary for a factory model to work in many situations.

Your plugin needs references to openframeworksLib, ofxSingletonLib, and anything else it references.

Current limitations / Known issues

  • All plugins in one dll must inherit from the same ModuleBaseType
  • Plugins are never unloaded until the application terminates (you can still manually remove factories from the FactoryRegister).

ofxplugin's People

Contributors

elliotwoods avatar tgfrerer avatar satoruhiga avatar

Watchers

James Cloos 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.