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 _PORTTYPEH 00022 #define _PORTTYPEH 00023 00024 #include "wsdlparser/Operation.h" 00025 #include "wsdlparser/Binding.h" 00026 #include "xmlpull/wsdlpull_export.h" 00027 00028 namespace WsdlPull { 00029 //This class implements a port type of WSDL . 00030 class WSDLPULL_EXPORT PortType:public WsdlElement 00031 { 00032 public: 00033 typedef std::list<PortType*>::iterator PortTypeIterator; 00034 typedef std::list<PortType*>::const_iterator cPortTypeIterator; 00035 00036 PortType(WsdlParser& w); 00037 ~PortType(); 00040 00041 int getNumOps(void) const; 00042 00048 const Operation *getOperation(int index) const; 00049 00055 const Operation *getOperation(const Qname & name) const; 00056 int getOperationIndex(const Qname & name) const; 00057 00063 bool getOperations(Operation::cOpIterator & start ,Operation::cOpIterator & finish)const; 00064 00072 const Binding* binding(const std::string & nsp)const; 00073 00075 00078 void addOp(Operation * op); 00079 void setBinding(Binding* bn); 00081 private: 00082 std::vector<Operation *> ops_; 00083 std::vector<const Binding *> bindings_; 00084 }; 00085 00086 inline 00087 PortType::PortType(WsdlParser& w) 00088 :WsdlElement(w) 00089 { 00090 ops_.clear() ; 00091 } 00092 inline 00093 PortType::~PortType() 00094 { 00095 for (size_t i = 0; i < ops_.size(); i++) 00096 delete ops_[i]; 00097 00098 } 00099 00100 inline 00101 int 00102 PortType::getNumOps(void) const 00103 { 00104 return ops_.size(); 00105 } 00106 00107 inline 00108 const Operation * 00109 PortType::getOperation(int index) const 00110 { 00111 return ops_[index]; 00112 } 00113 00114 inline 00115 int 00116 PortType::getOperationIndex(const Qname & name) const 00117 { 00118 for (size_t i = 0; i < ops_.size(); i++) 00119 { 00120 if (ops_[i]->getName() == name.getLocalName()) 00121 return i; 00122 } 00123 return 0; 00124 } 00125 00126 inline 00127 const Operation * 00128 PortType::getOperation(const Qname & name) const 00129 { 00130 for (size_t i = 0; i < ops_.size(); i++) 00131 { 00132 if (ops_[i]->getName() == name.getLocalName()) 00133 return ops_[i]; 00134 } 00135 return 0; 00136 } 00137 00138 inline 00139 bool 00140 PortType::getOperations(Operation::cOpIterator & start , 00141 Operation::cOpIterator & finish)const 00142 { 00143 start=ops_.begin(); 00144 finish=ops_.end(); 00145 return true; 00146 } 00147 00148 00149 inline 00150 void 00151 PortType::addOp(Operation * op) 00152 { 00153 ops_.push_back(op); 00154 } 00155 00156 inline 00157 void 00158 PortType::setBinding(Binding* bn) 00159 { 00160 bindings_.push_back(bn); 00161 } 00162 00163 inline 00164 const Binding* 00165 PortType::binding(const std::string & nsp)const 00166 { 00167 for (unsigned int i = 0; i<bindings_.size();i++){ 00168 if (bindings_[i]->getBindingMethod() == nsp) 00169 return bindings_[i]; 00170 } 00171 return 0; 00172 } 00173 } 00174 #endif /* */