GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Bugs, Fixes, Releases » Bug in sigleton classes in fairbase/base
Re: Bug in sigleton classes in fairbase/base [message #9629 is a reply to message #9628] Tue, 27 October 2009 15:09 Go to previous messageGo to previous message
Bertram Kopf is currently offline  Bertram Kopf
Messages: 110
Registered: March 2006
continuous participant
From: *ep1.ruhr-uni-bochum.de
Hi Mohammad,
Mohammad Al-Turany wrote


... but I do not agree that you can create these classes more than once, there is protection in the ctor which prevent this, so I am wondering how could you create any of these more than once! did you try it?


I didn't look closer into the ctor. You are right, there is a protection against it. If you try to create a second object , then the application will crash.
But if you would like to call the function "Instance()" without creating the object before, one gets back 0 pointer. And this definitely is not the idea of a singleton.


Mohammad Al-Turany wrote


the only reason that we kept this attempt to write singletons as it is that if we put the ctor as privet then you have to call always the instance so nobody can call new FairRun for example directly ...
Mohammad


But exactly this should be avoided in a singleton. The only way to get access to a singleton object should be possible via a static instance function. The singleton itself has to take care of calling its own ctor.
Therefore I would prefer to follow the recommendations of object oriented design patterns.

Cheers,
Bertram.
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problems with integer FairTrackPar charge
Next Topic: Can't run Geane
Goto Forum:
  


Current Time: Mon Jun 17 22:11:39 CEST 2024

Total time taken to generate the page: 0.00980 seconds