OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
t_function.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef T_FUNCTION_H
21 #define T_FUNCTION_H
22 
23 #include <string>
24 #include "t_type.h"
25 #include "t_struct.h"
26 #include "t_doc.h"
27 
34 class t_function : public t_doc {
35  public:
36  t_function(t_type* returntype,
37  std::string name,
38  t_struct* arglist,
39  bool oneway=false
40 #ifdef SANDESH
41  ,
42  bool is_virtual=false,
43  bool is_static=false
44 #endif
45  ) :
46  returntype_(returntype),
47  name_(name),
48  arglist_(arglist),
49  oneway_(oneway),
50 #ifdef SANDESH
51  virtual_(is_virtual),
52  static_(is_static)
53 #endif
54  {
55  xceptions_ = new t_struct(NULL);
56  }
57 
58  t_function(t_type* returntype,
59  std::string name,
60  t_struct* arglist,
61  t_struct* xceptions,
62  bool oneway=false
63 #ifdef SANDESH
64  ,
65  bool is_virtual=false,
66  bool is_static=false
67 #endif
68  ) :
69  returntype_(returntype),
70  name_(name),
71  arglist_(arglist),
72  xceptions_(xceptions),
73  oneway_(oneway)
74 #ifdef SANDESH
75  ,
76  virtual_(is_virtual),
77  static_(is_static)
78 #endif
79  {
80  if (oneway_ && !xceptions_->get_members().empty()) {
81  throw std::string("Oneway methods can't throw exceptions.");
82  }
83  }
84 
86 
88  return returntype_;
89  }
90 
91  const std::string& get_name() const {
92  return name_;
93  }
94 
95  t_struct* get_arglist() const {
96  return arglist_;
97  }
98 
100  return xceptions_;
101  }
102 
103  bool is_oneway() const {
104  return oneway_;
105  }
106 #ifdef SANDESH
107  bool is_virtual() const {
108  return virtual_;
109  }
110 
111  bool is_static() const {
112  return static_;
113  }
114 #endif
115 
116  private:
118  std::string name_;
121  bool oneway_;
122 #ifdef SANDESH
123  bool virtual_;
124  bool static_;
125 #endif
126 };
127 
128 #endif
t_function(t_type *returntype, std::string name, t_struct *arglist, t_struct *xceptions, bool oneway=false)
Definition: t_function.h:58
std::string name_
Definition: t_function.h:118
t_type * returntype_
Definition: t_function.h:117
Definition: t_type.h:48
const std::string & get_name() const
Definition: t_function.h:91
t_type * get_returntype() const
Definition: t_function.h:87
const members_type & get_members()
t_struct * get_xceptions() const
Definition: t_function.h:99
Definition: t_doc.h:27
t_struct * xceptions_
Definition: t_function.h:120
bool oneway_
Definition: t_function.h:121
t_function(t_type *returntype, std::string name, t_struct *arglist, bool oneway=false)
Definition: t_function.h:36
t_struct * arglist_
Definition: t_function.h:119
bool is_oneway() const
Definition: t_function.h:103
t_struct * get_arglist() const
Definition: t_function.h:95