[clug-progsig] Keeping Status
John E. Jardine
john_e_jardine at spamcop.net
Thu Feb 8 05:21:06 PST 2007
If I'm way off here just /dev/null this response.
Create another class (registrar) which is responsible for storing the
current state of every managed object.
Have the constructer of each managed class invoke registrar.create() and/or
registrar.update(). The managed class destructor(s) should similarly invoke
The registrar class can manipulate and report the list of object instances.
For your purposes, add another method to update the instance status.
+ You may also want to store timestamps with the list so you can figure out
how long it takes to transition the states.
----- Original Message -----
From: "Shawn" <sgrover at open2space.com>
To: "CLUG PROGSIG" <clug-progsig at clug.ca>
Sent: Thursday, February 08, 2007 2:12 PM
Subject: [clug-progsig] Keeping Status
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> This weeks challenge... :)
> I have a number of objects, some of which will work asynchronously, and
> almost all of them can have different states at any given time while
> processing is happening. I need to be able to display the "current"
> status, but the asynch and multi state issues are causing grief.
> So, I'm looking for ideas.
> The model is something like this:
> objectA.arrayB (contains objectB's)
> objectB.arrayD (contains objectD's)
> objectD.arrayE (yes, same type of object as objectC's array)
> So, when objectA loads, it get's it's list of objectBs.
> Then each objectB is told to get it's data, and so on.
> Each object is operating asynchronously. So, I can't just set a global
> status flag. (objectX might still be loading, but objectY may have
> cleared the status, which is not indicative of what's really happening
> at that point in time).
> I've tried to give each object a "state" queue, which is a simple array
> of messages and timestamps. Then objectA displays the latest "state" as
> it's status, and each time a state is changed, it calls the routine to
> redetermine the current state. Unfortunately this isn't working well.
> I thought about using an observer pattern, but am not quite sure that's
> the right answer here, and it could have substantial impact on the code.
> (seeing as it wasn't written with an explicit pattern approach)
> I've been trying to resolve this for the past 4 hours, and I can't help
> but fell my approach is just wrong. So I'm looking for alternatives.
> Any suggestions are appreciated.
> (NOTE: the above problem has been highly simplified for the purpose of
> posting here. In some ways it's not quite as complex, and in other ways
> it's MUCH MUCH more complex... :)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> -----END PGP SIGNATURE-----
> clug-progsig mailing list
> clug-progsig at clug.ca
More information about the clug-progsig