From: Gerrit V. <vo...@ca...> - 2008-11-21 02:46:30
|
Hi, On Thu, 2008-11-20 at 18:21 -0600, Carsten Neumann wrote: > Hi Gerrit, > > >> Then finally it seems nice to be able to use > >> a derived type for the global instance, instead of being fixed to what > >> OpenSG comes with. So basically I'm changing SceneFileHandlerBase a bit > >> and instead of > >> > >> typedef SingletonHolder<SceneFileHandlerBase> SceneFileHandler; > >> > >> it is: > >> > >> class SceneFileHandler > >> { > >> public: > >> static SceneFileHandlerBase *the(void); > >> > >> static bool destroy (void ); > >> static void setSingleton(SceneFileHandlerBase *singleton); > >> > >> private: > >> static SceneFileHandlerBaseRefPtr _the; > >> }; > >> > >> so that _the can be replaced. > > > > Hmm, why do you still need the singleton structure at all (it is no > > singleton anymore anyway), and you plan to pass the handler pointer to > > the individual file handlers, so get rid of it. Just let the users > > create the global handler they want. > > > > Actually a compromise would be let the old singleton structure be there > > for convenience and just pass the required pointers to the actual file > > handlers so they don't have to go to the global one. This way the users > > can start out with whatever global handler they like. > > yes, that was the idea - allow creation of your own objects and keep the > singleton just as a convenient (backwards compatible) way of getting the > global handler. ok I might have been a little unclear, actually I guess not only a little ;-). What I wanted to say was that I would switch from the singleton to a prototype/factory pattern. In general I would try to work out the general infrastructure things (compression/encryption/caching) first and than, as a last step do this transition. kind regards, gerrit |