Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
FObjectCx.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#pragma once
20
21#include <base/source/fobject.h>
22#include <pluginterfaces/vst/vsttypes.h>
24
25namespace pongasoft {
26namespace VST {
27
28using namespace Steinberg::Vst;
29using namespace Steinberg;
30
36class FObjectCx : protected FObject
37{
38public:
39 // Constructor
40 explicit FObjectCx(FObject *iTarget);
41
45 virtual void close();
46
50 virtual void onTargetChange() {};
51
54 inline ~FObjectCx() override { close(); }
55
56 // disabling copy
57 FObjectCx(FObjectCx const &) = delete;
58 FObjectCx& operator=(FObjectCx const &) = delete;
59
60protected:
64 void PLUGIN_API update(FUnknown *iChangedUnknown, Steinberg::int32 iMessage) SMTG_OVERRIDE;
65
66protected:
67 FObject *fTarget;
69};
70
75{
76public:
77 using ChangeCallback = std::function<void()>;
78
79 // Constructor
80 FObjectCxCallback(FObject *iTarget, ChangeCallback iChangeCallback);
81
82 // close
83 void close() override;
84
85 // onTargetChange
86 void onTargetChange() override;
87
88 // disabling copy
91
92protected:
94};
95
96}
97}
std::function< void()> ChangeCallback
Definition FObjectCx.h:77
FObjectCxCallback(FObjectCxCallback const &)=delete
void close() override
Call to stop listening for changes.
Definition FObjectCx.cpp:74
FObjectCxCallback & operator=(FObjectCxCallback const &)=delete
FObjectCxCallback(FObject *iTarget, ChangeCallback iChangeCallback)
Definition FObjectCx.cpp:66
ChangeCallback fChangeCallback
Definition FObjectCx.h:93
void onTargetChange() override
Called when the target changes (by default does nothing).
Definition FObjectCx.cpp:85
FObjectCx & operator=(FObjectCx const &)=delete
void PLUGIN_API update(FUnknown *iChangedUnknown, Steinberg::int32 iMessage) SMTG_OVERRIDE
This is being called when fTarget sends a message to this object.
Definition FObjectCx.cpp:55
bool fIsConnected
Definition FObjectCx.h:68
FObjectCx(FObjectCx const &)=delete
virtual void close()
Call to stop listening for changes.
Definition FObjectCx.cpp:42
~FObjectCx() override
Automatically closes the connection and stops listening.
Definition FObjectCx.h:54
FObjectCx(FObject *iTarget)
Definition FObjectCx.cpp:30
FObject * fTarget
Definition FObjectCx.h:67
virtual void onTargetChange()
Called when the target changes (by default does nothing).
Definition FObjectCx.h:50
Definition Clock.h:24
Definition Clock.h:23