foobar2000 SDK  2015-01-14
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() {}
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)
virtual void unregister_callback(system_time_callback *callback)=0
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
virtual void on_time_changed(t_filetimestamp newVal)=0
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 api; api->doso...
Definition: service.h:533
virtual void register_callback(system_time_callback *callback, t_filetimestamp resolution)=0
The callback object receives an on_changed() call with the current time inside the register_callback(...