Mercurial > hg > blitz_stable
diff src/org/dancres/blitz/ActiveObjectRegistry.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/dancres/blitz/ActiveObjectRegistry.java Sat Mar 21 11:00:06 2009 +0000 @@ -0,0 +1,38 @@ +package org.dancres.blitz; + +import java.util.ArrayList; + +/** + @see org.dancres.blitz.ActiveObject + */ +public class ActiveObjectRegistry { + private static ArrayList theObjects = new ArrayList(); + private static boolean haveStarted = false; + + public synchronized static void add(ActiveObject anObject) { + theObjects.add(anObject); + + // If already started we have to "automagically" start this object. + if (haveStarted) + anObject.begin(); + } + + public synchronized static void startAll() { + haveStarted = true; + + for (int i = 0; i < theObjects.size(); i++) { + ((ActiveObject) theObjects.get(i)).begin(); + } + } + + public synchronized static void stopAll() { + for (int i = 0; i < theObjects.size(); i++) { + ActiveObject myObject = (ActiveObject) theObjects.get(i); + myObject.halt(); + } + } + + public synchronized static boolean hasStarted() { + return haveStarted; + } +}