C++ adapter class to wrap actual implementation
<p>Objective: "wrap" actual implementation of IPC communication bus to allow clients to interface to generic API and allow possible future replacement of underlying IPC implementation.</p>

<p>Here is what I came up with. Note: I'm a C-guy moving to C++.  Is there a better way of solving this problem? </p>

<p>Note: I want clients to interface only with my wrapper/interface and not be required to include any protocol specific code or setup include paths for implementation specific header files.</p>

<p>I've trolled through the design patterns.  I think I want an adapter/wrapper pattern but the order of Interface_impl : public Interface inheritance requires the client set up include paths for the specific impelementation.</p>

<p>The interface/wrapper is UMSConnector which calls the actual implementation UMSConnector_impl.</p>

<pre><code>// "interface"
class UMSConnector {
public:
    static UMSConnector * instance(const string&amp; name) {
        static UMSConnector *pInstance;
        if( ! pInstance ) {
            pInstance = new UMSConnector(name);
            return pInstance;
        }
        return pInstance;
    }

    // interface API to be implemented by UMSConnector_impl
    bool addEventHandler(string event);

private:
    class UMSConnector_impl;
    UMSConnector_impl *pImpl;
    Logger log;
    string name;

    UMSConnector(const string&amp; name);
    ~UMSConnector();
    UMSConnector(UMSConnector const&amp; ) {};  // copy constructor
    void operator=(const UMSConnector&amp;) {};  // assignment constructor
};

UMSConnector::UMSConnector(const string&amp; name)
             : name(name) {
  LOG_TRACE(log,"called");
  pImpl = new UMSConnector_impl();
}

UMSConnector::~UMSConnector() {
  LOG_TRACE(log,"called");
  delete pImpl;
  pImpl = NULL;
}

bool UMSConnector::addEventHandler(string event)
{
    if( pImpl ) {
        return pImpl-&gt;addEventHandler(event);
    }
    return false;
}

// "implementation"
class UMSConnector::UMSConnector_impl {
public:
    bool addEventHandler(const string&amp; event);

private:
    Logger log;
};

bool UMSConnector::UMSConnector_impl::addEventHandler(const string&amp; event)
{
  LOG_TRACE(log,"UMSConnector_impl::addEventHandler: event=%s",event.c_str());
  return true;
}
</code></pre>
