Is this an ideal use for passing functions as an arguement...
I decided to scratch the old particle class I wrote for a new better one, the primary goal this time is I want one method to handle the "movement processing" based on certain values which a formula will manipulate.
Code:
void MovementInACircle (double a, double b, double c ) // etc...
void MovementInASquare (double a, double b, double c ) // etc...
Let's assume I define the classes method as such:
Code:
class ParticleManage
{
// ...
public:
void Process((*proc)(double, double, double));
// ...
During development I'd like to swap out different "movement patterns" to work on them individually... so I might have...
Code:
ObjInst->Process((*MovementInACirle)(1.33, 2.342, 1.23));
I'd like to achieve this effect exactly, this might not be the ideal method and maybe there's a better way.
I want all movement algorithms as a separate component to the particle manager.
Am I on the right track?
I'd go with virtual methods and then override methods, but that doesn't give me a 'dynamic' approach. I might later have controls to swap out which "movement algorithm" will be used at any given time...
I'm just not 100% sure of my approach on this, I've never used functions as arguments so before I went in to it I thought i'd get some feedback. :-)