Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Operation.h

Go to the documentation of this file.
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 _OPERATIONH
00022 #define  _OPERATIONH
00023 
00024 #include "xmlpull/Qname.h"
00025 
00026 #include "wsdlparser/WsdlException.h"
00027 #include "wsdlparser/WsdlElement.h"
00028 #include "wsdlparser/Message.h"
00029 #include "xmlpull/wsdlpull_export.h"
00030 
00031 
00032 namespace WsdlPull {
00033 
00034 enum Optype{
00035   OP_NONE,
00036   OP_IN ,
00037   OP_OUT,
00038   OP_IN_OUT,
00039   OP_OUT_IN
00040 };
00041  
00042 enum MessageType{
00043 
00044   Input,
00045   Output,
00046   Fault
00047 };
00048 
00049 typedef std::list<const Message*> MessageList;
00050 class PortType;
00051 //class for Wsdl operation element
00052 class WSDLPULL_EXPORT Operation:public WsdlElement
00053 {
00054  public:
00055   typedef std::vector<Operation*>::iterator OpIterator;
00056   typedef std::vector<Operation*>::const_iterator cOpIterator;
00057 
00058   Operation(WsdlParser& w,PortType * pt);
00059   ~Operation();
00062 
00068   const Message *getMessage(WsdlPull::MessageType type) const;
00069   std::list<const Message*>* getFaults()const;
00070   const Message* getFault(const std::string& name)const;
00075   Optype getType() const;
00076   
00081   const PortType* portType()const;
00082 
00084   void setMessage(const Message * message, WsdlPull::MessageType type);
00086   void print(std::ostream & out);
00087 
00088  private:
00089   PortType * pt_;
00090   Optype type_;
00091   const Message *inMessage_, *outMessage_;
00092   std::list<const Message*> *faultMessages_;
00093 };
00094 
00095 
00096 
00097 inline
00098 Operation::Operation(WsdlParser& w,PortType * p)
00099   :WsdlElement(w),
00100      pt_(p),
00101      type_(OP_NONE),
00102      inMessage_(0),
00103      outMessage_(0),
00104      faultMessages_(0)
00105 {
00106 }
00107 
00108 inline
00109 Operation::~Operation()
00110 {
00111   
00112   delete faultMessages_;
00113 }
00114 
00115 inline
00116 const PortType* 
00117 Operation::portType()const
00118 {
00119   return pt_;
00120 }
00121 
00122 inline
00123 const Message *
00124 Operation::getMessage(WsdlPull::MessageType type) const     
00125 {
00126   if (type == Input)
00127     return inMessage_;
00128 
00129   else if (type == Output)
00130     return outMessage_;
00131 
00132   else if (type == Fault && faultMessages_)
00133     return faultMessages_->front();
00134 
00135   else
00136     return 0;
00137 }
00138 
00139 inline  
00140 Optype
00141 Operation::getType() const                        
00142 {
00143   return type_;
00144 }
00145 
00146 
00147 inline
00148 void 
00149 Operation::setMessage(const Message * message,
00150                       WsdlPull::MessageType type)
00151 {
00152   if (message == 0)
00153     throw WsdlException("Invalid message name");
00154   if (type == Input) {
00155 
00156     inMessage_ = message;
00157     if (type_ == OP_NONE)
00158       type_ = OP_IN;
00159 
00160     else if (type_ == OP_OUT)
00161       type_ = OP_OUT_IN;
00162 
00163     else
00164       type_ = OP_NONE;
00165   }
00166   else if (type == Output){
00167     
00168     outMessage_ = message;
00169     if (type_ == OP_NONE)
00170       type_ = OP_OUT;
00171 
00172     else if (type_ == OP_IN)
00173       type_ = OP_IN_OUT;
00174 
00175     else
00176       type_ = OP_NONE;
00177   } 
00178   else if (type == Fault) {
00179       
00180     if (!faultMessages_)
00181       faultMessages_ = new std::list<const Message*>();
00182     
00183     faultMessages_->push_back(message);
00184   }
00185 }
00186 
00187 inline
00188 void 
00189 Operation::print(std::ostream & out)
00190 {
00191   out << id_ << XmlUtils::dbsp << name_ << std::endl;
00192   out << type_ << std::endl;
00193   out << inMessage_ << XmlUtils::dbsp << outMessage_ << XmlUtils::dbsp <<std::endl;
00194   out << XmlUtils::blk;
00195 }
00196 
00197 inline
00198 std::list<const Message*>*
00199 Operation::getFaults()const
00200 {
00201 
00202   return faultMessages_;
00203 }
00204 inline
00205 const Message* 
00206 Operation::getFault(const std::string& name)const
00207 {
00208   for ( std::list<const Message*>::iterator mli = faultMessages_->begin();
00209         mli != faultMessages_->end();
00210         mli++) {
00211 
00212     if ((*mli)->getName() == name)
00213       return (*mli);
00214   }
00215   return 0;
00216 }
00217 }
00218 
00219 #endif                                            /*  */

Generated on Wed Apr 12 18:51:55 2006 for wsdlpull by  doxygen 1.3.9.1