class SomeStruct{ type SomeVariable;public: type GetSomeVariable() const { return this->SomeVariable; }};
I ran into this (and it would be very common occurrence seeing as how a lot of data is hidden) and I've been trying to come up with a solution.
The first idea was quite simple using BOOST and the StatVariableBase class:
template class FunctionResultStat : public StatVariableBase{ boost::function Functor;public: FunctionResultStat(boost::function Functor) : Functor(Functor) { } // Error handling would be needed below. string ToString() const { return boost::lexical_cast(Functor()); }};
However, that's quite limiting and kind of hackish.
The "best" solution I can come up with is just creating a new class for each function (like my TimeSinceStartStat from yesterday), but that's not really a "usable" solution.
The only other idea I've come up with so far is using the FunctionResultStat and overloading it, allowing for up to 10 different parameters. Won't be the prettiest solution, but it'll be a lot better than using macros.
No matter how I go about it, there is also the fact that it's limited to types that can be cast via boost::lexical_cast.
[edit]
I think I've decided that to add this is just too much hacking. On to more important things (suggestions are still welcome if anyone has any.)
Any suggestions?
Of course, if you need to store different types of stats, I would do something silly like this:
But that's just me.