nongnu.org/gsequencer


gsequencer 7.0.5
Advanced Gtk+ Sequencer
updatehandler.h
Go to the documentation of this file.
1//------------------------------------------------------------------------
2// Project : SDK Base
3// Version : 1.0
4//
5// Category : Helpers
6// Filename : base/source/updatehandler.h
7// Created by : Steinberg, 2008
8// Description :
9//
10//-----------------------------------------------------------------------------
11// LICENSE
12// (c) 2021, Steinberg Media Technologies GmbH, All Rights Reserved
13//-----------------------------------------------------------------------------
14// Redistribution and use in source and binary forms, with or without modification,
15// are permitted provided that the following conditions are met:
16//
17// * Redistributions of source code must retain the above copyright notice,
18// this list of conditions and the following disclaimer.
19// * Redistributions in binary form must reproduce the above copyright notice,
20// this list of conditions and the following disclaimer in the documentation
21// and/or other materials provided with the distribution.
22// * Neither the name of the Steinberg Media Technologies nor the names of its
23// contributors may be used to endorse or promote products derived from this
24// software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
34// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
35// OF THE POSSIBILITY OF SUCH DAMAGE.
36//-----------------------------------------------------------------------------
37
38/* GSequencer - Advanced GTK Sequencer
39 * Copyright (C) 2005-2021 Joël Krähemann
40 *
41 * This file is part of GSequencer.
42 *
43 * GSequencer is free software: you can redistribute it and/or modify
44 * it under the terms of the GNU General Public License as published by
45 * the Free Software Foundation, either version 3 of the License, or
46 * (at your option) any later version.
47 *
48 * GSequencer is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>.
55 */
56
57#pragma once
58
59#include "base/source/fobject.h"
60#include "base/thread/include/flock.h"
61#include "pluginterfaces/base/iupdatehandler.h"
62
63namespace Steinberg {
64
66namespace Update { struct Table; }
68
69//------------------------------------------------------------------------
71//------------------------------------------------------------------------
72class IUpdateManager : public FUnknown
73{
74public:
75//------------------------------------------------------------------------
77 virtual tresult PLUGIN_API cancelUpdates (FUnknown* object) = 0;
79 virtual tresult PLUGIN_API triggerDeferedUpdates (FUnknown* object = nullptr) = 0;
80 static const FUID iid;
81};
82
83DECLARE_CLASS_IID (IUpdateManager, 0x030B780C, 0xD6E6418D, 0x8CE00BC2, 0x09C834D4)
84
85//------------------------------------------------------------------------------
94//------------------------------------------------------------------------------
95class UpdateHandler : public FObject, public IUpdateHandler, public IUpdateManager
96{
97public:
98//------------------------------------------------------------------------------
101
102 using FObject::addDependent;
103 using FObject::removeDependent;
104 using FObject::deferUpdate;
105
106 // IUpdateHandler
108 tresult PLUGIN_API addDependent (FUnknown* object, IDependent* dependent) SMTG_OVERRIDE;
110 tresult PLUGIN_API removeDependent (FUnknown* object,
111 IDependent* dependent) SMTG_OVERRIDE;
113 tresult PLUGIN_API triggerUpdates (FUnknown* object, int32 message) SMTG_OVERRIDE;
115 tresult PLUGIN_API deferUpdates (FUnknown* object, int32 message) SMTG_OVERRIDE;
116
117 // IUpdateManager
119 tresult PLUGIN_API cancelUpdates (FUnknown* object) SMTG_OVERRIDE;
121 tresult PLUGIN_API triggerDeferedUpdates (FUnknown* object = nullptr) SMTG_OVERRIDE;
122
124 // obsolete functions kept for compatibility
125 void checkUpdates (FObject* object = nullptr) { triggerDeferedUpdates (object->unknownCast ()); }
126 void flushUpdates (FObject* object) { cancelUpdates (object->unknownCast ()); }
127 void deferUpdate (FObject* object, int32 message)
128 {
129 deferUpdates (object->unknownCast (), message);
130 }
131 void signalChange (FObject* object, int32 message, bool suppressUpdateDone = false)
132 {
133 doTriggerUpdates (object->unknownCast (), message, suppressUpdateDone);
134 }
135#if DEVELOPMENT
136 bool checkDeferred (FUnknown* object);
137 bool hasDependencies (FUnknown* object);
138 void printForObject (FObject* object) const;
139#endif
141 size_t countDependencies (FUnknown* object = nullptr);
142
143 OBJ_METHODS (UpdateHandler, FObject)
144 FUNKNOWN_METHODS2 (IUpdateHandler, IUpdateManager, FObject)
145 SINGLETON (UpdateHandler)
146//------------------------------------------------------------------------------
147private:
148 tresult doTriggerUpdates (FUnknown* object, int32 message, bool suppressUpdateDone);
149
150 Steinberg::Base::Thread::FLock lock;
151 Update::Table* table = nullptr;
152 friend struct LockUpdateDependencies;
153 static bool lockUpdates;
154};
155
156
157//------------------------------------------------------------------------
158} // namespace Steinberg
struct AgsVstFObject FObject
Definition ags_vst_fobject.h:29
Definition updatehandler.h:73
virtual tresult PLUGIN_API cancelUpdates(FUnknown *object)=0
virtual tresult PLUGIN_API triggerDeferedUpdates(FUnknown *object=nullptr)=0
static const FUID iid
Definition updatehandler.h:80
Definition updatehandler.h:96
Definition hostcontext.cpp:61
Definition updatehandler.cpp:173