And then have another template function declaration for all the attractor functions where I pass the same template value as in the first one.
As you can see, I'm calling another functions inside called attractors(_tmp). I know that one way around it could be to get rid of that function and just do all the logic inside of each if statement. Is there any way to pass the same template function parameter within a template function parameter?
> NotesController and FamiliesController have the same parent.
¿why don't you ask for the parent then?
¿what do the attractor{1..4}() functions receive as parameter? (you could use polymorphism there)
1 2 3 4
void Attractor::updateNotes(NotesController *_tmp, int _counter){
template<class TYPE>
void Attractor::updateData(TYPE* *_tmp, int _counter){
¿don't you see an extra asterisk? (replace TYPE)
The template parameter may be deduced by the types of the arguments of the function. So you wouldn't need to specify it.
If you must, then you could simply do attractor4<TYPE>(_tmp);
void Attractor::update(ParticleController *_tmp, int _counter){ // PArticleController is the parent class for both NotesController and FamiliesController
center.x = ofGetWidth()/2;
center.y = ofGetHeight()/3;
attractorCounter = _counter;
if(attractorCounter == 1){
attractor1(_tmp); // circle (2 Attractor moving same direction in same circle)
} elseif (attractorCounter == 2){ // PROBLEM HERE
attractor2(_tmp); // figure-8 (2 Attractor passing boids back n forth)
} elseif (attractorCounter == 3){
attractor3(_tmp); // flower (like circle Attractor but radius flux'es on a sine wave)
} elseif (attractorCounter == 4){
attractor4(_tmp); // flower (like circle Attractor but radius flux'es on a sine wave)
}
}
I have a feeling that passing the same value to the attractor functions is bad design. I don't come from a CS background so I could be wrong.