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 
00030 
00031 namespace WsdlPull {
00032 
00033         enum Optype{
00034       OP_NONE,
00035       OP_IN ,
00036       OP_OUT,
00037       OP_IN_OUT,
00038       OP_OUT_IN
00039     };
00040  
00041  enum MessageType{
00042 
00043       Input,
00044       Output,
00045       Fault
00046     };
00047 
00048 class PortType;
00049 //class for Wsdl operation element
00050 class Operation:public WsdlElement
00051 {
00052  public:
00053   typedef std::vector<Operation*>::iterator OpIterator;
00054   typedef std::vector<Operation*>::const_iterator cOpIterator;
00055 
00056   Operation(WsdlParser& w,PortType * pt);
00057   ~Operation();
00060 
00066   const Message *getMessage(WsdlPull::MessageType type) const;
00071   Optype getType() const;
00072   
00077   const PortType* portType()const;
00078 
00080   void setMessage(const Message * message, WsdlPull::MessageType type);
00082   void print(std::ostream & out);
00083 
00084  private:
00085   const Message *inMessage_, *outMessage_, *faultMessage_;
00086   Optype type_;
00087   PortType * pt_;
00088 };
00089 
00090 
00091 
00092 inline
00093 Operation::Operation(WsdlParser& w,PortType * p)
00094   :WsdlElement(w),
00095      pt_(p)
00096 {
00097   type_ = OP_NONE;
00098   inMessage_ = outMessage_ = faultMessage_ = 0;
00099 }
00100 
00101 inline
00102 Operation::~Operation()
00103 {
00104 }
00105 
00106 inline
00107 const PortType* 
00108 Operation::portType()const
00109 {
00110   return pt_;
00111 }
00112 
00113 inline
00114 const Message *
00115 Operation::getMessage(WsdlPull::MessageType type) const     
00116 {
00117   if (type == Input)
00118     return inMessage_;
00119 
00120   else if (type == Output)
00121     return outMessage_;
00122 
00123   else if (type == Fault)
00124     return faultMessage_;
00125 
00126   else
00127     return 0;
00128 }
00129 
00130 inline  
00131 Optype
00132 Operation::getType() const                        
00133 {
00134   return type_;
00135 }
00136 
00137 
00138 inline
00139 void 
00140 Operation::setMessage(const Message * message,
00141                       WsdlPull::MessageType type)
00142 {
00143   if (message == 0)
00144     throw WsdlException("Invalid message name");
00145   if (type == Input)
00146     {
00147       inMessage_ = message;
00148       if (type_ == OP_NONE)
00149         type_ = OP_IN;
00150 
00151       else if (type_ == OP_OUT)
00152         type_ = OP_OUT_IN;
00153 
00154       else
00155         type_ = OP_NONE;
00156     }
00157   else if (type == Output)
00158     {
00159       outMessage_ = message;
00160       if (type_ == OP_NONE)
00161         type_ = OP_OUT;
00162 
00163       else if (type_ == OP_IN)
00164         type_ = OP_IN_OUT;
00165 
00166       else
00167         type_ = OP_NONE;
00168     } else if (type == Fault)
00169       faultMessage_ = message;
00170 }
00171 
00172 inline
00173 void 
00174 Operation::print(std::ostream & out)
00175 {
00176   out << id_ << XmlUtils::dbsp << name_ << std::endl;
00177   out << type_ << std::endl;
00178   out << inMessage_ << XmlUtils::dbsp << outMessage_ << XmlUtils::dbsp <<
00179     faultMessage_ << std::endl;
00180   out << XmlUtils::blk;
00181 }
00182 }
00183 #endif                                            /*  */

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1