Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
isignal_builder.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 
23 #ifndef MCR_EXTRAS_REFERENCES_ISIGNAL_BUILDER_H_
24 #define MCR_EXTRAS_REFERENCES_ISIGNAL_BUILDER_H_
25 
26 #include "mcr/extras/wrappers.h"
27 
28 namespace mcr
29 {
34 class MCR_API ISignalBuilder
35 {
36 public:
40  ISignalBuilder(Libmacro *context = nullptr);
41  ISignalBuilder(const ISignalBuilder &) = default;
42  virtual ~ISignalBuilder() {}
43  ISignalBuilder &operator =(const ISignalBuilder &copytron) = delete;
44 
45  inline ISignalBuilder &build(mcr_ISignal *isigPt)
46  {
47  setISignal(isigPt);
48  return *this;
49  }
50  inline ISignalBuilder &build(size_t id)
51  {
52  setId(id);
53  return *this;
54  }
55  inline ISignalBuilder &build(const char *name)
56  {
57  setName(name);
58  return *this;
59  }
60 
61  inline Libmacro &context() const
62  {
63  return *_context;
64  }
65 
71  virtual void registerType(const char *name,
72  const char * const*addNames = nullptr, size_t addNamesCount = 0);
73  virtual void unregisterType();
74 
76  virtual inline mcr_ISignal *isignal() const
77  {
78  return _isigPt;
79  }
80  inline mcr_Interface *interface() const
81  {
82  return _isigPt ? &_isigPt->interface : NULL;
83  }
84  virtual inline void setISignal(mcr_ISignal *isigPt)
85  {
86  _isigPt = isigPt;
87  }
88 
89  /* Interface */
91  virtual inline size_t id()
92  {
93  return mcr_ISignal_id(_isigPt);
94  }
95  virtual void setId(size_t val);
97  virtual const char *name();
98  virtual void setName(const char *name);
100  virtual inline size_t dataSize() const
101  {
102  return _isigPt ? _isigPt->interface.data_size : 0;
103  }
104  virtual inline void setDataSize(size_t newSize)
105  {
106  if (_isigPt)
107  _isigPt->interface.data_size = newSize;
108  }
109 
110  virtual inline mcr_data_fnc init() const
111  {
112  return _isigPt ? _isigPt->interface.init : nullptr;
113  }
114  virtual inline void setInit(mcr_data_fnc val)
115  {
116  if (_isigPt)
117  _isigPt->interface.init = val;
118  }
119 
120  virtual inline mcr_data_fnc deinit() const
121  {
122  return _isigPt ? _isigPt->interface.deinit : nullptr;
123  }
124  virtual inline void setDeinit(mcr_data_fnc val)
125  {
126  if (_isigPt)
127  _isigPt->interface.deinit = val;
128  }
129 
130  virtual inline mcr_compare_fnc compare() const
131  {
132  return _isigPt ? _isigPt->interface.compare : nullptr;
133  }
134  virtual inline void setCompare(mcr_compare_fnc val)
135  {
136  if (_isigPt)
137  _isigPt->interface.compare = val;
138  }
139 
140  virtual inline mcr_copy_fnc copy() const
141  {
142  return _isigPt ? _isigPt->interface.copy : nullptr;
143  }
144  virtual inline void setCopy(mcr_copy_fnc val)
145  {
146  if (_isigPt)
147  _isigPt->interface.copy = val;
148  }
149 
150  /* ISignal */
151  virtual inline mcr_IDispatcher *dispatcher() const
152  {
153  return _isigPt ? _isigPt->dispatcher_pt : nullptr;
154  }
155  virtual inline void setDispatcher(mcr_IDispatcher *val)
156  {
157  if (_isigPt)
158  _isigPt->dispatcher_pt = val;
159  }
160 
161  virtual inline mcr_signal_fnc send() const
162  {
163  return _isigPt ? _isigPt->send : nullptr;
164  }
165  virtual inline void setSend(mcr_signal_fnc val)
166  {
167  if (_isigPt)
168  _isigPt->send = val;
169  }
170 
171  virtual mcr_IRegistry *registry();
172 private:
173  Libmacro *_context;
174  mcr_ISignal *_isigPt;
175 };
176 }
177 
178 #endif
virtual size_t dataSize() const
int(* mcr_compare_fnc)(const void *lhsPt, const void *rhsPt)
Definition: comparison.h:53
virtual mcr_ISignal * isignal() const
int(* mcr_data_fnc)(void *dataPt)
Definition: comparison.h:39
int(* mcr_signal_fnc)(struct mcr_Signal *signalPt)
Definition: isignal.h:39
int(* mcr_copy_fnc)(void *destinationPt, const void *sourcePt)
Definition: comparison.h:46
C++ wrappers and extensions of C types.
Libmacro, by Jonathan Pelletier, New Paradigm Software. Alpha version.
Definition: classes.h:31
virtual size_t id()
MCR_API size_t mcr_ISignal_id(const struct mcr_ISignal *isigPt)