Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #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 Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 9 | * 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 Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 12 | * |
| 13 | * @author Mark Slee <mcslee@facebook.com> |
| 14 | */ |
| 15 | class t_function { |
| 16 | public: |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 17 | 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 Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 24 | async_(async) { |
| 25 | xceptions_ = new t_struct; |
| 26 | } |
| 27 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 28 | 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 Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 37 | async_(async) {} |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 38 | |
| 39 | ~t_function() {} |
| 40 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 41 | 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 Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 60 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 61 | private: |
| 62 | t_type* returntype_; |
| 63 | std::string name_; |
| 64 | t_struct* arglist_; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 65 | t_struct* xceptions_; |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 66 | bool async_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | #endif |