From 413ba1fdaf666118c9a340d0c23c466f4b7d7fee Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 10 May 2012 18:04:26 -0500 Subject: stats: track if the stats have been enabled and prevent requesting master id Track the point in the initialization where statistics have been registered. After this point registering new masterIds can no longer work as some SimObjects may have sized stats vectors based on the previous value. If someone tries to register a masterId after this point the simulator executes fatal(). --- src/base/statistics.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/base/statistics.cc') diff --git a/src/base/statistics.cc b/src/base/statistics.cc index e3f3ad78b..545d08cab 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -441,6 +441,23 @@ registerResetCallback(Callback *cb) resetQueue.add(cb); } +bool _enabled = false; + +bool +enabled() +{ + return _enabled; +} + +void +enable() +{ + if (_enabled) + fatal("Stats are already enabled"); + + _enabled = true; +} + } // namespace Stats void -- cgit v1.2.3