Singletons.kl

Functions

Singleton_has

Boolean Singleton_has ( in String key )

returns true if a singleton with a given name exists

Singleton_set

Singleton_set ( in String key, in Object obj )

stores a singleton

Singleton_init

Object Singleton_init ( in String key, in Object obj )

inits a singleton: sets it only if ‘null’, and returns set value. The returned should be used if the singleton needs to be unique among threads.

Singleton_get

Object Singleton_get ( in String key )

retrieves a singleton

Singleton_remove

Boolean Singleton_remove ( in String key )

deletes a singleton

Singleton_removeAll

Singleton_removeAll ()

deletes all known singletons

GetOrCreateSingleton

Ref<Object> GetOrCreateSingleton ( in String key, in Type singletonObjectType )

Checks if a singleton exists with this key. If not, a new object is created from the passed-in type. This allowa to create an Object only when possible.