Compiler Firewall Idiom - Accessing implementation from another class

closed account (3hM2Nwbp)
This idiom seems to make more of a mess in my particular case than anything else.

Consider the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

class SocketAcceptor
{
  class ISocketAcceptor;
  ISocketAcceptor* impl;
};

class Session
{
  friend SocketAcceptor;
  class ISession;
  ISession* impl;
}

/* I want to...
ISocketAcceptor::start(void)
{
  Session* session = new Session();
  session->impl->doSomething();
  // but ISession is not defined here
*/


Is there a way that I could access ISession from SocketAcceptor? The reason for this is to hide the last remaining implementation detail from the public interface of Session - the socket service that the sessions are attached to. What I want to avoid is having a Session constructor that takes the socket service as an argument.

Oh...and on a side note:
Is there a programmer's version of writer's block? Every time I set up a different API like this, do all of the testing, etc...I think of a new "better?" way of doing it and start over. Crumple up the old design and throw it in the trash...then get a blank sheet out and repeat the process. Right now my VS2010 directory has 5 different networking models in it :\

Thanks for your time,
Luc
Last edited on
Topic archived. No new replies allowed.