LMMS
Loading...
Searching...
No Matches
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#pragma once
39
40#include "base/source/fobject.h"
43
44namespace Steinberg {
45
47namespace Update { struct Table; }
49
50//------------------------------------------------------------------------
52//------------------------------------------------------------------------
54{
55public:
56//------------------------------------------------------------------------
58 virtual tresult PLUGIN_API cancelUpdates (FUnknown* object) = 0;
60 virtual tresult PLUGIN_API triggerDeferedUpdates (FUnknown* object = nullptr) = 0;
61 static const FUID iid;
62};
63
64DECLARE_CLASS_IID (IUpdateManager, 0x030B780C, 0xD6E6418D, 0x8CE00BC2, 0x09C834D4)
65
66//------------------------------------------------------------------------------
75//------------------------------------------------------------------------------
76class UpdateHandler : public FObject, public IUpdateHandler, public IUpdateManager
77{
78public:
79//------------------------------------------------------------------------------
82
86
87 // IUpdateHandler
89 tresult PLUGIN_API addDependent (FUnknown* object, IDependent* dependent) SMTG_OVERRIDE;
91 tresult PLUGIN_API removeDependent (FUnknown* object,
92 IDependent* dependent) SMTG_OVERRIDE;
97
98 // IUpdateManager
100 tresult PLUGIN_API cancelUpdates (FUnknown* object) SMTG_OVERRIDE;
102 tresult PLUGIN_API triggerDeferedUpdates (FUnknown* object = nullptr) SMTG_OVERRIDE;
103
105 // obsolete functions kept for compatibility
106 void checkUpdates (FObject* object = nullptr) { triggerDeferedUpdates (object->unknownCast ()); }
107 void flushUpdates (FObject* object) { cancelUpdates (object->unknownCast ()); }
108 void deferUpdate (FObject* object, int32 message)
109 {
110 deferUpdates (object->unknownCast (), message);
111 }
112 void signalChange (FObject* object, int32 message, bool suppressUpdateDone = false)
113 {
114 doTriggerUpdates (object->unknownCast (), message, suppressUpdateDone);
115 }
116#if DEVELOPMENT
117 bool checkDeferred (FUnknown* object);
118 bool hasDependencies (FUnknown* object);
119 void printForObject (FObject* object) const;
120#endif
122 size_t countDependencies (FUnknown* object = nullptr);
123
127//------------------------------------------------------------------------------
128private:
129 tresult doTriggerUpdates (FUnknown* object, int32 message, bool suppressUpdateDone);
130
134 static bool lockUpdates;
135};
136
137
138//------------------------------------------------------------------------
139} // namespace Steinberg
static void message(int level, const char *fmt,...)
Definition adplugdb.cpp:120
Definition flock.h:92
virtual void addDependent(IDependent *dep)
adds dependency to the object
Definition fobject.cpp:92
virtual void removeDependent(IDependent *dep)
removes dependency from the object
Definition fobject.cpp:99
FObject()
default constructor...
Definition fobject.h:85
virtual void deferUpdate(int32 msg=kChanged)
Similar to triggerUpdates, except only delivered in idle (usefull in collecting updates).
Definition fobject.cpp:115
Definition funknown.h:233
Definition funknown.h:361
Definition iupdatehandler.h:76
Definition iupdatehandler.h:41
Definition updatehandler.h:54
virtual tresult PLUGIN_API cancelUpdates(FUnknown *object)=0
virtual tresult PLUGIN_API triggerDeferedUpdates(FUnknown *object=nullptr)=0
static const FUID iid
Definition updatehandler.h:61
friend struct LockUpdateDependencies
Definition updatehandler.h:133
tresult PLUGIN_API addDependent(FUnknown *object, IDependent *dependent) SMTG_OVERRIDE
Definition updatehandler.cpp:210
UpdateHandler()
Definition updatehandler.cpp:193
Update::Table * table
Definition updatehandler.h:132
virtual void deferUpdate(int32 msg=kChanged)
Similar to triggerUpdates, except only delivered in idle (usefull in collecting updates).
Definition fobject.cpp:115
static bool lockUpdates
Definition updatehandler.h:134
size_t countDependencies(FUnknown *object=nullptr)
Definition updatehandler.cpp:622
tresult PLUGIN_API triggerUpdates(FUnknown *object, int32 message) SMTG_OVERRIDE
Definition updatehandler.cpp:450
tresult PLUGIN_API triggerDeferedUpdates(FUnknown *object=nullptr) SMTG_OVERRIDE
Definition updatehandler.cpp:496
tresult PLUGIN_API removeDependent(FUnknown *object, IDependent *dependent) SMTG_OVERRIDE
Definition updatehandler.cpp:248
tresult doTriggerUpdates(FUnknown *object, int32 message, bool suppressUpdateDone)
Definition updatehandler.cpp:364
Steinberg::Base::Thread::FLock lock
Definition updatehandler.h:131
tresult PLUGIN_API deferUpdates(FUnknown *object, int32 message) SMTG_OVERRIDE
Definition updatehandler.cpp:456
tresult PLUGIN_API cancelUpdates(FUnknown *object) SMTG_OVERRIDE
Definition updatehandler.cpp:600
#define OBJ_METHODS(className, baseClass)
Definition fobject.h:339
#define SINGLETON(ClassName)
Definition fobject.h:321
#define FUNKNOWN_METHODS2(InterfaceName1, InterfaceName2, BaseClass)
Definition fobject.h:458
#define SMTG_OVERRIDE
Definition fplatform.h:241
#define DECLARE_CLASS_IID(ClassName, l1, l2, l3, l4)
Definition funknown.h:74
void * object
Definition jmemsys.h:50
Definition updatehandler.cpp:61
Definition baseiids.cpp:43
int int32
Definition ftypes.h:50
int32 tresult
Definition ftypes.h:76
Definition updatehandler.cpp:155