Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
interrupt.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_SIGNALS_INTERRUPT_H_
24 #define MCR_EXTRAS_SIGNALS_INTERRUPT_H_
25 
27 #include "mcr/extras/macro.h"
28 
29 namespace mcr
30 {
31 class MCR_API IInterrupt
32 {
33 public:
35 
36  /* Interrupt Signal */
37  virtual int type() const = 0;
38  virtual void setType(int val) = 0;
39  virtual const char *target() const = 0;
40  virtual void setTarget(const char *val) = 0;
41  virtual IInterrupt *iinterrupt() const = 0;
42  virtual void setIInterrupt(IInterrupt *val) = 0;
43  /* Apply interrupt to target */
44  virtual void interrupt(const char *target, int type) = 0;
45 };
46 
48 class InterruptPrivate;
49 class MCR_API Interrupt : public ISignalMember, public IInterrupt
50 {
51  friend class InterruptPrivate;
52 public:
57  Interrupt(IInterrupt *iintercept = nullptr,
58  const char *target = "All",
59  int type = Macro::INTERRUPT_ALL);
60  Interrupt(const Interrupt &);
61  virtual ~Interrupt();
62  Interrupt &operator =(const Interrupt &);
63 
64  virtual int compare(const IDataMember &rhs) const override;
65  virtual void copy(const IDataMember *copytron) override;
66  virtual const char *name() const override
67  {
68  return "Interrupt";
69  }
70  virtual void send(mcr_Signal *signalPt) override;
71 
75  virtual int type() const override
76  {
77  return _type;
78  }
79  virtual void setType(int val) override
80  {
81  _type = val;
82  }
83 
87  virtual const char *target() const override;
88  virtual void setTarget(const char *val) override;
89 
90  virtual IInterrupt *iinterrupt() const override
91  {
92  return _iInterrupt;
93  }
94  virtual void setIInterrupt(IInterrupt *val) override
95  {
96  _iInterrupt = val;
97  }
98 
99  virtual void interrupt(const char *target, int type) override
100  {
101  if (_iInterrupt)
102  _iInterrupt->interrupt(target, type);
103  }
104 private:
105  IInterrupt *_iInterrupt;
106  int _type;
107  /* Not exportable */
108  InterruptPrivate *_private;
109 };
110 }
111 
112 #endif
ISignalData - Data type for signal instances C++.
#define MCR_DECL_INTERFACE(className)
Definition: defines.h:434
static IInterrupt * defaultInterrupt
Definition: interrupt.h:54
Libmacro, by Jonathan Pelletier, New Paradigm Software. Alpha version.
Definition: classes.h:31
virtual const char * name() const override
Definition: interrupt.h:66
virtual int type() const override
Definition: interrupt.h:75