blob: a6d10738255f3e209ecba8db966aceee5bca31c4 [file] [log] [blame]
Christopher Piro094823a2007-07-18 00:26:12 +00001%%% Copyright (c) 2007- 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
7-module(tErlProcessor).
8
Christopher Piro5b3a8f72007-08-01 22:27:37 +00009-include("thrift.hrl").
Christopher Piro094823a2007-07-18 00:26:12 +000010-include("oop.hrl").
11-include("tErlProcessor.hrl").
12
13-behavior(oop).
14
15-export([attr/4, super/0, inspect/1]).
16
17-export([new/2, process/3]).
18
19%%%
20%%% define attributes
21%%% 'super' is required unless ?MODULE is a base class
22%%%
23
24?DEFINE_ATTR(super);
25?DEFINE_ATTR(generatedProcessor);
26?DEFINE_ATTR(handler).
27
28%%%
29%%% behavior callbacks
30%%%
31
32%%% super() -> SuperModule = atom()
33%%% | none
34
35super() ->
36 tProcessor.
37
38%%% inspect(This) -> string()
39
40inspect(This) ->
41 ?FORMAT_ATTR(generatedProcessor) ++ ", " ++
42 ?FORMAT_ATTR(handler).
43
44%%%
45%%% class methods
46%%%
47
48new(GP, Handler) ->
49 Super = (super()):new(),
50 #?MODULE{super = Super, generatedProcessor = GP, handler = Handler}.
51
52%% processor is generated code
53%% handler is user code
54
55%%%
56%%% instance methods
57%%%
58
59process(This, Iprot, Oprot) ->
60 GP = oop:get(This, generatedProcessor),
61 Handler = oop:get(This, handler),
Christopher Piro5b3a8f72007-08-01 22:27:37 +000062
Christopher Piroee598842007-08-03 23:34:55 +000063 GP:process(Handler, Iprot, Oprot).