foobar2000 SDK  2015-08-03
system_time_keeper.h
Go to the documentation of this file.
1 namespace system_time_periods {
3  static const t_filetimestamp minute = second * 60;
4  static const t_filetimestamp hour = minute * 60;
5  static const t_filetimestamp day = hour * 24;
6  static const t_filetimestamp week = day * 7;
7 };
9 public:
10  virtual void on_time_changed(t_filetimestamp newVal) = 0;
11 };
14 public:
16  virtual void register_callback(system_time_callback * callback, t_filetimestamp resolution) = 0;
17 
18  virtual void unregister_callback(system_time_callback * callback) = 0;
19 
20  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(system_time_keeper)
21 };
22 
24 public:
25  system_time_callback_impl() : m_registered() {}
26  ~system_time_callback_impl() {stop_timer();}
27 
28  void stop_timer() {
29  if (m_registered) {
30  static_api_ptr_t<system_time_keeper>()->unregister_callback(this);
31  m_registered = false;
32  }
33  }
36  stop_timer();
37  static_api_ptr_t<system_time_keeper>()->register_callback(this, period);
38  m_registered = true;
39  }
40 
42 
43  PFC_CLASS_NOT_COPYABLE_EX(system_time_callback_impl)
44 private:
45  bool m_registered;
46 };
47 
static const t_filetimestamp filetimestamp_1second_increment
Definition: filesystem.h:18
void on_time_changed(t_filetimestamp newVal)
static const t_filetimestamp day
void initialize_timer(t_filetimestamp period)
You get a on_changed() call inside the initialize_timer() call.
static const t_filetimestamp minute
static const t_filetimestamp week
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
static const t_filetimestamp second
static const t_filetimestamp hour
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533