From 6b0a0145a52356c8211e76e19659fc32cef68f7b Mon Sep 17 00:00:00 2001 From: Rene Milk <koshi@springlobby.info> Date: Fri, 17 Jul 2009 13:31:24 +0200 Subject: [PATCH] prohibit direct instantiation of logger and profiler, force to use the global --- stuff/logging.hh | 5 ++++- stuff/profiler.hh | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/stuff/logging.hh b/stuff/logging.hh index ffbd53dd3..8681b95f4 100644 --- a/stuff/logging.hh +++ b/stuff/logging.hh @@ -221,6 +221,7 @@ public: } }; +protected: Logging() { streamIDs_.push_back(LOG_ERR); @@ -248,7 +249,7 @@ public: Stuff::safe_delete(matlabLogStreamPtr); } - +public: /** \brief setup loglevel, logfilename \param logflags any OR'd combination of flags \param logfile filename for log, can contain paths, but creation will fail if dir is non-existant @@ -464,6 +465,8 @@ private: IdVec streamIDs_; int logflags_; MatlabLogStream* matlabLogStreamPtr; + + friend Logging& Logger(); }; /// global Logging instance diff --git a/stuff/profiler.hh b/stuff/profiler.hh index 88b25235d..72ccd9a97 100644 --- a/stuff/profiler.hh +++ b/stuff/profiler.hh @@ -33,8 +33,9 @@ typedef std::vector<DataMap> MapVector; **/ class Profiler { + friend Profiler& profiler(); -public: +protected: Profiler() { Reset(1); @@ -43,6 +44,7 @@ public: { } +public: //! set this to begin a named section inline void StartTiming(const std::string section_name) { -- GitLab