blob: efda0341fa01f2c962efe622a4d7c2d23cf7d1ba [file] [log] [blame]
Mark Slee9f0c6512007-02-28 23:58:26 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Sleef5f2be42006-09-05 21:05:31 +00007#ifndef _THRIFT_TPROCESSOR_H_
8#define _THRIFT_TPROCESSOR_H_ 1
Mark Slee8d7e1f62006-06-07 06:48:56 +00009
10#include <string>
Mark Slee4af6ed72006-10-25 19:02:49 +000011#include <protocol/TProtocol.h>
Marc Slemko16698852006-08-04 03:16:10 +000012#include <boost/shared_ptr.hpp>
Mark Slee8d7e1f62006-06-07 06:48:56 +000013
Marc Slemko6f038a72006-08-03 18:58:09 +000014namespace facebook { namespace thrift {
15
Marc Slemko16698852006-08-04 03:16:10 +000016using namespace boost;
17
Mark Slee4af6ed72006-10-25 19:02:49 +000018using namespace facebook::thrift::protocol;
Marc Slemko6f038a72006-08-03 18:58:09 +000019
Mark Slee8d7e1f62006-06-07 06:48:56 +000020/**
21 * A processor is a generic object that acts upon two streams of data, one
22 * an input and the other an output. The definition of this object is loose,
23 * though the typical case is for some sort of server that either generates
24 * responses to an input stream or forwards data from one pipe onto another.
25 *
26 * @author Mark Slee <mcslee@facebook.com>
27 */
28class TProcessor {
29 public:
30 virtual ~TProcessor() {}
Mark Slee4af6ed72006-10-25 19:02:49 +000031
32 virtual bool process(shared_ptr<TProtocol> in,
33 shared_ptr<TProtocol> out) = 0;
34
35 bool process(shared_ptr<TProtocol> io) {
36 return process(io, io);
37 }
Mark Sleed788b2e2006-09-07 01:26:35 +000038
Mark Slee8d7e1f62006-06-07 06:48:56 +000039 protected:
40 TProcessor() {}
41};
42
Marc Slemko6f038a72006-08-03 18:58:09 +000043}} // facebook::thrift
44
Mark Sleef5f2be42006-09-05 21:05:31 +000045#endif // #ifndef _THRIFT_PROCESSOR_H_