Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
MessageHandler.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#pragma once
21
22#include "Messaging.h"
23
24#include <map>
25
26namespace pongasoft {
27namespace VST {
28
32{
33public:
34 virtual ~IMessageHandler() = default;
35 virtual tresult handleMessage(Message const &iMessage) = 0;
36};
37
41{
42public:
43 // handleMessage
44 tresult handleMessage(Message const &iMessage) override;
45
46 // registerHandler
47 void registerHandler(MessageID iMessageID, IMessageHandler *iMessageHandler);
48
49private:
50 // map of messageID to a handler
51 std::map<MessageID, IMessageHandler *> fHandlers{};
52};
53
54}
55}
56
Interface defining a message handler.
Definition MessageHandler.h:32
virtual tresult handleMessage(Message const &iMessage)=0
virtual ~IMessageHandler()=default
Simple implementation of IMessageHandler which will delegate the message handling based on MessageID.
Definition MessageHandler.h:41
tresult handleMessage(Message const &iMessage) override
Definition MessageHandler.cpp:30
void registerHandler(MessageID iMessageID, IMessageHandler *iMessageHandler)
Definition MessageHandler.cpp:43
std::map< MessageID, IMessageHandler * > fHandlers
Definition MessageHandler.h:51
Simple wrapper class with better api.
Definition Messaging.h:46
Definition Clock.h:24
int MessageID
Definition Messaging.h:40
Definition Clock.h:23