Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Mismatched types in static event

$
0
0

@udiskie wrote:

I need an object of class Clip to be loaded into another object of class ClipEditor (there will be multiple objects of Clip class and one object of ClipEditor class).

To do so, i think the best way is to create a static event inside Clip class, so all instances of that class broadcast the event to a single listener (the ClipEditor instance). In detail, once the Clip object is selected, it notifies to the static event and passes its memory address, so the listener executes the callback function with the selected clip’s memory address.

Obviously it does not work, and i get this error on the compiler:

/home/ivan/OF/libs/openFrameworks/events/ofEventUtils.h:103:6: note: template argument deduction/substitution failed:

/home/ivan/OF/apps/myApps/seq_6/src/ClipEditor.cpp:7:55: note: mismatched types ‘bool(ArgumentsType&)’ and ‘ClipEditor’ ofAddListener(Clip::e_select, this, &ClipEditor::load);

this is the related code:

//static event declaration in Clip.h
static ofEvent <Clip*> e_select;

//static event initialization outside Clip class scope
ofEvent <Clip*> Clip::e_select;

//adding the listener in  ClipEditor.cpp (inside ClipEditor's constructor)
ofAddListener(Clip::e_select, this, &ClipEditor::load);

//the callback function
void ClipEditor::load(Clip* _clip){}

question:

1- as i undestood, the event type must be the same data type as the value passed by ofNotifyEvent(), in this case that would be ofNotifyEvent(eventName, objAddress), am i right?

thanks in advance

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images