openframeworks / ofxAddonTemplate

an empty ofxAddon folder structure for easy creating your own addon for openFrameworks
http://ofxaddons.com/howto
Other
77 stars 34 forks source link

is an addon present? #9

Open bakercp opened 11 years ago

bakercp commented 11 years ago

@obviousjim and I were talking about conditional includes for addon header / impl files and thought that it might be useful to suggest that all addons specify a #define that announces the addon's presence to the system. That way other addons can conditionally include bridge classes. A proposal would be something like ... in the main class ofxMyAddon.h a define like:

#define DEFINE_OFX_MYADDON

And then in the bridge classes of a dependent addon like ofxMyAddonThatDependsOnofxMyAddon.h one would do something like:

#ifdef DEFINE_OFX_MYADDON`

my special class that required OFX_MYADDON

#endif

Right now it is possible to specify required addon dependencies in addon_config.mk, but this is addressing the situation where an addon can optionally add features if an addon is present.

@arturoc @atduskgreg @bilderbuchi

bilderbuchi commented 11 years ago

Hm, is there no way we can do this automatically, e.g. during the build process generate the defines from the list of parsed addons? The make-work character of this define (i.e. have a define which basically echoes the filename) makes me feel we should be able to automate this?

The problem I see is that we have to get every addon author to add this special include, and it will be "only" useful for a subset of users, i.e. people who write addons which depend on some special functionality in another addon. It would be better if we could have a system where the dependent addon author would be the only one who would have to do something (i.e. the ifded above) to make this work for him.

bakercp commented 11 years ago

Good point @bilderbuchi -- it's very easy to do with the new makefile system, but wasn't sure how it would play out in other project files. I suppose an update project generator could also take care of this.

gsautr commented 6 years ago

Hello, was the feature suggested by @bilderbuchi added?