Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
dispatch_receiver_set.h
Go to the documentation of this file.
1 /* Libmacro - A multi-platform, extendable macro and hotkey C library
2  Copyright (C) 2013 Jonathan Pelletier, New Paradigm Software
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
22 #ifndef __cplusplus
23  #pragma message "C++ support is required for extras module"
24  #include "mcr/err.h"
25 #endif
26 
27 #ifndef MCR_EXTRAS_DISPATCH_RECEIVER_SET_H_
28 #define MCR_EXTRAS_DISPATCH_RECEIVER_SET_H_
29 
30 #include "mcr/extras/base_cpp.h"
31 
32 namespace mcr
33 {
35 class DispatchReceiverSetPrivate;
40 class MCR_API DispatchReceiverSet
41 {
42  friend class DispatchReceiverSetPrivate;
43 public:
44  DispatchReceiverSet(mcr_DispatchReceiver **applyReceiversPt = nullptr,
45  size_t *applyCountPt = nullptr);
47  virtual ~DispatchReceiverSet();
48  DispatchReceiverSet &operator =(const DispatchReceiverSet &);
49 
50  virtual void add(void *receiver, mcr_dispatch_receive_fnc receiverFnc);
51  virtual void clear();
52  virtual void remove(void *remReceiver);
53  virtual void trim();
54 
55  virtual mcr_DispatchReceiver *array() const;
56  virtual mcr_DispatchReceiver *find(void *receiver) const;
57  virtual size_t count() const;
58  inline size_t size() const
59  {
60  return count();
61  }
62  inline bool empty() const
63  {
64  return !count();
65  }
68  virtual void apply();
71  virtual void apply(mcr_DispatchReceiver *receivers, size_t count)
72  {
73  if (applicable()) {
74  *_applyReceiversPt = receivers;
75  *_applyCountPt = count;
76  }
77  }
78 
79  virtual mcr_DispatchReceiver **applyReceiversPt() const
80  {
81  return _applyReceiversPt;
82  }
83  virtual void setApplyReceiversPt(mcr_DispatchReceiver **applyReceiversPt);
84  virtual size_t *applyCountPt() const
85  {
86  return _applyCountPt;
87  }
88  virtual void setApplyCountPt(size_t *applyCountPt);
89  inline bool applicable() const
90  {
91  return _applyReceiversPt && _applyCountPt;
92  }
93  virtual void setApplyReceivers(mcr_DispatchReceiver **applyReceiversPt,
94  size_t *applyCountPt);
95 private:
96  mcr_DispatchReceiver **_applyReceiversPt;
97  size_t *_applyCountPt;
98 
99  DispatchReceiverSetPrivate *_private;
100 };
101 }
102 
103 #endif
bool(* mcr_dispatch_receive_fnc)(struct mcr_DispatchReceiver *dispatchReceiver, struct mcr_Signal *dispatchSignal, unsigned int mods)
Definition: types.h:50
Raise a compiler error. Usage: #include "mcr/err.h"
Libmacro, by Jonathan Pelletier, New Paradigm Software. Alpha version.
Definition: classes.h:31
virtual void apply(mcr_DispatchReceiver *receivers, size_t count)