//
//  (C) Porkolab 2003
//
//  A.8.2.
//   
//  Compilation firewalls:

In C++ when anything in a header file changes, all code that includes
the header (either directly or indirectly) must be recompiled.
To minimalize this we use PIMPL idiom:


// file x.h
class X
{
public:
    // public members
protected:
    // protected members
private:
    // pointer to forward declared class
    class XImpl *pimpl_;  // opaque pointer
};


Questions:

-- What should go into XImpl?  Options are:

1. Put all private data but not functions into XImpl.
    3/10:   Not too bed, but there is better

2. Put all private members into XImpl.
    10/10:

3. Put all private and protected members into XImpl.
    0/10:   Bad, protected members must be in X

4. Make XImpl entirely the class that X would have been,
    and write X as only the public interface made up
    entirely of simple forwarding functions (handle/body variant).
    10/10:  in some restricted cases.

-- Does XImpl require a pointer back to the X object?



Caveats:

- You can't hide virtual member functions in the Pimpl
  (here private inheritance differs from membership)

- Functions in Pimpl may require a "back pointer" to
  the visible object (by convention that is called: "self_".

- Often the best compromise is to use Option 2, and in addition
  to put into XImpl only rhose non-private functions that need
  to be called by private ones.

- 4th is better over 2nd not needed "back pointer", but X is
  useless for inheritance.