MythTV master
Link.h
Go to the documentation of this file.
1/* Link.h
2
3 Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19
20*/
21
22#if !defined(LINK_H)
23#define LINK_H
24
25#include "Ingredients.h"
26#include "Root.h"
27#include "BaseClasses.h"
28#include "Actions.h"
29#include "BaseActions.h"
30
31#include <QString>
32
33class MHParseNode;
34
35// Link - basically a guarded command.
36class MHLink : public MHIngredient
37{
38 public:
39 MHLink();
40 const char *ClassName() override // MHRoot
41 { return "Link"; }
42 // Set this up from the parse tree.
43 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
44 void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
45 // Look up the event type. Returns zero if it doesn't match.
46 static int GetEventType(const QString& str);
47 // Print an event type.
48 static QString EventTypeToString(enum EventType ev);
49
50 // Internal behaviours.
51 void Activation(MHEngine *engine) override; // MHRoot
52 void Deactivation(MHEngine *engine) override; // MHRoot
53
54 // Handle activation and deactivation
55 void Activate(bool f, MHEngine *engine) override; // MHRoot
56 // Called when an event has been triggered and fires this link if it matches.
57 virtual void MatchEvent(const MHObjectRef &sourceRef, enum EventType ev, const MHUnion &evData, MHEngine *engine);
58
59 protected:
61 enum EventType m_nEventType {EventIsAvailable};
64};
65
66// Actions.
67// Activate and deactivate actions.
69{
70 public:
71 MHActivate(const char *name, bool fActivate): MHElemAction(name), m_fActivate(fActivate) {}
72 void Perform(MHEngine *engine) override // MHElemAction
73 { Target(engine)->Activate(m_fActivate, engine); }
74 protected:
76};
77
78#endif
EventType
Definition: Root.h:34
@ EventIsAvailable
Definition: Root.h:34
bool m_fActivate
Definition: Link.h:75
MHActivate(const char *name, bool fActivate)
Definition: Link.h:71
void Perform(MHEngine *engine) override
Definition: Link.h:72
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
virtual void Activate(bool, MHEngine *)
Definition: Root.h:123
int FILE
Definition: mythburn.py:138