| Last change
 on this file since 3f2719 was             8e24ef, checked in by Frederik Heber <heber@…>, 15 years ago | 
        
          | 
Chronos is so far fully working.
 Library version is now 7:0:0, API version is 1.1.0.
using either time.h or sys/times.h if present to measure timing.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.5 KB | 
      
      
| Rev | Line |  | 
|---|
| [a80f419] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
|  | 4 | * Copyright (C)  2010 University of Bonn. All rights reserved. | 
|---|
|  | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | /* | 
|---|
|  | 9 | * Info.cpp | 
|---|
|  | 10 | * | 
|---|
|  | 11 | *  Created on: Nov 25, 2009 | 
|---|
|  | 12 | *      Author: heber | 
|---|
|  | 13 | */ | 
|---|
|  | 14 |  | 
|---|
|  | 15 | // include config.h | 
|---|
|  | 16 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 17 | #include <config.h> | 
|---|
|  | 18 | #endif | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include "MemDebug.hpp" | 
|---|
|  | 21 |  | 
|---|
| [93abe8] | 22 | #include "Chronos.hpp" | 
|---|
| [a80f419] | 23 | #include "Info.hpp" | 
|---|
|  | 24 | #include "Log.hpp" | 
|---|
|  | 25 | #include "Verbose.hpp" | 
|---|
|  | 26 |  | 
|---|
|  | 27 | int Info::verbosity = 0; | 
|---|
| [93abe8] | 28 | Chronos * Info::timekeeper = NULL; | 
|---|
|  | 29 | bool Info::ChronosBlocker = false; | 
|---|
|  | 30 | size_t Info::NumberInfos = 0; | 
|---|
| [a80f419] | 31 |  | 
|---|
|  | 32 | /** | 
|---|
|  | 33 | * Constructor. Do not use this function. Use getInstance() instead. | 
|---|
|  | 34 | * | 
|---|
|  | 35 | * \return Info instance | 
|---|
|  | 36 | */ | 
|---|
|  | 37 | Info::Info(const char *msg) : | 
|---|
|  | 38 | FunctionName(msg) | 
|---|
|  | 39 | { | 
|---|
|  | 40 | verbosity++; | 
|---|
| [8e24ef] | 41 | LOG(0, "INFO: Begin of "+FunctionName); | 
|---|
| [93abe8] | 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 | } | 
|---|
| [a80f419] | 54 |  | 
|---|
|  | 55 | /** | 
|---|
|  | 56 | * Destructor. Better use purgeInstance(). | 
|---|
|  | 57 | */ | 
|---|
| [93abe8] | 58 | Info::~Info() | 
|---|
|  | 59 | { | 
|---|
|  | 60 | // end time keeping | 
|---|
|  | 61 | timekeeper->endTiming(FunctionName); | 
|---|
|  | 62 |  | 
|---|
|  | 63 | // verbosity stuff | 
|---|
| [8e24ef] | 64 | LOG(0, "INFO: End of "+FunctionName); | 
|---|
| [a80f419] | 65 | verbosity--; | 
|---|
| [93abe8] | 66 |  | 
|---|
|  | 67 | // one info object less | 
|---|
|  | 68 | --NumberInfos; | 
|---|
|  | 69 |  | 
|---|
|  | 70 | // we are last one? | 
|---|
|  | 71 | if (!NumberInfos) { | 
|---|
|  | 72 | timekeeper = NULL; | 
|---|
|  | 73 | } | 
|---|
| [a80f419] | 74 | } | 
|---|
|  | 75 |  | 
|---|
|  | 76 | /** | 
|---|
|  | 77 | * Sets the verbosity. | 
|---|
|  | 78 | * | 
|---|
|  | 79 | * \param verbosityLevel verbosity | 
|---|
|  | 80 | */ | 
|---|
| [93abe8] | 81 | void Info::setVerbosity(int verbosityLevel) | 
|---|
|  | 82 | { | 
|---|
| [a80f419] | 83 | verbosity = verbosityLevel; | 
|---|
|  | 84 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.