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;
00074   Optype getType() const;
00075   
00080   const PortType* portType()const;
00081 
00083   void setMessage(const Message * message, WsdlPull::MessageType type);
00085   void print(std::ostream & out);
00086 
00087  private:
00088   PortType * pt_;
00089   Optype type_;
00090   const Message *inMessage_, *outMessage_;
00091   std::list<const Message*> *faultMessages_;
00092 };
00093 
00094 
00095 
00096 inline
00097 Operation::Operation(WsdlParser& w,PortType * p)
00098   :WsdlElement(w),
00099      pt_(p),
00100      type_(OP_NONE),
00101      inMessage_(0),
00102      outMessage_(0),
00103      faultMessages_(0)
00104 {
00105 }
00106 
00107 inline
00108 Operation::~Operation()
00109 {
00110   
00111   delete faultMessages_;
00112 }
00113 
00114 inline
00115 const PortType* 
00116 Operation::portType()const
00117 {
00118   return pt_;
00119 }
00120 
00121 inline
00122 const Message *
00123 Operation::getMessage(WsdlPull::MessageType type) const     
00124 {
00125   if (type == Input)
00126     return inMessage_;
00127 
00128   else if (type == Output)
00129     return outMessage_;
00130 
00131   else if (type == Fault && faultMessages_)
00132     return faultMessages_->front();
00133 
00134   else
00135     return 0;
00136 }
00137 
00138 inline  
00139 Optype
00140 Operation::getType() const                        
00141 {
00142   return type_;
00143 }
00144 
00145 
00146 inline
00147 void 
00148 Operation::setMessage(const Message * message,
00149                       WsdlPull::MessageType type)
00150 {
00151   if (message == 0)
00152     throw WsdlException("Invalid message name");
00153   if (type == Input) {
00154 
00155     inMessage_ = message;
00156     if (type_ == OP_NONE)
00157       type_ = OP_IN;
00158 
00159     else if (type_ == OP_OUT)
00160       type_ = OP_OUT_IN;
00161 
00162     else
00163       type_ = OP_NONE;
00164   }
00165   else if (type == Output){
00166     
00167     outMessage_ = message;
00168     if (type_ == OP_NONE)
00169       type_ = OP_OUT;
00170 
00171     else if (type_ == OP_IN)
00172       type_ = OP_IN_OUT;
00173 
00174     else
00175       type_ = OP_NONE;
00176   } 
00177   else if (type == Fault) {
00178       
00179     if (!faultMessages_)
00180       faultMessages_ = new std::list<const Message*>();
00181     
00182     faultMessages_->push_back(message);
00183   }
00184 }
00185 
00186 inline
00187 void 
00188 Operation::print(std::ostream & out)
00189 {
00190   out << id_ << XmlUtils::dbsp << name_ << std::endl;
00191   out << type_ << std::endl;
00192   out << inMessage_ << XmlUtils::dbsp << outMessage_ << XmlUtils::dbsp <<std::endl;
00193   out << XmlUtils::blk;
00194 }
00195 
00196 inline
00197 std::list<const Message*>*
00198 Operation::getFaults()const
00199 {
00200 
00201   return faultMessages_;
00202 }
00203 
00204 }
00205 
00206 #endif                                            /*  */

Generated on Sun Apr 2 18:12:00 2006 for wsdlpull by  doxygen 1.3.9.1