src/wsdlparser/Binding.h

00001 /* 
00002  * wsdlpull - A C++ parser  for WSDL  (Web services description language)
00003  * Copyright (C) 2005-2007 Vivek Krishna
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  *
00020  */
00021 #ifndef _BINDINGH
00022 #define  _BINDINGH
00023 
00024 #include "wsdlparser/WsdlElement.h"
00025 #include "xmlpull/wsdlpull_export.h"
00026 
00027 namespace WsdlPull {
00028 class PortType;
00029 const int MAX_EXT_ELEM=10;
00030 
00031 //Wsdl Binding element
00032 class WSDLPULL_EXPORT Binding:public WsdlElement
00033 {
00034 
00035   /**
00036    * The default constructor for Wsdl Binding
00037    */
00038  public:
00039   typedef std::list<Binding*>::iterator BindingIterator;
00040   typedef std::list<Binding*>::const_iterator cBindingIterator;
00041 
00042   Binding(WsdlParser & w);
00043   ~Binding();
00044   
00045   /** @name Various Getter methods*/
00046   //@{
00047   /**
00048    * getBindingInfo
00049    * @return the extensibility element id of the  main binding extension element.
00050    *         In case of soap it would  be the id of the soap:binding element
00051    */
00052   int getBindingInfo() const;
00053   /**
00054    * getPortType
00055    * @return the wsdl port type associated with this binding
00056    */
00057   const PortType *getPortType() const;
00058   /**
00059    * getServiceExtId
00060    * @return the id of the service element assocaited with this binding
00061    */
00062   int getServiceExtId() const;
00063 
00064   /**
00065    * numOps
00066    * @return number of operations in this binding
00067    */
00068   int numOps(void) const;
00069 
00070   /**
00071    * getOperation
00072    * @param the index of the operation (index ranges from 0 to Ops_.size()-1)
00073    * @return pointer to the  operation
00074    */
00075   const Operation *getOperation(int index) const;
00076   /**
00077    * getBindingMethod
00078    * @param void
00079    * @return The namespace of the binding protocol 
00080    *         example "http://schemas.xmlsoap.org/wsdl/soap/"
00081    */
00082   std::string getBindingMethod()const;
00083 
00084 
00085   /**
00086    * getBinding
00087    * @return The number of binding extensibility elements assocated with each
00088    *         message of the operation whose index is given
00089    *         returns a pointer to a list of extensibility binding ids
00090    */
00091   int getOpBinding(int index, const int*& bindings) const;
00092   int getOutputBinding(int index, const int*& bindings) const;
00093   int getInputBinding(int index, const int*& bindings) const;
00094   int getFaultBinding(int index, const int*& bindings) const;
00095   //@}
00096   ///** @name Various Setter methods*//
00097   ///@{
00098 
00099   /**
00100    *Their descriptions are similar to the corresponding getter methods
00101    */
00102 
00103   void setPortType(const PortType * pt);
00104   void setBindingInfo(int id);
00105   void setBindingMethod(const std::string & ns);
00106   void addServiceExtId(int id);
00107   /**
00108    * Add an operation to the binding .The index returned is to be used
00109    * to add more bindings to the operation
00110    */
00111   int  addOperation(const Operation * op);
00112   void addOpBinding(int index, int oBn);
00113   void addOutputBinding(int index, int opBn);
00114   void addInputBinding(int index, int ipBn);
00115   void addFaultBinding(int index, int fBn);
00116 
00117   //@}
00118 
00119  private:
00120   class OperationBinding
00121     {
00122     public:
00123       OperationBinding();
00124       const Operation *op;
00125       int opBinding[MAX_EXT_ELEM];
00126       int nObn;                           
00127       //additional extensibility elements,example soap:operation element
00128       int inputBinding[MAX_EXT_ELEM];
00129       int nIpbn;
00130       int outputBinding[MAX_EXT_ELEM];
00131       int nOpbn;
00132       int faultBinding[MAX_EXT_ELEM];
00133       int nFbn;
00134     };
00135 
00136   std::vector<OperationBinding> Ops_;
00137   const PortType *portType_;
00138   std::string binding_;//namespace of the binding protocol(SOAP,HTTP etc)
00139   int bindingInfo;  //binding information for the whole port type 
00140   //this is the id of the element whichgives details about service for this binding
00141   std::list<int> serviceExtIds_;                       
00142 };
00143 
00144 inline
00145 Binding::OperationBinding::OperationBinding()
00146   :op(0),
00147      nObn(0),
00148      nIpbn (0),
00149      nOpbn(0),
00150      nFbn(0)
00151 {
00152 }
00153 
00154 inline
00155 int
00156 Binding::getBindingInfo() const
00157 {
00158   return bindingInfo;
00159 }
00160 
00161 inline
00162 const PortType *
00163 Binding::getPortType() const
00164 {
00165   return portType_;
00166 }
00167 
00168 inline
00169 int 
00170 Binding::getServiceExtId() const
00171 {
00172   if (serviceExtIds_.size() > 0)
00173     return serviceExtIds_.front();
00174   else 
00175     return 0;
00176 }
00177 
00178 inline
00179 int
00180 Binding::numOps(void) const
00181 {
00182   return Ops_.size();
00183 }
00184 
00185 inline
00186 const Operation *
00187 Binding::getOperation(int index) const
00188 {
00189   return Ops_[index].op;
00190 }
00191 
00192 inline
00193 int
00194 Binding::getOpBinding(int index, const int*& bindings) const
00195 {
00196   bindings = Ops_[index].opBinding;
00197   return Ops_[index].nObn;
00198 }
00199 
00200 inline
00201 int
00202 Binding::getOutputBinding(int index, const int*& bindings) const
00203 {
00204   bindings = Ops_[index].outputBinding;
00205   return Ops_[index].nOpbn;
00206 }
00207 
00208 inline
00209 int
00210 Binding::getInputBinding(int index, const int*& bindings) const
00211 {
00212   bindings = Ops_[index].inputBinding;
00213   return Ops_[index].nIpbn;
00214 }
00215 
00216 inline
00217 int
00218 Binding::getFaultBinding(int index, const int*& bindings) const
00219 {
00220   bindings = Ops_[index].faultBinding;
00221   return Ops_[index].nFbn;
00222 }
00223 
00224 inline
00225 void 
00226 Binding::setPortType(const PortType * pt)
00227 {
00228   portType_ = pt;
00229 }
00230 
00231 inline
00232 void
00233 Binding:: setBindingInfo(int id)
00234 {
00235   bindingInfo = id;
00236   WsdlElement::addExtElement(id);
00237 }
00238 
00239 inline
00240 void 
00241 Binding::addServiceExtId(int id)
00242 {
00243   serviceExtIds_.push_back(id);
00244 }
00245 
00246 inline
00247 int
00248 Binding::addOperation(const Operation * op)
00249 {
00250   OperationBinding ob;
00251   ob.op=op;
00252   Ops_.push_back(ob);
00253   return Ops_.size()-1;
00254 }
00255 
00256 inline
00257 void
00258 Binding::addOpBinding(int index, int oBn)
00259 {
00260   Ops_[index].opBinding[Ops_[index].nObn++] = oBn;
00261 }
00262 
00263 inline
00264 void
00265 Binding::addOutputBinding(int index, int opBn)
00266 {
00267   Ops_[index].outputBinding[Ops_[index].nOpbn++] = opBn;
00268 }
00269 inline
00270 void
00271 Binding::addInputBinding(int index, int ipBn)
00272 {
00273   Ops_[index].inputBinding[Ops_[index].nIpbn++] = ipBn;
00274 }
00275 
00276 inline
00277 void
00278 Binding::addFaultBinding(int index, int fBn)
00279 {
00280   Ops_[index].faultBinding[Ops_[index].nFbn++] = fBn;
00281 }
00282 
00283 
00284 inline
00285 Binding::Binding(WsdlParser& w)
00286   :WsdlElement(w)
00287 {
00288   portType_ = 0;
00289   Ops_.clear();
00290 }
00291 
00292 inline
00293 Binding::~Binding()
00294 {
00295 };
00296 
00297 inline
00298 void
00299 Binding::setBindingMethod(const std::string & ns)
00300 {
00301   binding_=ns;
00302 }
00303 
00304 inline
00305 std::string
00306 Binding::getBindingMethod()const
00307 {
00308   return binding_;
00309 }
00310 }
00311 #endif                                            /*  */

Generated on Sat May 3 16:29:00 2008 for wsdlpull by  doxygen 1.4.6