Skip to content

Conversation

artificiel
Copy link
Contributor

No description provided.

@eduardfrigola
Copy link
Contributor

Hi @artificiel

I found that with this change it stills fails to compile ofParameter<std::vector<ofPath>>.

@ofTheo
Copy link
Member

ofTheo commented Mar 3, 2025

Hi @artificiel

I found that with this change it stills fails to compile ofParameter<std::vector<ofPath>>.

Wow - that's a wild type to try and use. :)
Is there any reason we would want that to compile?

Or is that to illustrate a bigger issue?

@eduardfrigola
Copy link
Contributor

I know is a wild type to use....

The story behind it is that in ofxOceanode, we wanted to make it fast and easy to convert of sketches (apps with minimal code) to oceanode nodes. So you can have modulation, osc control, midi functionality and preset system without much effort.

That meant that ofParameter was chosen as the type for the parameters that could be modulated, but also designed so the output of each node is also an ofParameter, and here is where you can really use any type for ofParameter, and the only interest in here is that in can be put in a ofParameterGroup and you can listen to events when the parameter has changed (and that drives all the logic inside and gui creation).
I'm refactoring this so that creating nodes from ofParameter is an option and not a requirement, and to implement a custom parameter class that suits ofxOceanode needs.

ofParameter<vector<ofPath>> is currently used in some nodes that create vector graphics and need to send its output to other nodes that will process (or render) this paths. See: https://github.com/PlaymodesStudio/ofxOceanodeVectorGraphics/blob/13c87d6ccdbe898eec51a7a25751c618a5d1d128/src/ofxOceanodeVectorGraphics.h#L17-L116

Concerning this pull request, I just wanted to illustrate that still not all types can be compiled due to the addition of init() / reinit() and related to non-comparable/non-copyable objects. Objects that in 0.12.0 where valid ofParameter types and could be compiled.

@ofTheo
Copy link
Member

ofTheo commented Mar 3, 2025

Thanks for the explanation @eduardfrigola !
@artificiel is it easy to make it work as before even with weird types ?

@artificiel
Copy link
Contributor Author

@eduardfrigola haha indeed a vector as ofParameter is somewhat out there, but it's good to exercice the pattern. I don't mind at all getting odd cases as it augments malleability, and one (personal) goal is to maximize expressivity on the user side, and enabling un-planned use is a good measure of such expressivity. again this init() stuff is new anyway so it's the right time to figure out things. so please test the current PR again before it gets merged, and throw other funny things at it if you have them.

(also, I dived into ofParameter/ofEvent in an attempt to squeeze more expressivity in the type, but discovered some limits inherent to the design, which is actually a coupled cluster (ofxGui etc.). the behaviour you need (a observable container of heterogeneous classes, including itself) is supported by ofParameterGroup, but it should probably be extracted into a more generic Tree-type class, but the class hierarchy makes it hard. I have different experiments that have clearer designs (including a much cleaner ofParameter.h, which is a hairy file in itself, and difficult to split), but nothing that can slide under the current designed unnoticed, not because of "user parameter" considerations but how it ties into ofEvents). there is room for a non-OFsystem-intertwined parameter-value type).

anyhow the problem was the trait checked for the existence of operator== but not if it would actually compile wit given type <T>. as of now you cannot compare ofPaths, but you can compare vectors. however if you try to compare vectors of paths compilation will not work (which is expected — I don't see any efficient way of comparing ofPath). so now the template digs a little deeper; not really complicated and actually more correct.

i also found a small return value bug, and this closes #8332 too, by prioritizing actual value assignment over silently creating an ofParameter wrapper that gets immediately thrown away.

@artificiel artificiel changed the title fix(ofParameter): better default init() handling of non-comparable/non-copyable objects fix(ofParameter): better default init() handling of non-comparable/non-copyable objects and containers Mar 3, 2025
@eduardfrigola
Copy link
Contributor

Thanks @artificiel!
Now seems to fix all the issues in my use case!

@ofTheo ofTheo merged commit b1f0902 into openframeworks:master Mar 3, 2025
15 checks passed
@ofTheo
Copy link
Member

ofTheo commented Mar 3, 2025

Thanks @artificiel @eduardfrigola !!

@eduardfrigola
Copy link
Contributor

Thanks everyone! Closing resolved issues by this.

@artificiel artificiel deleted the ofParameter-moreinit branch March 4, 2025 03:30
danoli3 added a commit that referenced this pull request Mar 13, 2025
* commit '5630d2034d835e81225a225355e97f4144b21179': (446 commits)
  Restore target build dir behavior for Xcode. Closes #8321 (#8340)
  of script updates (#8339)
  _OBJC_CLASS_$_AVFoundationVideoPlayer fix (#8337)
  poco mk (#8336)
  relative locations rabbit (#8335)
  fix(ofParameter): better default init() handling of non-comparable/non-copyable objects and containers (#8325)
  path to string conversion on Windows fix. (#8333)
  iOS template add ofxiOS group ref (#8330)
  Xcode iOS Target Project Fixes (#8328)
  chore(iOS): remove iosNativeARCExample (#8324)
  ofxGui fix for apple targets (#8320)
  assimp ios addon_config (#8319)
  chore(iOS): remove GLKit example (#8317)
  fix(iOS): adjustments to layout of Location example + deprecations updates (#8311)
  fix(iOS): update to CoreLocation authorization request (#8309)
  remove boost from android. (#8307)
  Remove boost from linux scripts, download_libs (#8306)
  ofPixels memory allocation size fix (#8226)
  remove boost references from CoreOF.xcconfig and config.*.default.mk for macOS and osx. (#8304)
  Fix to json scripts (#8301)
  ...

# Conflicts:
#	.gitignore
#	libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp
#	libs/openFrameworks/gl/ofGLUtils.h
#	libs/openFrameworks/gl/ofShader.cpp
#	libs/openFrameworks/gl/ofTexture.h
#	libs/openFrameworks/graphics/ofTrueTypeFont.cpp
#	libs/openFrameworks/graphics/ofTrueTypeFont.h
#	libs/openFrameworks/sound/ofAVEngineSoundPlayer.h
#	libs/openFrameworks/sound/ofSoundBaseTypes.cpp
#	libs/openFrameworks/sound/ofSoundBaseTypes.h
#	libs/openFrameworks/sound/ofSoundStream.cpp
#	libs/openFrameworks/utils/ofConstants.h
#	libs/openFrameworks/utils/ofThread.h
#	libs/openFrameworks/utils/ofURLFileLoader.cpp
#	libs/openFrameworks/utils/ofUtils.h
#	libs/openFrameworks/utils/ofXml.h
#	libs/openFrameworksCompiled/project/android/build.gradle
#	libs/openFrameworksCompiled/project/android/common-functions.gradle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants