I have a question regarding a good way to handling a large number of similar classes.
I have a number of classes representing operations to perform on my data class. Now the data has to meet specific conditions specific to each operation for the operation to applicable. I need to be able to check for each operation if its applicable and to do this in each class I have a function which given a data set returns whether or not the operation can be used on that data set. Each of these operations shares a parent class.
I know lots of different ways of handling this but I haven't found one that isn't messy. On one hand I can create an instance of each operation and have an array of them and iterate through it checking each class if its applicable. This is easy in the sense that I just loop through checking. This is a messy solution in the sense I need to maintain an instance of each operation (potentially a lot of them) and when I use an instance to mutate data I then need to create a new unused instance and place it in my array. On the other hand I can have the function to check if its applicable be static. This way I don't need to have instances of each class. I do however have to have a line in my code checking each and every single class and then again when I want to apply an operation I need to lookup the class from a string and then instantiate it. This creates two very large messy functions that are just lookup functions essentially.
I'm looking for a middle ground. If I could have an array of functions it might work but I haven't figured out how to do that (I know how to make a function pointer.. but G++ gives an error if I create an array of them). Again if I could have an array of classes (not instances, the actual class to instantiate instances from) it would work even better.
If anyone has any hints I'd love to hear them, thanks.