0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TimeWindow.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
27 
28 #ifndef Common_TimeWindow_h
29 #define Common_TimeWindow_h
30 
31 #include <Common/Crontab.h>
32 
33 #include <vector>
34 
35 namespace Hypertable {
36 
39 
61  class TimeWindow {
62  public:
63 
65  TimeWindow() : m_within_window(false), m_enabled(true) { }
66 
74  TimeWindow(std::vector<String> crontab_specs);
75 
87  bool update_current_time(time_t now=0);
88 
93  bool within_window() const { return m_within_window && m_enabled; }
94 
97  void enable_window(bool enable) { m_enabled = enable; }
98 
101  bool is_window_enabled() const { return m_enabled; }
102 
103  private:
104 
106  std::vector<Crontab> m_crontabs;
107 
110 
112  bool m_enabled;
113  };
114 
116 }
117 
118 #endif // Common_TimeWindow_h
bool within_window() const
Tests to see if current time is within the window.
Definition: TimeWindow.h:93
bool m_within_window
Set to true if currently within the time window.
Definition: TimeWindow.h:109
Defines a time window.
Definition: TimeWindow.h:61
bool update_current_time(time_t now=0)
Logically sets the current time.
Definition: TimeWindow.cc:58
bool is_window_enabled() const
Indicates if the time window is enabled or disabled.
Definition: TimeWindow.h:101
Hypertable definitions
bool m_enabled
Set to true if the time window is enabled.
Definition: TimeWindow.h:112
void enable_window(bool enable)
Enables or disables this time window.
Definition: TimeWindow.h:97
TimeWindow()
Default constructor.
Definition: TimeWindow.h:65
Crontab class for periodic events.
std::vector< Crontab > m_crontabs
Vector of Crontab objects that define each subwindow.
Definition: TimeWindow.h:106