|
|
clipka wrote:
> Darren New schrieb:
>>
>> What I'm doing right now is declaring
>> struct _IDirectFB; struct _IDirectFBFont; ...
>> class dfbScreen {
>> struct _IDirectFB* dfb;
>> struct _IDirectFBFont* font;
>> ...
>> }
>>
>> But that seems wrong, given that I have to grope around in someone
>> else's headers to pull out private declarations to make it possible to
>> compile a header that doesn't depend on those declarations.
>
> Yes, that's why you normally /do/ include the headers... after all,
> that's what they are for.
It seems wrong that I should have to expose the DirectFB declarations to
classes that don't care about the directfb declarations, simply because the
private parts of one of the classes they use has a pointer to something in
the directfb libs. That's what's the "seems wrong" part.
> I'm not sure, but you might also be able to directly use
> struct IDirectFB;
IDirectFB isn't a struct or a class. It's a typedef. Therein lies the problem.
> Unfortunately, C++ doesn't natively make a good job at separating
> interface from implementation (the bane of allowing direct access to
> data members, and "inlining" of classes as data members).
Yeah. Plus having to declare everything *and* define it.
> Speaking of interfaces, you might make dfbScreen abstract (serving as
> what would usually be declared as an interface in Java), so that you can
> keep the actual implementation of it in the background - private data
> members included.
What I did for the "real" library interface was to have a Player and a
Player_p object, and the Player.h forward-declared Player_p and the
Player.cpp included the actual definition. It's just an extra level of
indirection and another header file and such, which seemed unnecessary for a
unit-test helper function. (Only the fact that I expect to have to do unit
tests for multiple GUI bits drove me to make it separate from the unit tests
to start with, and then I got sidetracked down to figuring out how to do it
better. :-)
--
Darren New, San Diego CA, USA (PST)
I ordered stamps from Zazzle that read "Place Stamp Here".
Post a reply to this message
|
|