[openbeos] Re: state-keeping app

  • From: "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Thu, 01 Aug 2002 23:49:56 CEST (+0200)

> En réponse à Jonas Sundstrom <kirilla@xxxxxxxxx>:
> 
> > I'd do it something like this:
> > 
> > - a new resource flag: "Remember state"
> >   (something like that)
> > 
> > - a B_LOAD_STATE app launch message
> > 
> > - a B_SAVE_STATE shutdown message
> >   (probably a B_QUIT_REQUESTED with a "save_state" field)

Actually I would provide the application programmer with a little bit 
more comfortable interface. E.g. two new BApplication hook methods

  status_t StoreState(BDataIO *state);
  status_t RestoreState(BDataIO *state);

A BDataIO should be better than a BMessage, as applications with a 
greater amount of data to be saved/loaded certainly don't want to put 
it into a BMessage first, whereas the others are free to internally use 
a BMessage and just Flatten() it to/Unflatten() it from the BDataIO.

> Yeah, I'm pretty sure the shutdown command just sends 
> B_QUIT_REQUESTED with 
> a special flag on the BMessage, can't remember where I read that 
> though.

Actually the registrar is the one responsible for system shutdown and 
it the flag you mean is the boolean field "_shutdown_".

> > The resource flag would keep non-state-aware apps 
> > out of the loop
> > 
> Or just those that ignore the flag on QUIT_REQUESTED ?
> 
> > The load/save messages would put the actual 
> > state-management in the hands of the application.
> > (different apps - different ways of saving state)
> > 
> > All backwards-compatible with Be's R5.

So are hook methods. The BApplication implementation would just return 
B_UNSUPPORTED or another meaningful error.

CU, Ingo



Other related posts: