Hello, I'm writing statistic system. It should make some output with given params. For example:
float getSunActivity() { ... }
int getEarthActivity() { ... }
StatisticSystem::track("sun_activity", boost::any(getSunActivity()));
StatisticSystem::track("earth_activity", boost::any(getEarthActivity()));
class StatisticSystem
{
typedef std::map<string, const boost::any*> stats;
stats mStatsData;
static void track(const string &name, const boost::any ¶m);
void update();
};
StaticSystem::track(const string &name, const boost::any ¶m)
{
mStatsData[name] = ¶m;
}
StaticSystem::update()
{
BOOST_FOREACH(stats::value_type &row, mStatsData)
{
string data = lexical_cast<string>(&row.second);
cout << data << "\n";
// Usage of 'data' value
}
}
Look, each update calling I need in the new value of all passed variables. So I decided to pass their addresses in the memory. But now the data consist of address. How can I receive value from it? Is it possible, if not, what could you advice for this problem?