comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz;
2
3 import java.util.ArrayList;
4
5 /**
6 @see org.dancres.blitz.ActiveObject
7 */
8 public class ActiveObjectRegistry {
9 private static ArrayList theObjects = new ArrayList();
10 private static boolean haveStarted = false;
11
12 public synchronized static void add(ActiveObject anObject) {
13 theObjects.add(anObject);
14
15 // If already started we have to "automagically" start this object.
16 if (haveStarted)
17 anObject.begin();
18 }
19
20 public synchronized static void startAll() {
21 haveStarted = true;
22
23 for (int i = 0; i < theObjects.size(); i++) {
24 ((ActiveObject) theObjects.get(i)).begin();
25 }
26 }
27
28 public synchronized static void stopAll() {
29 for (int i = 0; i < theObjects.size(); i++) {
30 ActiveObject myObject = (ActiveObject) theObjects.get(i);
31 myObject.halt();
32 }
33 }
34
35 public synchronized static boolean hasStarted() {
36 return haveStarted;
37 }
38 }