dbus-cxx logo
timeout.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007,2008,2009,2010 by Rick L. Vinyard, Jr. *
3  * rvinyard@cs.nmsu.edu *
4  * *
5  * This file is part of the dbus-cxx library. *
6  * *
7  * The dbus-cxx library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License *
9  * version 3 as published by the Free Software Foundation. *
10  * *
11  * The dbus-cxx library is distributed in the hope that it will be *
12  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this software. If not see <http://www.gnu.org/licenses/>. *
18  ***************************************************************************/
19 #include <dbus/dbus.h>
20 #include <sys/time.h>
21 #include <sys/signal.h>
22 #include <dbus-cxx/pointer.h>
23 
24 #ifndef DBUSCXX_TIMEOUT_H
25 #define DBUSCXX_TIMEOUT_H
26 
27 namespace DBus
28 {
29 
40  class Timeout
41  {
42  protected:
43  Timeout( DBusTimeout* cobj=NULL );
44 
45  public:
46 
47  typedef DBusCxxPointer<Timeout> pointer;
48  typedef DBusCxxWeakPointer<Timeout> weak_pointer;
49 
50  static pointer create( DBusTimeout* cobj=NULL );
51 
52  ~Timeout();
53 
54  bool is_valid() const;
55 
56  operator bool() const;
57 
58  int interval() const;
59 
60  bool is_enabled() const;
61 
62  bool handle();
63 
64  bool operator==(const Timeout& other) const;
65 
66  bool operator!=(const Timeout& other) const;
67 
68  void arm(bool should_arm=true);
69 
70  bool is_armed();
71 
72  DBusTimeout* cobj();
73 
74  operator DBusTimeout*();
75 
76  protected:
77  DBusTimeout* m_cobj;
78 
79  timer_t m_timer_id;
80 
81  bool m_is_armed;
82 
83  pthread_mutex_t m_arming_mutex;
84 
85  static void timer_callback_proxy( sigval_t sv );
86 
87  };
88 
89 }
90 
91 #endif
Provides timeouts that can be armed/disarmed as necessary.
Definition: timeout.h:40
bool is_armed()
Definition: timeout.cpp:124
int interval() const
Definition: timeout.cpp:58
DBusCxxPointer< Timeout > pointer
Definition: timeout.h:47
Definition: accumulators.h:24
static pointer create(DBusTimeout *cobj=NULL)
Definition: timeout.cpp:35
DBusCxxWeakPointer< Timeout > weak_pointer
Definition: timeout.h:48
static void timer_callback_proxy(sigval_t sv)
Definition: timeout.cpp:139
bool is_valid() const
Definition: timeout.cpp:48
bool operator!=(const Timeout &other) const
Definition: timeout.cpp:81
bool operator==(const Timeout &other) const
Definition: timeout.cpp:76
bool m_is_armed
Definition: timeout.h:81
void arm(bool should_arm=true)
Definition: timeout.cpp:86
pthread_mutex_t m_arming_mutex
Definition: timeout.h:83
bool is_enabled() const
Definition: timeout.cpp:64
DBusTimeout * m_cobj
Definition: timeout.h:77
Timeout(DBusTimeout *cobj=NULL)
Definition: timeout.cpp:27
bool handle()
Definition: timeout.cpp:70
DBusTimeout * cobj()
Definition: timeout.cpp:129
~Timeout()
Definition: timeout.cpp:40
timer_t m_timer_id
Definition: timeout.h:79

Generated on Sun Mar 19 2017 14:54:27 for dbus-cxx by doxygen 1.8.8