2.19.2.1. C++ Server Implementation

Method Implementation. 

class ExampleHandler : virtual public ExampleIf {
    void printString (const std::string &text) override {

        // Method implementation goes here ...

    }
    ...
}

Server Initialization. 

// Handler is the user defined implementation.
std::shared_ptr<ExampleHandler> handler (new ExampleHandler ());

// Processor is responsible for decoding function arguments and invoking the handler.
std::shared_ptr<ExampleProcessor> processor (new ExampleProcessor (handler));

// Transport provides reading and writing of byte buffers.
std::shared_ptr<TServerTransport> transport (new TServerSocket (SERVER_PORT));

// Buffered transport is a wrapper for another transport object.
std::shared_ptr<TTransportFactory> transport_factory (new TBufferedTransportFactory ());

// Protocol provides reading and writing of individual types on top of transport.
std::shared_ptr<TProtocolFactory> protocol_factory (new TBinaryProtocolFactory ());

// New connections use their own transport and protocol instances hence the factories.
std::shared_ptr<TServer> server (new TSimpleServer (processor, transport, transport_factory, protocol_factory));

server->serve ();