I undestand how container classes work, it just seems like SerialPort and SerialPortImpl do the exact same thing. It looks to me like the authors defined a class, defined another class that does pretty much the same thing, and has the first one call functions in the second one which could just as well be in the first one.

Here's some more code examples to try and explain what I mean:

SerialPort.h:
Code:
class SerialPort
{
public:
...
    /**
     * Set the parity type for the serial port.
     *
     * Returns -1 if success, 0 if error.
     */
    int
    SetParity( const Parity parityType ) throw() ;
...
private:
...
    class SerialPortImpl ;
    SerialPortImpl* mSerialPortImpl ;
SerialPort.cpp:
Code:
class SerialPort::SerialPortImpl : public PosixSignalHandler
{
public:
...
    int
    SetParity( const SerialPort::Parity parityType ) throw() ;
private:
...
    std::queue<unsigned char> mInputBuffer ;
}
...
int
SerialPort::SetParity( const Parity parityType ) throw()
{
    return mSerialPortImpl->SetParity( parityType, myErrors ) ;
}
...
inline
int
SerialPort::SerialPortImpl::SetParity( const SerialPort::Parity parityType, portErrors& errors ) throw()
{
    //
    // Make sure that the serial port is open.
    //
    if ( ! this->IsOpen() )
    {
        throw();
        return -1;
    }
    //
    // Get the current port settings.
    //
    termios port_settings ;
    if ( tcgetattr( mFileDescriptor,
                    &port_settings ) < 0 )
    {
        throw();
        return -1;
    }
    //
    // Set the parity type depending on the specified parameter.
    //
    switch( parityType )
    {
    case SerialPort::PARITY_EVEN:
        port_settings.c_cflag |= PARENB ;
        port_settings.c_cflag &= ~PARODD ;
        port_settings.c_iflag |= INPCK ;
        break ;
    case SerialPort::PARITY_ODD:
        port_settings.c_cflag |= ( PARENB | PARODD ) ;
        port_settings.c_iflag |= INPCK ;
        break ;
    case SerialPort::PARITY_NONE:
        port_settings.c_cflag &= ~(PARENB) ;
        port_settings.c_iflag |= IGNPAR ;
        break ;
    default:
        throw();
        break ;
    }
    //
    // Apply the modified port settings.
    //
    if ( tcsetattr( mFileDescriptor,
                    TCSANOW,
                    &port_settings ) < 0 )
    {
        throw();
    }
    return 0;
}