Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (68 sloc) 2.216 kB
4b71bbe @mhroth Add LGPL license to remaining files.
authored
1 /*
29f83db Towards an a stack-based messaging system. First commit.
Martin Roth authored
2 * Copyright 2009,2010,2011 Reality Jockey, Ltd.
4b71bbe @mhroth Add LGPL license to remaining files.
authored
3 * info@rjdj.me
4 * http://rjdj.me/
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
5 *
4b71bbe @mhroth Add LGPL license to remaining files.
authored
6 * This file is part of ZenGarden.
7 *
8 * ZenGarden is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ZenGarden is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
17 *
4b71bbe @mhroth Add LGPL license to remaining files.
authored
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with ZenGarden. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
abb33ec First commit of current source.
Martin Roth authored
23 #include "MessageGreaterThan.h"
24
7329847 @mhroth Add static factory method to all objects in order to create an object…
authored
25 MessageObject *MessageGreaterThan::newObject(PdMessage *initMessage, PdGraph *graph) {
26 return new MessageGreaterThan(initMessage, graph);
27 }
28
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
29 MessageGreaterThan::MessageGreaterThan(PdMessage *initMessage, PdGraph *graph) : MessageObject(2, 1, graph) {
8ce3e14 added test for MessageGreaterThan and updated object to conform to test
Yoonchang Han authored
30 constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
31 lastOutput = 0.0f;
abb33ec First commit of current source.
Martin Roth authored
32 }
33
34 MessageGreaterThan::~MessageGreaterThan() {
35 // nothing to do
36 }
37
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
38 void MessageGreaterThan::processMessage(int inletIndex, PdMessage *message) {
39 switch (inletIndex) {
40 case 0: {
8ce3e14 added test for MessageGreaterThan and updated object to conform to test
Yoonchang Han authored
41 switch (message->getType(0)) {
42 case FLOAT: {
43 lastOutput = (message->getFloat(0) > constant) ? 1.0f : 0.0f;
44 // allow fallthrough
45 }
46 case BANG: {
29f83db Towards an a stack-based messaging system. First commit.
Martin Roth authored
47 PdMessage *outgoingMessage = PD_MESSAGE_ON_STACK(1);
48 outgoingMessage->initWithTimestampAndFloat(message->getTimestamp(), lastOutput);
8ce3e14 added test for MessageGreaterThan and updated object to conform to test
Yoonchang Han authored
49 sendMessage(0, outgoingMessage);
50 break;
51 }
52 default: {
53 break;
54 }
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
55 }
56 break;
57 }
58 case 1: {
8ce3e14 added test for MessageGreaterThan and updated object to conform to test
Yoonchang Han authored
59 if (message->isFloat(0)) {
60 constant = message->getFloat(0);
82d00a8 Added MessageEqualsEquals, MessageNotEquals, MessageLessThan, Message…
Yoonchang Han authored
61 }
62 break;
63 }
64 default: {
65 break;
66 }
67 }
68 }
3f6a39c @Kyew Rewrote header functions as inline, add toString to all objects
Kyew authored
69
70 std::string MessageGreaterThan::toString() {
71 char str[snprintf(NULL, 0, "> %g", constant)+1];
72 snprintf(str, sizeof(str), "> %g", constant);
73 return string(str);
74 }
Something went wrong with that request. Please try again.