[openbeos-midi] Re: goals update?

  • From: Michael Pfeiffer <michael.pfeiffer@xxxxxxxxx>
  • To: openbeos-midi@xxxxxxxxxxxxx
  • Date: Tue, 04 Jun 2002 22:29:50 +0000

>shaggyafterjack <shaggyafterjack@xxxxxxxxx> wrote:
>>Also, how to implement a global bsynth object named be_synth globally per 
>application and detect
>>the whether it has been initialized or not?  Is there an objects database 
>the be framework that
>>I can do a look up or is it something more fundamental in the language (C++
>than that?
>This is simple. 
>You already have 
>extern _IMPEXP_MIDI BSynth *be_synth;
>in the header file.
>The only thing you need in you cpp file is a global object, and the pointer 
>do it like this:
>static BSynth be_synth_object;
>BSynth *be_synth = &be_synth_object;

The BeBook describes that the constructor of the  other synthesis classes 
(BMidiSynth, BMidiSynthFile, ...) create a BSynth object if it does not 
already exists.
Not sure if this has to be MT-safe, if it has to be then some kind of
locking mechanism is required.
And I have not found a word about when be_synth will be destroyed as well.

If be_synth is destroyed when an application terminates, it could be 
implemented this way:

class BSynthAutoDeleter {
    ~BSynthAutoDeleter() {
        delete be_synth; be_synth = NULL;

and a global variable:
static BSynthAutoDeleter __delete_be_synth_on_exit;

Any better possibilities to do this?

- Michael

Other related posts: