Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Checkpoint.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author
13 
14 
15 #ifndef INCLUDED_protocols_checkpoint_Checkpoint_hh
16 #define INCLUDED_protocols_checkpoint_Checkpoint_hh
17 
19 
20 // C++ Headers
21 #include <ctime>
22 
23 namespace protocols {
24 namespace checkpoint {
25 
26 
27 void checkpoint_with_interval( const int interval_in );
28 
29 
30 ///////////////////////////////////////////////////////////////////////////////
31 /// @brief: singleton checkpoint timer class
32 ///
33 /// @detailed: Keeps track of when to checkpoint using a time interval.
34 /// Not thread safe.
35 ///
36 /// @authors David K
37 ///
38 /// @last_modified December 7 2007
39 ///////////////////////////////////////////////////////////////////////////////
40 class Timer {
41 
42 
43 
44 public:
45 
46  static Timer& instance(void);
47 
48  void set_interval( const int interval_in );
49  static bool is_on(void);
50  static bool time_to_checkpoint(void);
51  static void reset(void);
52 
53 private:
54  Timer(void) {
55  if (!is_on_) time(&time_);
56  is_on_ = true;
57  }
58 
59  static bool is_on_; // do checkpointing?
60  static int interval_; // checkpoint interval in seconds
61  static time_t time_; // time of the last checkpoint
62 
63 }; // Timer
64 
65 
66 } // checkpoint
67 } // protocols
68 
69 
70 #endif