mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Dragged the singleton macros into the 21st century.. Cleaned up their implementation and gave them new upper-case names to match juce official style. The old names are still defined to avoid breaking old code, but please update before they get deprecated!
This commit is contained in:
parent
c6ed2626e1
commit
58a99ff139
30 changed files with 211 additions and 214 deletions
|
|
@ -52,7 +52,7 @@
|
|||
#include "../LiveBuildEngine/UI/jucer_ComponentListComponent.h"
|
||||
#include "../LiveBuildEngine/jucer_CompileEngineServer.h"
|
||||
|
||||
juce_ImplementSingleton (CompileEngineDLL);
|
||||
JUCE_IMPLEMENT_SINGLETON (CompileEngineDLL)
|
||||
|
||||
struct ProjucerAppClasses
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "jucer_LiveCodeBuilderDLL.h"
|
||||
|
||||
//==============================================================================
|
||||
struct CompileEngineDLL : DeletedAtShutdown
|
||||
struct CompileEngineDLL : private DeletedAtShutdown
|
||||
{
|
||||
CompileEngineDLL()
|
||||
{
|
||||
|
|
@ -39,6 +39,7 @@ struct CompileEngineDLL : DeletedAtShutdown
|
|||
~CompileEngineDLL()
|
||||
{
|
||||
shutdown();
|
||||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
bool tryLoadDll()
|
||||
|
|
@ -117,7 +118,7 @@ struct CompileEngineDLL : DeletedAtShutdown
|
|||
return userAppData.getChildFile ("Projucer").getChildFile (String ("CompileEngine-") + ProjectInfo::versionString);
|
||||
}
|
||||
|
||||
juce_DeclareSingleton (CompileEngineDLL, false)
|
||||
JUCE_DECLARE_SINGLETON (CompileEngineDLL, false)
|
||||
|
||||
private:
|
||||
DynamicLibrary dll;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ void Analytics::setSuspended (bool shouldBeSuspended)
|
|||
isSuspended = shouldBeSuspended;
|
||||
}
|
||||
|
||||
juce_ImplementSingleton (Analytics)
|
||||
JUCE_IMPLEMENT_SINGLETON (Analytics)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public:
|
|||
void setSuspended (bool shouldBeSuspended);
|
||||
|
||||
#ifndef DOXYGEN
|
||||
juce_DeclareSingleton (Analytics, false)
|
||||
JUCE_DECLARE_SINGLETON (Analytics, false)
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1107,7 +1107,7 @@ public:
|
|||
|
||||
MidiServiceType* getService();
|
||||
|
||||
juce_DeclareSingleton (MidiService, false)
|
||||
JUCE_DECLARE_SINGLETON (MidiService, false)
|
||||
|
||||
private:
|
||||
MidiService();
|
||||
|
|
@ -1115,7 +1115,7 @@ private:
|
|||
ScopedPointer<MidiServiceType> internal;
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (MidiService)
|
||||
JUCE_IMPLEMENT_SINGLETON (MidiService)
|
||||
|
||||
MidiService::~MidiService()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -189,12 +189,12 @@ struct SharedMessageThread : public Thread
|
|||
{}
|
||||
}
|
||||
|
||||
juce_DeclareSingleton (SharedMessageThread, false)
|
||||
JUCE_DECLARE_SINGLETON (SharedMessageThread, false)
|
||||
|
||||
bool initialised = false;
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (SharedMessageThread)
|
||||
JUCE_IMPLEMENT_SINGLETON (SharedMessageThread)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,115 @@ namespace juce
|
|||
|
||||
//==============================================================================
|
||||
/**
|
||||
Macro to declare member variables and methods for a singleton class.
|
||||
Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer
|
||||
to a singleton instance.
|
||||
|
||||
To use this, add the line juce_DeclareSingleton (MyClass, doNotRecreateAfterDeletion)
|
||||
You generally won't use this directly, but see the macros JUCE_DECLARE_SINGLETON,
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL,
|
||||
and JUCE_IMPLEMENT_SINGLETON for how it is intended to be used.
|
||||
*/
|
||||
template <typename Type, typename MutexType, bool onlyCreateOncePerRun>
|
||||
struct SingletonHolder : private MutexType // (inherited so we can use the empty-base-class optimisation)
|
||||
{
|
||||
SingletonHolder() noexcept {}
|
||||
|
||||
~SingletonHolder()
|
||||
{
|
||||
/* The static singleton holder is being deleted before the object that it holds
|
||||
has been deleted. This could mean that you've forgotten to call clearSingletonInstance()
|
||||
in the class's destructor, or have failed to delete it before your app shuts down.
|
||||
If you're having trouble cleaning up your singletons, perhaps consider using the
|
||||
SharedResourcePointer class instead.
|
||||
*/
|
||||
jassert (instance == nullptr);
|
||||
}
|
||||
|
||||
/** Returns the current instance, or creates a new instance if there isn't one. */
|
||||
Type* get()
|
||||
{
|
||||
if (instance == nullptr)
|
||||
{
|
||||
typename MutexType::ScopedLockType sl (*this);
|
||||
|
||||
if (instance == nullptr)
|
||||
{
|
||||
if (onlyCreateOncePerRun)
|
||||
{
|
||||
static bool createdOnceAlready = false;
|
||||
|
||||
if (createdOnceAlready)
|
||||
{
|
||||
// This means that the doNotRecreateAfterDeletion flag was set
|
||||
// and you tried to create the singleton more than once.
|
||||
jassertfalse;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
createdOnceAlready = true;
|
||||
}
|
||||
|
||||
static bool alreadyInside = false;
|
||||
|
||||
if (alreadyInside)
|
||||
{
|
||||
// This means that your object's constructor has done something which has
|
||||
// ended up causing a recursive loop of singleton creation..
|
||||
jassertfalse;
|
||||
}
|
||||
else
|
||||
{
|
||||
alreadyInside = true;
|
||||
getWithoutChecking();
|
||||
alreadyInside = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** Returns the current instance, or creates a new instance if there isn't one, but doesn't do
|
||||
any locking, or checking for recursion or error conditions.
|
||||
*/
|
||||
Type* getWithoutChecking()
|
||||
{
|
||||
if (instance == nullptr)
|
||||
{
|
||||
auto newObject = new Type(); // (create into a local so that instance is still null during construction)
|
||||
instance = newObject;
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** Deletes and resets the current instance, if there is one. */
|
||||
void deleteInstance()
|
||||
{
|
||||
typename MutexType::ScopedLockType sl (*this);
|
||||
auto old = instance;
|
||||
instance = nullptr;
|
||||
delete old;
|
||||
}
|
||||
|
||||
/** Called by the class's destructor to clear the pointer if it is currently set to the given object. */
|
||||
void clear (Type* expectedObject) noexcept
|
||||
{
|
||||
if (instance == expectedObject)
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
Type* instance = nullptr;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Macro to generate the appropriate methods and boilerplate for a singleton class.
|
||||
|
||||
To use this, add the line JUCE_DECLARE_SINGLETON(MyClass, doNotRecreateAfterDeletion)
|
||||
to the class's definition.
|
||||
|
||||
Then put a macro juce_ImplementSingleton (MyClass) along with the class's
|
||||
Then put a macro JUCE_IMPLEMENT_SINGLETON(MyClass) along with the class's
|
||||
implementation code.
|
||||
|
||||
It's also a very good idea to also add the call clearSingletonInstance() in your class's
|
||||
|
|
@ -42,12 +145,9 @@ namespace juce
|
|||
|
||||
e.g. @code
|
||||
|
||||
class MySingleton
|
||||
struct MySingleton
|
||||
{
|
||||
public:
|
||||
MySingleton()
|
||||
{
|
||||
}
|
||||
MySingleton() {}
|
||||
|
||||
~MySingleton()
|
||||
{
|
||||
|
|
@ -56,14 +156,15 @@ namespace juce
|
|||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
juce_DeclareSingleton (MySingleton, false)
|
||||
JUCE_DECLARE_SINGLETON (MySingleton, false)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (MySingleton)
|
||||
// ..and this goes in a suitable .cpp file:
|
||||
JUCE_IMPLEMENT_SINGLETON (MySingleton)
|
||||
|
||||
|
||||
// example of usage:
|
||||
MySingleton* m = MySingleton::getInstance(); // creates the singleton if there isn't already one.
|
||||
auto* m = MySingleton::getInstance(); // creates the singleton if there isn't already one.
|
||||
|
||||
...
|
||||
|
||||
|
|
@ -77,84 +178,38 @@ namespace juce
|
|||
objects being accidentally re-created during your app's shutdown code.
|
||||
|
||||
If you know that your object will only be created and deleted by a single thread, you
|
||||
can use the slightly more efficient juce_DeclareSingleton_SingleThreaded() macro instead
|
||||
can use the slightly more efficient JUCE_DECLARE_SINGLETON_SINGLETHREADED macro instead
|
||||
of this one.
|
||||
|
||||
@see juce_ImplementSingleton, juce_DeclareSingleton_SingleThreaded
|
||||
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED
|
||||
*/
|
||||
#define juce_DeclareSingleton(classname, doNotRecreateAfterDeletion) \
|
||||
#define JUCE_DECLARE_SINGLETON(Classname, doNotRecreateAfterDeletion) \
|
||||
\
|
||||
static classname* _singletonInstance; \
|
||||
static juce::CriticalSection _singletonLock; \
|
||||
static juce::SingletonHolder<Classname, juce::CriticalSection, doNotRecreateAfterDeletion> singletonHolder; \
|
||||
friend decltype (singletonHolder); \
|
||||
\
|
||||
static classname* JUCE_CALLTYPE getInstance() \
|
||||
{ \
|
||||
if (_singletonInstance == nullptr) \
|
||||
{\
|
||||
const juce::ScopedLock sl (_singletonLock); \
|
||||
\
|
||||
if (_singletonInstance == nullptr) \
|
||||
{ \
|
||||
static bool alreadyInside = false; \
|
||||
static bool createdOnceAlready = false; \
|
||||
\
|
||||
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \
|
||||
jassert (! problem); \
|
||||
if (! problem) \
|
||||
{ \
|
||||
createdOnceAlready = true; \
|
||||
alreadyInside = true; \
|
||||
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \
|
||||
alreadyInside = false; \
|
||||
\
|
||||
_singletonInstance = newObject; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static inline classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept\
|
||||
{ \
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static void JUCE_CALLTYPE deleteInstance() \
|
||||
{ \
|
||||
const juce::ScopedLock sl (_singletonLock); \
|
||||
if (_singletonInstance != nullptr) \
|
||||
{ \
|
||||
classname* const old = _singletonInstance; \
|
||||
_singletonInstance = nullptr; \
|
||||
delete old; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void clearSingletonInstance() noexcept\
|
||||
{ \
|
||||
if (_singletonInstance == this) \
|
||||
_singletonInstance = nullptr; \
|
||||
}
|
||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \
|
||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
|
||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
|
||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** This is a counterpart to the juce_DeclareSingleton macro.
|
||||
/** This is a counterpart to the JUCE_DECLARE_SINGLETON macros.
|
||||
|
||||
After adding the juce_DeclareSingleton to the class definition, this macro has
|
||||
After adding the JUCE_DECLARE_SINGLETON to the class definition, this macro has
|
||||
to be used in the cpp file.
|
||||
*/
|
||||
#define juce_ImplementSingleton(classname) \
|
||||
#define JUCE_IMPLEMENT_SINGLETON(Classname) \
|
||||
\
|
||||
classname* classname::_singletonInstance = nullptr; \
|
||||
juce::CriticalSection classname::_singletonLock;
|
||||
decltype (Classname::singletonHolder) Classname::singletonHolder;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Macro to declare member variables and methods for a singleton class.
|
||||
|
||||
This is exactly the same as juce_DeclareSingleton, but doesn't use a critical
|
||||
This is exactly the same as JUCE_DECLARE_SINGLETON, but doesn't use a critical
|
||||
section to make access to it thread-safe. If you know that your object will
|
||||
only ever be created or deleted by a single thread, then this is a
|
||||
more efficient version to use.
|
||||
|
|
@ -164,120 +219,61 @@ namespace juce
|
|||
object, getInstance() will refuse to create another one. This can be useful to stop
|
||||
objects being accidentally re-created during your app's shutdown code.
|
||||
|
||||
See the documentation for juce_DeclareSingleton for more information about
|
||||
how to use it, the only difference being that you have to use
|
||||
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton.
|
||||
See the documentation for JUCE_DECLARE_SINGLETON for more information about
|
||||
how to use it. Just like JUCE_DECLARE_SINGLETON you need to also have a
|
||||
corresponding JUCE_IMPLEMENT_SINGLETON statement somewhere in your code.
|
||||
|
||||
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton, juce_DeclareSingleton_SingleThreaded_Minimal
|
||||
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL
|
||||
*/
|
||||
#define juce_DeclareSingleton_SingleThreaded(classname, doNotRecreateAfterDeletion) \
|
||||
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreateAfterDeletion) \
|
||||
\
|
||||
static classname* _singletonInstance; \
|
||||
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, doNotRecreateAfterDeletion> singletonHolder; \
|
||||
friend decltype (singletonHolder); \
|
||||
\
|
||||
static classname* getInstance() \
|
||||
{ \
|
||||
if (_singletonInstance == nullptr) \
|
||||
{ \
|
||||
static bool alreadyInside = false; \
|
||||
static bool createdOnceAlready = false; \
|
||||
\
|
||||
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \
|
||||
jassert (! problem); \
|
||||
if (! problem) \
|
||||
{ \
|
||||
createdOnceAlready = true; \
|
||||
alreadyInside = true; \
|
||||
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \
|
||||
alreadyInside = false; \
|
||||
\
|
||||
_singletonInstance = newObject; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static inline classname* getInstanceWithoutCreating() noexcept\
|
||||
{ \
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static void deleteInstance() \
|
||||
{ \
|
||||
if (_singletonInstance != nullptr) \
|
||||
{ \
|
||||
classname* const old = _singletonInstance; \
|
||||
_singletonInstance = nullptr; \
|
||||
delete old; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void clearSingletonInstance() noexcept\
|
||||
{ \
|
||||
if (_singletonInstance == this) \
|
||||
_singletonInstance = nullptr; \
|
||||
}
|
||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \
|
||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
|
||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
|
||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Macro to declare member variables and methods for a singleton class.
|
||||
|
||||
This is like juce_DeclareSingleton_SingleThreaded, but doesn't do any checking
|
||||
This is like JUCE_DECLARE_SINGLETON_SINGLETHREADED, but doesn't do any checking
|
||||
for recursion or repeated instantiation. It's intended for use as a lightweight
|
||||
version of a singleton, where you're using it in very straightforward
|
||||
circumstances and don't need the extra checking.
|
||||
|
||||
Just use the normal juce_ImplementSingleton_SingleThreaded as the counterpart
|
||||
to this declaration, as you would with juce_DeclareSingleton_SingleThreaded.
|
||||
Just use the normal JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED as the counterpart
|
||||
to this declaration, as you would with JUCE_DECLARE_SINGLETON_SINGLETHREADED.
|
||||
|
||||
See the documentation for juce_DeclareSingleton for more information about
|
||||
See the documentation for JUCE_DECLARE_SINGLETON for more information about
|
||||
how to use it, the only difference being that you have to use
|
||||
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton.
|
||||
JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED instead of JUCE_IMPLEMENT_SINGLETON.
|
||||
|
||||
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton
|
||||
@see JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON
|
||||
*/
|
||||
#define juce_DeclareSingleton_SingleThreaded_Minimal(classname) \
|
||||
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname) \
|
||||
\
|
||||
static classname* _singletonInstance; \
|
||||
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, false> singletonHolder; \
|
||||
friend decltype (singletonHolder); \
|
||||
\
|
||||
static classname* getInstance() \
|
||||
{ \
|
||||
if (_singletonInstance == nullptr) \
|
||||
_singletonInstance = new classname(); \
|
||||
\
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static inline classname* getInstanceWithoutCreating() noexcept\
|
||||
{ \
|
||||
return _singletonInstance; \
|
||||
} \
|
||||
\
|
||||
static void deleteInstance() \
|
||||
{ \
|
||||
if (_singletonInstance != nullptr) \
|
||||
{ \
|
||||
classname* const old = _singletonInstance; \
|
||||
_singletonInstance = nullptr; \
|
||||
delete old; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void clearSingletonInstance() noexcept\
|
||||
{ \
|
||||
if (_singletonInstance == this) \
|
||||
_singletonInstance = nullptr; \
|
||||
}
|
||||
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.getWithoutChecking(); } \
|
||||
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
|
||||
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
|
||||
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** This is a counterpart to the juce_DeclareSingleton_SingleThreaded macro.
|
||||
|
||||
After adding juce_DeclareSingleton_SingleThreaded or juce_DeclareSingleton_SingleThreaded_Minimal
|
||||
to the class definition, this macro has to be used somewhere in the cpp file.
|
||||
*/
|
||||
#define juce_ImplementSingleton_SingleThreaded(classname) \
|
||||
\
|
||||
classname* classname::_singletonInstance = nullptr;
|
||||
#ifndef DOXYGEN
|
||||
// These are ancient macros, and have now been updated with new names to match the JUCE style guide,
|
||||
// so please update your code to use the newer versions!
|
||||
#define juce_DeclareSingleton(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON(Classname, doNotRecreate)
|
||||
#define juce_DeclareSingleton_SingleThreaded(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreate)
|
||||
#define juce_DeclareSingleton_SingleThreaded_Minimal(Classname) JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname)
|
||||
#define juce_ImplementSingleton(Classname) JUCE_IMPLEMENT_SINGLETON(Classname)
|
||||
#define juce_ImplementSingleton_SingleThreaded(Classname) JUCE_IMPLEMENT_SINGLETON(Classname)
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ DECLARE_JNI_CLASS (JNIHandler, "android/os/Handler");
|
|||
//==============================================================================
|
||||
namespace Android
|
||||
{
|
||||
class Runnable : public juce::AndroidInterfaceImplementer
|
||||
class Runnable : public juce::AndroidInterfaceImplementer
|
||||
{
|
||||
public:
|
||||
virtual void run() = 0;
|
||||
|
|
@ -58,7 +58,7 @@ namespace Android
|
|||
|
||||
struct Handler
|
||||
{
|
||||
juce_DeclareSingleton (Handler, false)
|
||||
JUCE_DECLARE_SINGLETON (Handler, false)
|
||||
|
||||
Handler() : nativeHandler (getEnv()->NewObject (JNIHandler, JNIHandler.constructor)) {}
|
||||
|
||||
|
|
@ -70,13 +70,13 @@ namespace Android
|
|||
GlobalRef nativeHandler;
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (Handler);
|
||||
JUCE_IMPLEMENT_SINGLETON (Handler)
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct AndroidMessageQueue : private Android::Runnable
|
||||
{
|
||||
juce_DeclareSingleton_SingleThreaded (AndroidMessageQueue, true)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (AndroidMessageQueue, true)
|
||||
|
||||
AndroidMessageQueue()
|
||||
: self (CreateJavaInterface (this, "java/lang/Runnable").get())
|
||||
|
|
@ -118,7 +118,7 @@ private:
|
|||
Android::Handler handler;
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (AndroidMessageQueue);
|
||||
JUCE_IMPLEMENT_SINGLETON (AndroidMessageQueue)
|
||||
|
||||
//==============================================================================
|
||||
void MessageManager::doPlatformSpecificInitialisation() { AndroidMessageQueue::getInstance(); }
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (InternalMessageQueue)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (InternalMessageQueue)
|
||||
|
||||
private:
|
||||
CriticalSection lock;
|
||||
|
|
@ -165,7 +165,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (InternalMessageQueue)
|
||||
JUCE_IMPLEMENT_SINGLETON (InternalMessageQueue)
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@
|
|||
|
||||
namespace juce
|
||||
{
|
||||
juce_ImplementSingleton (WinRTWrapper)
|
||||
JUCE_IMPLEMENT_SINGLETON (WinRTWrapper)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace juce
|
|||
class WinRTWrapper : public DeletedAtShutdown
|
||||
{
|
||||
public:
|
||||
juce_DeclareSingleton (WinRTWrapper, true)
|
||||
JUCE_DECLARE_SINGLETON (WinRTWrapper, true)
|
||||
|
||||
class ScopedHString
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public:
|
|||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
juce_DeclareSingleton (TypefaceCache, false)
|
||||
JUCE_DECLARE_SINGLETON (TypefaceCache, false)
|
||||
|
||||
void setSize (const int numToCache)
|
||||
{
|
||||
|
|
@ -157,7 +157,7 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (TypefaceCache)
|
||||
JUCE_IMPLEMENT_SINGLETON (TypefaceCache)
|
||||
|
||||
void Typeface::setTypefaceCacheSize (int numFontsToCache)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ struct ImageCache::Pimpl : private Timer,
|
|||
Pimpl() {}
|
||||
~Pimpl() { clearSingletonInstance(); }
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (ImageCache::Pimpl)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ImageCache::Pimpl)
|
||||
|
||||
Image getFromHashCode (const int64 hashCode) noexcept
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ struct ImageCache::Pimpl : private Timer,
|
|||
JUCE_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (ImageCache::Pimpl)
|
||||
JUCE_IMPLEMENT_SINGLETON (ImageCache::Pimpl)
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public:
|
|||
sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family);
|
||||
}
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (FTTypefaceList)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (FTTypefaceList)
|
||||
|
||||
private:
|
||||
FTLibWrapper::Ptr library;
|
||||
|
|
@ -288,7 +288,7 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (FTTypefaceList)
|
||||
JUCE_IMPLEMENT_SINGLETON (FTTypefaceList)
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ ModalComponentManager::~ModalComponentManager()
|
|||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (ModalComponentManager)
|
||||
JUCE_IMPLEMENT_SINGLETON (ModalComponentManager)
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
#ifndef DOXYGEN
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (ModalComponentManager)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ModalComponentManager)
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ private:
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
juce_ImplementSingleton (ContentSharer)
|
||||
JUCE_IMPLEMENT_SINGLETON (ContentSharer)
|
||||
|
||||
ContentSharer::ContentSharer() {}
|
||||
ContentSharer::~ContentSharer() { clearSingletonInstance(); }
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace juce
|
|||
class JUCE_API ContentSharer
|
||||
{
|
||||
public:
|
||||
juce_DeclareSingleton (ContentSharer, false)
|
||||
JUCE_DECLARE_SINGLETON (ContentSharer, false)
|
||||
|
||||
/** Shares the given files. Each URL should be either a full file path
|
||||
or it should point to a resource within the application bundle. For
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ struct ReportingThreadContainer : public ChangeListener,
|
|||
|
||||
ScopedPointer<ReportingThread> reportingThread;
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ReportingThreadContainer)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer)
|
||||
JUCE_IMPLEMENT_SINGLETON (ReportingThreadContainer)
|
||||
|
||||
//==============================================================================
|
||||
struct ReportingThread : public Thread,
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ void XWindowSystem::destroyXDisplay() noexcept
|
|||
LinuxEventLoop::removeWindowSystemFd();
|
||||
}
|
||||
|
||||
juce_ImplementSingleton (XWindowSystem)
|
||||
JUCE_IMPLEMENT_SINGLETON (XWindowSystem)
|
||||
|
||||
//==============================================================================
|
||||
ScopedXDisplay::ScopedXDisplay() : display (XWindowSystem::getInstance()->displayRef())
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public:
|
|||
XDisplay displayRef() noexcept;
|
||||
XDisplay displayUnref() noexcept;
|
||||
|
||||
juce_DeclareSingleton (XWindowSystem, false)
|
||||
JUCE_DECLARE_SINGLETON (XWindowSystem, false)
|
||||
|
||||
private:
|
||||
XDisplay display = {};
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ struct JuceMainMenuBarHolder : private DeletedAtShutdown
|
|||
|
||||
NSMenu* mainMenuBar = nil;
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded (JuceMainMenuBarHolder, true)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (JuceMainMenuBarHolder, true)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (JuceMainMenuBarHolder)
|
||||
JUCE_IMPLEMENT_SINGLETON (JuceMainMenuBarHolder)
|
||||
|
||||
//==============================================================================
|
||||
class JuceMainMenuHandler : private MenuBarModel::Listener,
|
||||
|
|
|
|||
|
|
@ -442,12 +442,12 @@ struct DisplaySettingsChangeCallback : private DeletedAtShutdown
|
|||
const_cast<Desktop::Displays&> (Desktop::getInstance().getDisplays()).refresh();
|
||||
}
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (DisplaySettingsChangeCallback)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (DisplaySettingsChangeCallback)
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback)
|
||||
JUCE_IMPLEMENT_SINGLETON (DisplaySettingsChangeCallback)
|
||||
|
||||
static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -755,7 +755,7 @@ struct OnScreenKeyboard : public DeletedAtShutdown,
|
|||
startTimer (10);
|
||||
}
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded (OnScreenKeyboard, true)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED (OnScreenKeyboard, true)
|
||||
|
||||
private:
|
||||
OnScreenKeyboard()
|
||||
|
|
@ -803,7 +803,7 @@ private:
|
|||
ComSmartPtr<ITipInvocation> tipInvocation;
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (OnScreenKeyboard)
|
||||
JUCE_IMPLEMENT_SINGLETON (OnScreenKeyboard)
|
||||
|
||||
//==============================================================================
|
||||
struct HSTRING_PRIVATE;
|
||||
|
|
@ -1606,7 +1606,7 @@ private:
|
|||
|
||||
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) atom; }
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (WindowClassHolder)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (WindowClassHolder)
|
||||
|
||||
private:
|
||||
ATOM atom;
|
||||
|
|
@ -3589,7 +3589,7 @@ JUCE_API ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& compo
|
|||
}
|
||||
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (HWNDComponentPeer::WindowClassHolder)
|
||||
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
TopLevelWindowManager() {}
|
||||
~TopLevelWindowManager() { clearSingletonInstance(); }
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (TopLevelWindowManager)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TopLevelWindowManager)
|
||||
|
||||
void checkFocusAsync()
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (TopLevelWindowManager)
|
||||
JUCE_IMPLEMENT_SINGLETON (TopLevelWindowManager)
|
||||
|
||||
void juce_checkCurrentlyFocusedTopLevelWindow();
|
||||
void juce_checkCurrentlyFocusedTopLevelWindow()
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
AllComponentRepainter() {}
|
||||
~AllComponentRepainter() { clearSingletonInstance(); }
|
||||
|
||||
juce_DeclareSingleton (AllComponentRepainter, false)
|
||||
JUCE_DECLARE_SINGLETON (AllComponentRepainter, false)
|
||||
|
||||
void trigger()
|
||||
{
|
||||
|
|
@ -89,8 +89,8 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
juce_ImplementSingleton (AllComponentRepainter)
|
||||
juce_ImplementSingleton (ValueList)
|
||||
JUCE_IMPLEMENT_SINGLETON (AllComponentRepainter)
|
||||
JUCE_IMPLEMENT_SINGLETON (ValueList)
|
||||
|
||||
//==============================================================================
|
||||
int64 parseInt (String s)
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ namespace LiveConstantEditor
|
|||
ValueList();
|
||||
~ValueList();
|
||||
|
||||
juce_DeclareSingleton (ValueList, false)
|
||||
JUCE_DECLARE_SINGLETON (ValueList, false)
|
||||
|
||||
template <typename Type>
|
||||
LiveValue<Type>& getValue (const char* file, int line, const Type& initialValue)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ bool PushNotifications::Notification::isValid() const noexcept { return true; }
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
juce_ImplementSingleton (PushNotifications)
|
||||
JUCE_IMPLEMENT_SINGLETON (PushNotifications)
|
||||
|
||||
PushNotifications::PushNotifications()
|
||||
#if JUCE_PUSH_NOTIFICATIONS
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class JUCE_API PushNotifications
|
|||
{
|
||||
public:
|
||||
#ifndef DOXYGEN
|
||||
juce_DeclareSingleton (PushNotifications, false)
|
||||
JUCE_DECLARE_SINGLETON (PushNotifications, false)
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ private:
|
|||
bool isRegistered() const noexcept { return atom != 0; }
|
||||
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) MAKELONG (atom, 0); }
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (NativeWindowClass)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (NativeWindowClass)
|
||||
|
||||
private:
|
||||
NativeWindowClass()
|
||||
|
|
@ -889,4 +889,4 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass)
|
||||
JUCE_IMPLEMENT_SINGLETON (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue