Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 97 lines (76 sloc) 3.524 kB
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
1 /*
2e21618 @mhroth Update MessageSendController to use stl.
authored
2 * Copyright 2010,2011 Reality Jockey, Ltd.
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
3 * info@rjdj.me
4 * http://rjdj.me/
5 *
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.
17 *
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
23 #ifndef _MESSAGE_SEND_CONTROLLER_H_
24 #define _MESSAGE_SEND_CONTROLLER_H_
25
2e21618 @mhroth Update MessageSendController to use stl.
authored
26 #include <set>
27 #include <string>
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
28 #include "MessageObject.h"
2ded8bc @mhroth Add MessageNotein. This is the beginnings of support for Pd's midi fr…
authored
29 #include "RemoteMessageReceiver.h"
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
30
d94e9cd @mhroth Massive refactor to use concept of a global context. Unfortunately th…
authored
31 class PdContext;
32
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
33 /**
34 * Because of features such as external message injection and implicit message sending from message
35 * boxes, it must be possible to [send] a message to associated [receive]ers without explicitly
36 * requiring a [send] object to exist in the graph. The <code>MessageSendController</code> is
37 * intended as a central dispatcher for all sent messages, delivering a message to all associated
38 * [receive]ers without requiring the existance of a [send] object.
39 *
40 * It can deliver messages via the usual <code>receiveMessage()</code> function, where the inlet
41 * index identifies a receiver name. The index for a receiver name can be determined with
42 * <code>getNameIndex()</code>. This is useful for messages that must be scheduled in the global
43 * message queue and must then be dispatched via the <code>receiveMessage()</code> function.
44 *
45 * Alternatively, a message can be sent to receivers using <code>receiveMessage()</code> with
46 * name and message arguments (instead of inlet index and message). Messages sent using this
ea3871a @mhroth Add support for messages sent to receiver "pd".
authored
47 * alternative will be sent right away (avoiding the message queue).
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
48 */
49 class MessageSendController : public MessageObject {
50
51 public:
d94e9cd @mhroth Massive refactor to use concept of a global context. Unfortunately th…
authored
52 MessageSendController(PdContext *context);
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
53 ~MessageSendController();
54
7329847 @mhroth Add static factory method to all objects in order to create an object…
authored
55 static const char *getObjectLabel();
3f6a39c @Kyew Rewrote header functions as inline, add toString to all objects
Kyew authored
56 std::string toString();
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
57
58 /** Sends the message on to all receivers with the given name. */
d7dca0a @mhroth Fix the test for registering and unregistering external receivers.
authored
59 void receiveMessage(const char *name, PdMessage *message);
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
60
728349a @mhroth remove MessageObject::sendScheduledObject in favour of making Message…
authored
61 void sendMessage(int outletIndex, PdMessage *message);
0112a42 @mhroth Fix bug in SendMessageController system in which it did not properly …
authored
62
ee06c73 @mhroth Enable Java test for external receiver registration. Make the test work.
authored
63 /** Returns true if a receiver by that name is already registered. False otherwise. */
64 bool receiverExists(const char *receiverName);
65
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
66 /**
67 * Returns the index to which the given receiver name is referenced.
68 * Used with <code>receiveMessage(int, PdMessage *)</code>.
69 */
ee06c73 @mhroth Enable Java test for external receiver registration. Make the test work.
authored
70 int getNameIndex(const char *name);
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
71
2ded8bc @mhroth Add MessageNotein. This is the beginnings of support for Pd's midi fr…
authored
72 void addReceiver(RemoteMessageReceiver *receiver);
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
73
45bba91 @mhroth first commit of removeObject and associated functionality
authored
74 void removeReceiver(RemoteMessageReceiver *receiver);
75
34045e7 @mhroth Implement external receiver registration.
authored
76 void registerExternalReceiver(const char *receiverName);
77 void unregisterExternalReceiver(const char *receiverName);
78
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
79 private:
80
d94e9cd @mhroth Massive refactor to use concept of a global context. Unfortunately th…
authored
81 PdContext *context;
82
2e21618 @mhroth Update MessageSendController to use stl.
authored
83 vector<std::pair<string, set<RemoteMessageReceiver *> > > sendStack;
34045e7 @mhroth Implement external receiver registration.
authored
84
85 set<string> externalReceiverSet;
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
86 };
87
3f6a39c @Kyew Rewrote header functions as inline, add toString to all objects
Kyew authored
88 inline const char *MessageSendController::getObjectLabel() {
89 return "sendcontroller";
90 }
91
92 inline std::string MessageSendController::toString() {
93 return MessageSendController::getObjectLabel();
94 }
95
7035de5 @mhroth Introduce MessageSendController to manage all send/receive connection…
authored
96 #endif // _MESSAGE_SEND_CONTROLLER_H_
Something went wrong with that request. Please try again.