I've taken a look at this, and I think it's probably time to call it quits on this issue. You've gotten it far enough that I think we can see that it could be made to work with some more effort, but we can also see what the tradeoff of a complete solution would look like - it'd be ton of macros (to support all different possible numbers of subcomponents, support new scalar outputs that don't have predefined subcomponents, and just generally polish this up), and probably a bit of bloat in the result objects to hold all the extra function pointers.
IMO, that tradeoff isn't worth it; I think the amount of hard-to-maintain macro code we'd end up putting in the framework would be larger than the amount of boilerplate we saved in all future plugins. I'm also worried that our potential reviewers (K-T and RHL in particular) are perhaps even more hostile to preprocessor macros than I am (that's why Source.h is generated using M4 rather than the preprocessor, for instance).
Do you agree, or do you think there's more to be done here? I do appreciate your work on this, as I think it's important to be able to rule out designs like this one and the others you already looked into.
This is a prototype of a ResultKey for a Result object which uses macros and generic routines. The code specific to the Result (in this case SdssShapeResult) is in the macros. (MAKE_RESULT_FIELD and INIT_RESULT_FIELDS3)
This prototype is not really completely done, but it is enough to demonstrate the concept.
Some limitations on this implementation:
1. I removed the scalar members of SdssShape because the code assumes that all of the members of the Result object have been defined in Results.h (essentially as what we called components in the past). I need to define a second "MAKE" macro to make this work with scalars.
2. I for some reason was not able to make macros with omitted arguments work, so I had to change FluxUtilities to add an UNCERTAINTY argument. Probably not necessary.
3. I never got the static initialization of my function arrays to work, so I was forced to add an init() method to initialize these arrays as instance variables. I think someone who knows C++ better than I do could fix this.