mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Singleton: Add new macros to simplify singleton creation
The INLINE macros allow singletons to be declared and defined in one line, without requiring a separate JUCE_IMPLEMENT_SINGLETON statement.
This commit is contained in:
parent
5179f4e720
commit
80ac9a78a0
44 changed files with 69 additions and 138 deletions
|
|
@ -63,7 +63,7 @@ public:
|
|||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
JUCE_DECLARE_SINGLETON (TypefaceCache, false)
|
||||
JUCE_DECLARE_SINGLETON_INLINE (TypefaceCache, false)
|
||||
|
||||
void setSize (const int numToCache)
|
||||
{
|
||||
|
|
@ -170,8 +170,6 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache)
|
||||
};
|
||||
|
||||
JUCE_IMPLEMENT_SINGLETON (TypefaceCache)
|
||||
|
||||
void Typeface::setTypefaceCacheSize (int numFontsToCache)
|
||||
{
|
||||
TypefaceCache::getInstance()->setSize (numFontsToCache);
|
||||
|
|
|
|||
|
|
@ -61,14 +61,12 @@ public:
|
|||
return cachedTypefaces.get (key, std::forward<Fn> (getTypeface));
|
||||
}
|
||||
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TypefaceFileCache)
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL_INLINE (TypefaceFileCache)
|
||||
|
||||
private:
|
||||
LruCache<TypefaceFileAndIndex, Typeface::Ptr> cachedTypefaces;
|
||||
};
|
||||
|
||||
JUCE_IMPLEMENT_SINGLETON (TypefaceFileCache)
|
||||
|
||||
} // namespace juce
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue