openframeworks / openframeworks/openFrameworks
missing copy and move constructors and assignment operators
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
There's several classes in the core and probably in the addons that should have copy and move constructors and assignment operators.
by the rule of 3 (the rule of 5 since c++11) everything that has a destructor needs mostly sure a copy and move constructor and assignment operator.
in most objects where we have destructors is just an empty virtual one which is usually fine but there's several objects that use a destructor to unassing themselves from an event. that means that at some point they registered to an event.
if those objects are copied with the default copy constructor the copies won't be registered to the event anymore.
the best way to solve this rather than implementing those constructors which would be really verbose and error prone would be avoiding the destructor altogether.
a possible solution for the cases where the destructor is needed to unregister from an even would be to have some kind of polling event. an object that would register itself to an event and accumulate the events on a queue, then it could be queried to check for new events, it would auto unregister it self from the event on destruction and do the right thing on copy or move.
the object containing it would be able to ask for new events on update or a similar call with an api similar to ofThreadChannel (it could even be just a new constructor of method for ofThreadChannel):
class MyClass{
public:
MyClass(){
mousePolling.register(ofEvents().mouseMoved);
}
void update(){
ofMouseEventArgs mouse;
if(mousePolling.tryReceive(mouse)){
// do something with mouse movement
}
}
}
this particular example probably doesn't make much sense cause there's already functions to check the state of the mouse but it will be useful for other cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the event-registration and destruction patterns across the core and addons, then read the existing ofThreadChannel API mentioned in the proposal. Determine which classes are affected and whether polling events or explicit copy/move operations are the intended direction. Done requires an agreed, testable design and coverage for copying, moving, registration, and destruction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100