blob: e75c6598ab725100465414d70c24f6bf55dd75c0 [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"
ccheeverf53b5cf2007-02-05 20:33:11 +00007#include "t_doc.h"
Mark Slee31985722006-05-24 21:45:31 +00008
9/**
Mark Sleef5377b32006-10-10 01:42:59 +000010 * Representation of a function. Key parts are return type, function name,
11 * optional modifiers, and an argument list, which is implemented as a thrift
12 * struct.
Mark Slee31985722006-05-24 21:45:31 +000013 *
14 * @author Mark Slee <mcslee@facebook.com>
15 */
ccheeverf53b5cf2007-02-05 20:33:11 +000016class t_function : public t_doc {
Mark Slee31985722006-05-24 21:45:31 +000017 public:
Mark Slee52f643d2006-08-09 00:03:43 +000018 t_function(t_type* returntype,
19 std::string name,
20 t_struct* arglist,
21 bool async=false) :
22 returntype_(returntype),
23 name_(name),
24 arglist_(arglist),
Mark Slee9cb7c612006-09-01 22:17:45 +000025 async_(async) {
Mark Sleef0712dc2006-10-25 19:03:57 +000026 xceptions_ = new t_struct(NULL);
Mark Slee9cb7c612006-09-01 22:17:45 +000027 }
28
Mark Slee9cb7c612006-09-01 22:17:45 +000029 t_function(t_type* returntype,
30 std::string name,
31 t_struct* arglist,
32 t_struct* xceptions,
33 bool async=false) :
34 returntype_(returntype),
35 name_(name),
36 arglist_(arglist),
37 xceptions_(xceptions),
Mark Slee52f643d2006-08-09 00:03:43 +000038 async_(async) {}
Mark Slee31985722006-05-24 21:45:31 +000039
40 ~t_function() {}
41
Mark Sleef5377b32006-10-10 01:42:59 +000042 t_type* get_returntype() const {
43 return returntype_;
44 }
45
46 const std::string& get_name() const {
47 return name_;
48 }
49
50 t_struct* get_arglist() const {
51 return arglist_;
52 }
53
54 t_struct* get_xceptions() const {
55 return xceptions_;
56 }
57
58 bool is_async() const {
59 return async_;
60 }
Mark Sleeb15a68b2006-06-07 06:46:24 +000061
Mark Slee31985722006-05-24 21:45:31 +000062 private:
63 t_type* returntype_;
64 std::string name_;
65 t_struct* arglist_;
Mark Slee9cb7c612006-09-01 22:17:45 +000066 t_struct* xceptions_;
Mark Slee52f643d2006-08-09 00:03:43 +000067 bool async_;
Mark Slee31985722006-05-24 21:45:31 +000068};
69
70#endif