multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
timer.hh
1 /* <LICENSE>
2 License for the MULTOVL multiple genomic overlap tools
3 
4 Copyright (c) 2007-2012, Dr Andras Aszodi,
5 Campus Science Support Facilities GmbH (CSF),
6 Dr-Bohr-Gasse 3, A-1030 Vienna, Austria, Europe.
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 
13  * Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  * Neither the name of the Campus Science Support Facilities GmbH
19  nor the names of its contributors may be used to endorse
20  or promote products derived from this software without specific prior
21  written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
24 AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27 THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 </LICENSE> */
35 #ifndef TOOLS_TIMER_HEADER
36 #define TOOLS_TIMER_HEADER
37 
38 // == Tools header timer.hh ==
39 
40 // -- Standard headers --
41 
42 #include <vector>
43 
44 // -- Boost header --
45 
46 #include "boost/date_time/posix_time/posix_time.hpp"
47 
48 // == Class ==
49 
50 namespace multovl {
51 
52 // This is a simple wrapper around Boost's POSIX time functionality,
53 // basically a stopwatch that keeps track of a vector of time points internally
54 // and then evaluates the durations.
55 class Timer
56 {
57  public:
58 
59  // ctor: adds the 0-th timepoint at time of creation
60  Timer()
61  {
62  add_timepoint();
63  }
64 
65  // Adds the current time with usec resolution as a new timepoint
66  void add_timepoint();
67 
68  // Returns the time difference between the /later/-th and /earlier/-th timepoints.
69  // Returns /not_a_date_time/ if these indices are invalid.
70  boost::posix_time::time_duration interval(unsigned int later, unsigned int earlier = 0) const;
71 
72  private:
73 
74  typedef std::vector<boost::posix_time::ptime> timevec_t;
75  timevec_t _timepoints;
76 
77 }; // class Timer
78 
79 } // namespace multovl
80 
81 #endif // TOOLS_TIMER_HEADER
Definition: timer.hh:55