ML Reference
MeVis/Foundation/Sources/ML/include/host/mlProcessingTimeLine.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00009 //-------------------------------------------------------------------------
00010 #ifndef __mlProcessingTimeLine_H
00011 #define __mlProcessingTimeLine_H
00012 
00013 // ML-includes
00014 #ifndef __mlInitSystemML_H
00015 #include "mlInitSystemML.h"
00016 #endif
00017 
00018 #include "mlTimeCounter.h"
00019 
00020 ML_START_NAMESPACE
00021 
00023 class MLEXPORT ProcessingTimeLine
00024 {
00025 public:
00026   ProcessingTimeLine();
00027   ~ProcessingTimeLine();
00028 
00030   void copyFrom(ProcessingTimeLine& timeline);
00031 
00033   class TimeLine
00034   {
00035     public:
00036       TimeLine(ProcessingTimeLine* owner, const std::string& name) {
00037         _name = name;
00038         _owner = owner;
00039       }
00040 
00042       struct Entry {
00043         std::string info;
00044         int processingScope;
00045         MLdouble startTime;
00046         MLdouble endTime;
00047       };
00048 
00050       int    startEntry(const std::string& info, int processingScope = 0);
00052       void   stopEntry(int entryIndex);
00053 
00054       void load(std::ifstream& stream);
00055 
00056       void save(std::ofstream& stream);
00057 
00058       void copyFrom(TimeLine& timeline);
00059 
00061       double getMinimumTime();
00062 
00064       double getMaximumTime();
00065 
00066       void clear();
00067 
00068       const std::vector<Entry>& getEntries() const { return _entries; }
00069 
00070       const std::string& name() const { return _name; }
00071 
00072   private:
00073       ProcessingTimeLine* _owner;
00074       std::string _name;
00075       std::vector<Entry> _entries;
00076   };
00077 
00079   TimeLine* addTimeLine(const std::string& name);
00080 
00082   void removeTimeLine(TimeLine* timeLine);
00083 
00085   int getNumTimeLines() const { return static_cast<int>(_timeLines.size()); }
00086 
00088   TimeLine* getTimeLine(int i) const { return _timeLines[i]; }
00089 
00091   void resetRunningTime() { _timer.reset(); }
00092 
00094   void resetTimeLines();
00095   
00097   double getRunningTime();
00098 
00100   double getMaximumTime();
00102   double getMinimumTime();
00103 
00105   void save(const std::string& fileName);
00106 
00108   void load(const std::string& fileName);
00109 
00111   void clear();
00112 
00113 private:
00114   std::vector<TimeLine*> _timeLines;
00115 
00116   TimeCounter _timer;
00117 
00118   bool _firstEntry;
00119 };
00120 
00121 ML_END_NAMESPACE
00122 
00123 #endif
00124