Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5640


Ignore:
Timestamp:
Aug 13, 2009, 1:01:47 AM (15 years ago)
Author:
landauf
Message:

Added a new utility "ScopedSingleton". A ScopedSingleton has a scope which is represented by a Scope template. ScopedSingletons are allowed to exist (= get created automatically after the first call to getInstance()) as soon as at least one instance of the corresponding Scope exists. If all those instances of Scope are deleted, the corresponding ScopedSingletons are destroyed too.

This allows us to create Singletons (for example the QuestManager) which may exist in a plugin and still get created and destroyed in parallel with GSLevel (or whatever Scope you like). All we have to do is to create and destroy one instance of Scope in GSLevel (or whoever defines the Scope). Therefore we don't have to link the singleton into GSLevel which is quite handy if we want to build independent plugins.

Btw, this can be expanded to other constructs, not just singletons. Just inherit from ScopeListener to get the full load of features.

(Note to Reto: I had to add a "ScopeManager" which ensures static linkage of the scope counters and listeners. Otherwise we'd end up with different counts in each library which is quite bad. Maybe you have a better idea? Or maybe you want to make the ScopeManager a singleton too? ;))

Location:
code/branches/libraries/src/util
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
Note: See TracChangeset for help on using the changeset viewer.