wsdlpull 1.23
|
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 00022 #ifndef _SERVICEH 00023 #define _SERVICEH 00024 00025 #include "wsdlparser/WsdlElement.h" 00026 #include "xmlpull/wsdlpull_export.h" 00027 00028 namespace WsdlPull { 00029 class Binding; 00030 00031 class WSDLPULL_EXPORT Service :public WsdlElement { 00032 public: 00033 typedef struct { 00034 std::string name_; 00035 const Binding* binding_; 00036 int serviceExtId_; 00037 }ServicePort; 00038 typedef std::list<ServicePort>::const_iterator cServicePortIterator; 00039 00040 public: 00041 Service(WsdlParser & w); 00042 00045 00046 void addPort(const std::string& name,const Binding* bn,int serviceExtId); 00047 00048 int getPortExtension(const std::string& name)const; 00049 const Binding* getPortBinding(const std::string& name)const; 00050 void getPortBindings(cServicePortIterator &from, cServicePortIterator &to)const; 00051 std::list<std::string> getPorts()const; 00053 private: 00054 00055 std::list<ServicePort> ports_; 00056 }; 00057 00058 00059 inline 00060 Service::Service(WsdlParser& w) 00061 :WsdlElement(w) 00062 { 00063 } 00064 inline 00065 void 00066 Service::addPort(const std::string& n,const Binding* bn,int serviceExtId) 00067 { 00068 ServicePort sp; 00069 sp.name_=n; 00070 sp.binding_ = bn; 00071 sp.serviceExtId_ = serviceExtId; 00072 ports_.push_back(sp); 00073 } 00074 00075 inline 00076 int 00077 Service::getPortExtension(const std::string & name)const 00078 { 00079 for(std::list<ServicePort>::const_iterator it = ports_.begin(); 00080 it != ports_.end(); 00081 it++){ 00082 if(it->name_ == name) 00083 return it->serviceExtId_; 00084 } 00085 return 0; 00086 } 00087 00088 inline 00089 const Binding* 00090 Service::getPortBinding(const std::string & name)const 00091 { 00092 for(std::list<ServicePort>::const_iterator it = ports_.begin(); 00093 it != ports_.end(); 00094 it++){ 00095 if(it->name_ == name) 00096 return it->binding_; 00097 } 00098 return 0; 00099 } 00100 00101 inline 00102 void 00103 Service::getPortBindings(cServicePortIterator &from, 00104 cServicePortIterator &to)const 00105 { 00106 if (ports_.size()> 0) 00107 { 00108 from = ports_.begin(); 00109 to = ports_.end(); 00110 } 00111 } 00112 00113 inline 00114 std::list<std::string> 00115 Service::getPorts()const 00116 { 00117 std::list<std::string> names; 00118 for(std::list<ServicePort>::const_iterator it = ports_.begin(); 00119 it != ports_.end(); 00120 it++){ 00121 names.push_back(it->name_); 00122 } 00123 return names; 00124 } 00125 } 00126 #endif 00127