interface/template.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: shift_jis -*-
3 # -*- python -*-
4 #
5 # @file template.py
6 # @brief doil interface header template
7 # @date $Date$
8 # @author Noriaki Ando <n-ando@aist.go.jp>
9 #
10 # Copyright (C) 2008
11 # Task-intelligence Research Group,
12 # Intelligent Systems Research Institute,
13 # National Institute of
14 # Advanced Industrial Science and Technology (AIST), Japan
15 # All rights reserved.
16 #
17 # $Id$
18 #
19 
20 types_h = """\
21 // -*- C++ -*-
22 /*!
23  * @file [types_h]
24  * @brief C++ interface definition for doil
25  * @date $Date$
26  * @author This file was automatically generated by omniidl/doil backend
27  * This file was generated from [idl_fname].
28  *
29  * $Id$
30  */
31 
32 #ifndef [types_include_guard]
33 #define [types_include_guard]
34 
35 #include <vector>
36 #include <string>
37 
38 [for inc in include_h]
39 #include <[inc]>
40 [endfor]
41 
42 [for iinc in idl_includes]
43 #include <[iinc.types_h_path]>
44 [endfor]
45 
46 [for decl in declarations]
47 [decl]
48 [endfor]
49 #endif // [types_include_guard]
50 
51 """
52 
53 ns_decl = """
54 [for-inv ens in end_ns]
55 }; // namespace [ens]
56 [endfor]
57 [for bns in begin_ns]
58 namespace [bns]
59 {
60 [endfor]
61 
62 """
63 
64 ifacefwd_decl = """\
65  // forward declaration of interface
66  class [local.iface_name];
67 
68 """
69 
70 struct_decl = """\
71  // struct
72  struct [local.name]
73  {
74 [for mem in members]
75  [mem.local.member_type] [mem.local.member_name];
76 [endfor]
77  };
78 
79 """
80 
81 structfwd_decl = """\
82  // struct
83  struct [local.name];
84 
85 """
86 
87 union_decl = """\
88  // union
89  class [local.name]
90  {
91  public:
92  [local.name](){}
93  virtual ~[local.name](){}
94 
95 [for cas in cases]
96  [local.name]([cas.local.case_type] var)
97  : m_type([cas.local.discriminator]),
98  m_[cas.local.case_member](var){}
99 
100  [cas.local.case_type] get_[cas.local.case_member]() const
101  {
102  return m_[cas.local.case_member];
103  }
104  void set_[cas.local.case_member]([cas.local.case_type] var)
105  {
106  m_type = [cas.local.discriminator];
107  m_[cas.local.case_member] = var;
108  }
109 [endfor]
110 
111  [local.switch_fq_type] get_type() const
112  {
113  return m_type;
114  }
115  private:
116  [local.switch_fq_type] m_type;
117 [for cas in cases]
118  [cas.local.case_type] m_[cas.local.case_member];
119 [endfor]
120 
121  };
122 
123 """
124 
125 unionfwd_decl = """\
126  class [local.name];
127 
128 """
129 
130 enum_decl = """\
131  // enum
132  enum [local.name]
133  {
134 [for mem in local.members]
135 [if-index mem is last]
136  [mem]
137 [else]
138  [mem],
139 [endif]
140 [endfor]
141 
142  };
143 
144 """
145 
146 exception_decl = """\
147  // struct
148  struct [local.name]
149  {
150 [for mem in members]
151  [mem.local.member_type] [mem.local.member_name];
152 [endfor]
153  };
154 
155 """
156 
157 typedef_decl = """\
158  // typedef
159  typedef [local.base_type] [local.derived_type];
160 
161 """
162 
163 
164 
165 interface_h = """\
166 // -*- C++ -*-
167 /*!
168  * @file [local.iface_h]
169  * @brief [local.iface_name] C++ interface definition for doil
170  * @date $Date$
171  * @author This file was automatically generated by omniidl/doil backend
172  *
173  * $Id$
174  */
175 
176 #ifndef [local.iface_include_guard]
177 #define [local.iface_include_guard]
178 
179 #include <doil/ImplBase.h>
180 [for inc in local.include_h]
181 #include <[inc]>
182 [endfor]
183 
184 [for iinc in idl_includes]
185 #include <[iinc.types_h_path]>
186 [endfor]
187 #include <[types_h_path]>
188 
189 [for ih in inherits]
190 #include <[ih.local.iface_h_path]>
191 [endfor]
192 
193 [for ns in local.iface_ns]
194 namespace [ns]
195 {
196 [endfor]
197  /*!
198  * @if jp
199  * @class [local.iface_name]
200  * @brief [local.iface_name] インターフェースクラス
201  * @else
202  * @class [local.iface_name]
203  * @brief [local.iface_name] interface class
204  * @endif
205  */
206  class [local.iface_name]
207  : public virtual doil::LocalBase
208 [for ih in inherits]
209 [if-index ih is last],
210  public virtual [ih.local.iface_name_fq]
211 [else],
212  public virtual [ih.local.iface_name_fq]
213 [endif]
214 [endfor]
215 
216  {
217  public:
218  virtual ~[local.iface_name](){};
219 
220 [for op in operations]
221  virtual [op.return.local.retn_type] [op.name]([for a in op.args]
222 [if-index a is last][a.local.arg_type] [a.local.arg_name]
223 [else][a.local.arg_type][a.local.arg_name], [endif]
224 [endfor])
225  throw ([for raise in op.raises]
226 [if-index raise is first]
227 [raise.local.name_fq]
228 [else]
229 ,
230  [raise.local.name_fq]
231 [endif]
232 [endfor]
233 ) = 0;
234 
235 [endfor]
236  };
237 [for-inv ns in local.iface_ns]
238 }; // namespace [ns]
239 [endfor]
240 
241 #endif // [local.iface_include_guard]
242 
243 """
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 a = """
271 [for td in typedefs]
272 [if td.corba.tk is "tk_sequence"][if td.corba.sq_tk is "tk_struct"]
273 [if td.local.deref_sq_type is st.local.base_type]
274  typedef [td.local.deref_fq_type] [td.local.derived_type];
275 [endif][endif][endif]
276 [endfor]
277 
278  //------------------------------------------------------------
279  // rest of typedef
280  //------------------------------------------------------------
281 [for td in typedefs]
282 [if td.corba.tk is "tk_sequence"]
283 [if td.corba.sq_tk is "tk_struct"]
284 [elif td.corba.sq_tk is "tk_objref"]
285 [else]
286  typedef [td.local.deref_fq_type] [td.local.derived_type];
287 [endif]
288 [else]
289  typedef [td.local.deref_fq_type] [td.local.derived_type];
290 [endif]
291 [endfor]
292 
293 
294 [for ns in iface_ns]
295 }; // namespace [ns]
296 [endfor]
297 
298 #endif // [types_include_guard]
299 """


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:56