blob: 3d07171114d5482a46d5977e41912c33108a7a08 [file] [log] [blame]
Mark Slee31985722006-05-24 21:45:31 +00001#ifndef T_FUNCTION_H
2#define T_FUNCTION_H
3
4#include <string>
5#include "t_type.h"
6#include "t_struct.h"
7
8/**
Mark Sleef5377b32006-10-10 01:42:59 +00009 * Representation of a function. Key parts are return type, function name,
10 * optional modifiers, and an argument list, which is implemented as a thrift
11 * struct.
Mark Slee31985722006-05-24 21:45:31 +000012 *
13 * @author Mark Slee <mcslee@facebook.com>
14 */
15class t_function {
16 public:
Mark Slee52f643d2006-08-09 00:03:43 +000017 t_function(t_type* returntype,
18 std::string name,
19 t_struct* arglist,
20 bool async=false) :
21 returntype_(returntype),
22 name_(name),
23 arglist_(arglist),
Mark Slee9cb7c612006-09-01 22:17:45 +000024 async_(async) {
25 xceptions_ = new t_struct;
26 }
27
Mark Slee9cb7c612006-09-01 22:17:45 +000028 t_function(t_type* returntype,
29 std::string name,
30 t_struct* arglist,
31 t_struct* xceptions,
32 bool async=false) :
33 returntype_(returntype),
34 name_(name),
35 arglist_(arglist),
36 xceptions_(xceptions),
Mark Slee52f643d2006-08-09 00:03:43 +000037 async_(async) {}
Mark Slee31985722006-05-24 21:45:31 +000038
39 ~t_function() {}
40
Mark Sleef5377b32006-10-10 01:42:59 +000041 t_type* get_returntype() const {
42 return returntype_;
43 }
44
45 const std::string& get_name() const {
46 return name_;
47 }
48
49 t_struct* get_arglist() const {
50 return arglist_;
51 }
52
53 t_struct* get_xceptions() const {
54 return xceptions_;
55 }
56
57 bool is_async() const {
58 return async_;
59 }
Mark Sleeb15a68b2006-06-07 06:46:24 +000060
Mark Slee31985722006-05-24 21:45:31 +000061 private:
62 t_type* returntype_;
63 std::string name_;
64 t_struct* arglist_;
Mark Slee9cb7c612006-09-01 22:17:45 +000065 t_struct* xceptions_;
Mark Slee52f643d2006-08-09 00:03:43 +000066 bool async_;
Mark Slee31985722006-05-24 21:45:31 +000067};
68
69#endif