-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCmd.cpp
87 lines (71 loc) · 1.22 KB
/
Cmd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Cmd.cpp
*
* Created on: 10.03.2014
* Author: niklausd
*/
#include "Cmd.h"
#include "CmdAdapter.h"
#include "CmdSequence.h"
Cmd::Cmd(CmdSequence* cmdSeq, long int timeMillis, const char* name)
: m_cmdSeq(cmdSeq)
, m_timeMillis(timeMillis)
, m_name(name)
, m_next(0)
{
if (0 != cmdSeq)
{
cmdSeq->attach(this);
}
}
Cmd::~Cmd()
{
if (0 != m_cmdSeq)
{
m_cmdSeq->detach(this);
}
}
void Cmd::setTime(long int millis)
{
m_timeMillis = millis;
}
long int Cmd::getTime()
{
return m_timeMillis;
}
Cmd* Cmd::next()
{
return m_next;
}
void Cmd::setNext(Cmd* next)
{
m_next = next;
}
const char* Cmd::getName()
{
return m_name;
}
CmdSequence* Cmd::cmdSequence()
{
return m_cmdSeq;
}
void Cmd::assign(CmdSequence* cmdSeq)
{
m_cmdSeq = cmdSeq;
if (0 != cmdSeq)
{
cmdSeq->attach(this);
}
}
//-----------------------------------------------------------------------------
CmdStop::CmdStop(CmdSequence* cmdSeq, long int timeMillis)
: Cmd(cmdSeq, timeMillis, "CmdStop")
{ }
void CmdStop::execute()
{
if ((0 != cmdSequence()) && (0 != cmdSequence()->adapter()))
{
cmdSequence()->adapter()->stopAction();
}
}
//-----------------------------------------------------------------------------