Changeset 93abe8
- Timestamp:
- Apr 2, 2011, 12:11:44 AM (15 years ago)
- Children:
- 8e24ef
- Parents:
- 6b898c
- git-author:
- Frederik Heber <heber@…> (03/14/11 17:54:03)
- git-committer:
- Frederik Heber <heber@…> (04/02/11 00:11:44)
- Location:
- src
- Files:
-
- 4 added
- 5 edited
-
Helpers/Chronos.cpp (added)
-
Helpers/Chronos.hpp (added)
-
Helpers/Info.cpp (modified) (4 diffs)
-
Helpers/Info.hpp (modified) (3 diffs)
-
Makefile.am (modified) (2 diffs)
-
unittests/ChronosUnitTest.cpp (added)
-
unittests/ChronosUnitTest.hpp (added)
-
unittests/InfoUnitTest.cpp (modified) (1 diff)
-
unittests/Makefile.am (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Helpers/Info.cpp
r6b898c r93abe8 20 20 #include "MemDebug.hpp" 21 21 22 #include "Chronos.hpp" 22 23 #include "Info.hpp" 23 24 #include "Log.hpp" … … 25 26 26 27 int Info::verbosity = 0; 28 Chronos * Info::timekeeper = NULL; 29 bool Info::ChronosBlocker = false; 30 size_t Info::NumberInfos = 0; 27 31 28 32 /** … … 36 40 verbosity++; 37 41 DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl); 38 }; 42 43 // one more info object 44 ++NumberInfos; 45 46 // have pointer ready 47 if (timekeeper == NULL) { 48 timekeeper = Chronos::getPointer(); 49 } 50 51 // start time keeping 52 timekeeper->startTiming(FunctionName); 53 } 39 54 40 55 /** 41 56 * Destructor. Better use purgeInstance(). 42 57 */ 43 Info::~Info() { 58 Info::~Info() 59 { 60 // end time keeping 61 timekeeper->endTiming(FunctionName); 62 63 // verbosity stuff 44 64 DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl); 45 65 verbosity--; 66 67 // one info object less 68 --NumberInfos; 69 70 // we are last one? 71 if (!NumberInfos) { 72 timekeeper = NULL; 73 } 46 74 } 47 75 … … 51 79 * \param verbosityLevel verbosity 52 80 */ 53 void Info::setVerbosity(int verbosityLevel) { 81 void Info::setVerbosity(int verbosityLevel) 82 { 54 83 verbosity = verbosityLevel; 55 84 } -
src/Helpers/Info.hpp
r6b898c r93abe8 14 14 #endif 15 15 16 #include <string> 17 18 class ChronosTest; 19 16 20 /*********************************************** includes ***********************************/ 17 21 … … 21 25 22 26 class Info { 27 //!> unit tests needs access to some internals 28 friend class ChronosTest; 23 29 public : 24 30 static int verbosity; 25 const char *FunctionName;31 const std::string FunctionName; 26 32 27 33 Info(const char *msg); … … 29 35 static void setVerbosity(int verbosityLevel); 30 36 37 private: 38 static class Chronos * timekeeper; 39 static bool ChronosBlocker; 40 static size_t NumberInfos; 31 41 }; 32 42 -
src/Makefile.am
r6b898c r93abe8 61 61 Patterns/Observer.cpp \ 62 62 Helpers/Assert.cpp \ 63 Helpers/Chronos.cpp \ 63 64 Helpers/errorlogger.cpp \ 64 65 Helpers/Info.cpp \ … … 71 72 HELPERSHEADER = \ 72 73 Helpers/Assert.hpp \ 74 Helpers/Chronos.hpp \ 73 75 Helpers/enumeration.hpp \ 74 76 Helpers/errorlogger.hpp \ -
src/unittests/InfoUnitTest.cpp
r6b898c r93abe8 59 59 class Info test(msg); 60 60 61 CPPUNIT_ASSERT_EQUAL( msg, test.FunctionName );61 CPPUNIT_ASSERT_EQUAL( std::string(msg) , test.FunctionName ); 62 62 CPPUNIT_ASSERT_EQUAL( 1, test.verbosity ); 63 63 }; -
src/unittests/Makefile.am
r6b898c r93abe8 13 13 TESTS = \ 14 14 AssertUnitTest \ 15 ChronosUnitTest \ 15 16 InfoUnitTest \ 16 17 IteratorAdaptorsUnitTest \ … … 47 48 $(top_srcdir)/src/Patterns/unittests/stubs/RegistryStub.cpp \ 48 49 AssertUnitTest.cpp \ 50 ChronosUnitTest.cpp \ 49 51 InfoUnitTest.cpp \ 50 52 LogUnitTest.cpp \ … … 80 82 $(top_srcdir)/src/Patterns/unittests/stubs/RegistryStub.hpp \ 81 83 AssertUnitTest.hpp \ 84 ChronosUnitTest.hpp \ 82 85 InfoUnitTest.hpp \ 83 86 LogUnitTest.hpp \ … … 89 92 AssertUnitTest.hpp 90 93 AssertUnitTest_LDADD = ${TESTLIBS} 94 95 ChronosUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 96 ChronosUnitTest.cpp \ 97 ChronosUnitTest.hpp 98 ChronosUnitTest_LDADD = ${TESTLIBS} 91 99 92 100 InfoUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.
