stats: Method stats source
Review Request #2241 - Created April 23, 2014 and submitted
| Information | |
|---|---|
| Andreas Hansson | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 10193:ae6a0ea78f4f --------------------------- stats: Method stats source This source for stats binds an object and a method / function from the object to a stats object. This allows pulling out stats from object methods without needing to go through a global, or static shim. Syntax is somewhat unpleasant, but the templates and method pointer type specification were quite tricky. Interface is very clean though; and similar to .functor
Posted (April 23, 2014, 10:01 a.m.)
This is cool, but it'd be better to just change FunctorProxy to be more generic. If FunctorProxy held a std::function<Counter()> (instead of the T*), then anything that took no arguments and returned a stats::Counter could be used. This would allow pretty much everything to be used: functions, classes, lambdas, and anything in <functional>. For the specific case you're trying to solve for, you could simply use a lambda or std::mem_fn and std::bind to wrap objects. Check out: http://en.cppreference.com/w/cpp/utility/functional
Posted (April 23, 2014, 10:01 a.m.)
This is cool, but it'd be better to just change FunctorProxy to be more generic. If FunctorProxy held a std::function<Counter()> (instead of the T*), then anything that took no arguments and returned a stats::Counter could be used. This would allow pretty much everything to be used: functions, classes, lambdas, and anything in <functional>. For the specific case you're trying to solve for, you could simply use a lambda or std::mem_fn and std::bind to wrap objects. Check out: http://en.cppreference.com/w/cpp/utility/functional
