On Thu, Sep 28, 2006 at 12:39:57PM +0200, Abdelrazak Younes wrote:
> Again, I prefer to have one single point of access for all global
> variable. The logical place to put them is in Application. When it's
> written "theApp->XXX", I know that this is a unique instance variable.
> "XXX" alone doesn't tell me anything by itself.
You could have global accessors
Applcation & theApplication()
LyXFunc & theLyXFunc()
BufferList & theBufferList()
etc.
> I am not sure I parsed the above correctly... Application is designed
> specifically for this: it contains unique instance of objects:
>
> - Clipboard
> - Selection
> - LyXFunc
> - BufferList
>
> I might add some more (egg quitting).
>
> Are you sure that gcc doesn't? You can compile this:
>
> class A;
>
> class B {
> private:
> boost::scoped_ptr<A> a_;
> }
If it compiles it is coincidence. It is not required to
compile without a full declaration of 'A' in scope.
So MSVC is not to blame here.
> >I hope you mean pimpl Application.
>
> Of course I mean "put these member in a pimpled Application".
Ok.. so if 'Application' is really only a very cheap wrapper around a
set of otherwise global entities, and everything hides behind a pimple
such that #include "Application.h" is really cheap (as in "does not
ppull in other headers") I could live with it even as a long-term
solution even if I think that serpate singletons are better.
More of a rationale:
class Foo {
Bar & bar();
};
Foo & theFoo();
theFoo().bar()
is basically equivalent to
class Foo {
static Bar & bar();
};
Foo::bar()
which in turn is equivalent to
namespace Foo {
Bar & bar();
};
Foo::bar()
which in turn is not much different from
Bar & fooBar();
fooBar()
or,. for clarity
Bar & theBar();
theBar()
Andre'