wsdlpull  1.23
Binding.h
Go to the documentation of this file.
1 /*
2  * wsdlpull - A C++ parser for WSDL (Web services description language)
3  * Copyright (C) 2005-2007 Vivek Krishna
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *
20  */
21 #ifndef _BINDINGH
22 #define _BINDINGH
23 
24 #include "wsdlparser/WsdlElement.h"
26 
27 namespace WsdlPull {
28 class PortType;
29 const int MAX_EXT_ELEM=50;
30 
31 //Wsdl Binding element
32 class WSDLPULL_EXPORT Binding:public WsdlElement
33 {
34 
38  public:
39  typedef std::list<Binding*>::iterator BindingIterator;
40  typedef std::list<Binding*>::const_iterator cBindingIterator;
41 
42  Binding(WsdlParser & w);
43  ~Binding();
44 
52  int getBindingInfo() const;
57  const PortType *getPortType() const;
62  int getServiceExtId() const;
63 
68  int numOps(void) const;
69 
75  const Operation *getOperation(int index) const;
82  std::string getBindingMethod()const;
83 
84 
91  int getOpBinding(int index, const int*& bindings) const;
92  int getOutputBinding(int index, const int*& bindings) const;
93  int getInputBinding(int index, const int*& bindings) const;
94  int getFaultBinding(int index, const int*& bindings) const;
96 
103  void setPortType(const PortType * pt);
104  void setBindingInfo(int id);
105  void setBindingMethod(const std::string & ns);
106  void addServiceExtId(int id);
111  int addOperation(const Operation * op);
112  void addOpBinding(int index, int oBn);
113  void addOutputBinding(int index, int opBn);
114  void addInputBinding(int index, int ipBn);
115  void addFaultBinding(int index, int fBn);
116  int getOperationIndex(const Qname & name) const;
117 
119 
120  private:
121  class OperationBinding
122  {
123  public:
124  OperationBinding();
125  const Operation *op;
126  int opBinding[MAX_EXT_ELEM];
127  int nObn;
128  //additional extensibility elements,example soap:operation element
129  int inputBinding[MAX_EXT_ELEM];
130  int nIpbn;
131  int outputBinding[MAX_EXT_ELEM];
132  int nOpbn;
133  int faultBinding[MAX_EXT_ELEM];
134  int nFbn;
135  };
136 
137  std::vector<OperationBinding> Ops_;
138  const PortType *portType_;
139  std::string binding_;//namespace of the binding protocol(SOAP,HTTP etc)
140  int bindingInfo; //binding information for the whole port type
141  //this is the id of the element whichgives details about service for this binding
142  std::list<int> serviceExtIds_;
143 };
144 
145 inline
146 Binding::OperationBinding::OperationBinding()
147  :op(0),
148  nObn(0),
149  nIpbn (0),
150  nOpbn(0),
151  nFbn(0)
152 {
153 }
154 
155 inline
156 int
157 Binding::getBindingInfo() const
158 {
159  return bindingInfo;
160 }
161 
162 inline
163 const PortType *
164 Binding::getPortType() const
165 {
166  return portType_;
167 }
168 
169 inline
170 int
171 Binding::getServiceExtId() const
172 {
173  if (serviceExtIds_.size() > 0)
174  return serviceExtIds_.front();
175  else
176  return 0;
177 }
178 
179 inline
180 int
181 Binding::numOps(void) const
182 {
183  return Ops_.size();
184 }
185 
186 inline
187 const Operation *
188 Binding::getOperation(int index) const
189 {
190  return Ops_[index].op;
191 }
192 
193 inline
194 int
195 Binding::getOpBinding(int index, const int*& bindings) const
196 {
197  bindings = Ops_[index].opBinding;
198  return Ops_[index].nObn;
199 }
200 
201 inline
202 int
203 Binding::getOutputBinding(int index, const int*& bindings) const
204 {
205  bindings = Ops_[index].outputBinding;
206  return Ops_[index].nOpbn;
207 }
208 
209 inline
210 int
211 Binding::getInputBinding(int index, const int*& bindings) const
212 {
213  bindings = Ops_[index].inputBinding;
214  return Ops_[index].nIpbn;
215 }
216 
217 inline
218 int
219 Binding::getFaultBinding(int index, const int*& bindings) const
220 {
221  bindings = Ops_[index].faultBinding;
222  return Ops_[index].nFbn;
223 }
224 
225 inline
226 void
227 Binding::setPortType(const PortType * pt)
228 {
229  portType_ = pt;
230 }
231 
232 inline
233 void
234 Binding:: setBindingInfo(int id)
235 {
236  bindingInfo = id;
237  WsdlElement::addExtElement(id);
238 }
239 
240 inline
241 void
242 Binding::addServiceExtId(int id)
243 {
244  serviceExtIds_.push_back(id);
245 }
246 
247 inline
248 int
249 Binding::addOperation(const Operation * op)
250 {
251  OperationBinding ob;
252  ob.op=op;
253  Ops_.push_back(ob);
254  return Ops_.size()-1;
255 }
256 
257 inline
258 void
259 Binding::addOpBinding(int index, int oBn)
260 {
261  Ops_[index].opBinding[Ops_[index].nObn++] = oBn;
262 }
263 
264 inline
265 void
266 Binding::addOutputBinding(int index, int opBn)
267 {
268  Ops_[index].outputBinding[Ops_[index].nOpbn++] = opBn;
269 }
270 inline
271 void
272 Binding::addInputBinding(int index, int ipBn)
273 {
274  Ops_[index].inputBinding[Ops_[index].nIpbn++] = ipBn;
275 }
276 
277 inline
278 void
279 Binding::addFaultBinding(int index, int fBn)
280 {
281  Ops_[index].faultBinding[Ops_[index].nFbn++] = fBn;
282 }
283 
284 
285 inline
286 Binding::Binding(WsdlParser& w)
287  :WsdlElement(w)
288 {
289  portType_ = 0;
290  Ops_.clear();
291 }
292 
293 inline
294 Binding::~Binding()
295 {
296 }
297 
298 inline
299 void
300 Binding::setBindingMethod(const std::string & ns)
301 {
302  binding_=ns;
303 }
304 
305 inline
306 std::string
307 Binding::getBindingMethod()const
308 {
309  return binding_;
310 }
311 
312 inline int
313 Binding::getOperationIndex(const Qname & name) const
314 {
315  for (int i=0; i < int(Ops_.size()); i++ ) {
316  if (Ops_[i].op->getName() == name.getLocalName() ) return i;
317  }
318  return -1;
319 }
320 
321 
322 }
323 #endif /* */
Definition: Qname.h:30
std::string getLocalName(void) const
Definition: Qname.h:76
#define WSDLPULL_EXPORT