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 #include <wsdlparser/Wsdl.h>
00026 #include <wsdlparser/WsdlException.h>
00027 #include <wsdlparser/WsdlElement.h>
00028 #include <wsdlparser/Message.h>
00029 
00030 class PortType;
00031 using namespace Wsdl;
00032 //class for Wsdl operation element
00033 class Operation:public WsdlElement
00034 {
00035  public:
00036   typedef std::vector<Operation*>::iterator OpIterator;
00037   typedef std::vector<Operation*>::const_iterator cOpIterator;
00038 
00039   Operation(WsdlParser& w,PortType * pt);
00040   ~Operation();
00043 
00049   const Message *getMessage(Wsdl::MessageType type) const;
00054   Optype getType() const;
00055   
00060   const PortType* portType()const;
00061 
00063   void setMessage(const Message * message, Wsdl::MessageType type);
00065   void print(ostream & out);
00066 
00067  private:
00068   const Message *inMessage_, *outMessage_, *faultMessage_;
00069   Optype type_;
00070   PortType * pt_;
00071 };
00072 
00073 
00074 
00075 inline
00076 Operation::Operation(WsdlParser& w,PortType * p)
00077   :WsdlElement(w),
00078      pt_(p)
00079 {
00080   type_ = NONE;
00081   inMessage_ = outMessage_ = faultMessage_ = 0;
00082 }
00083 
00084 inline
00085 Operation::~Operation()
00086 {
00087 }
00088 
00089 inline
00090 const PortType* 
00091 Operation::portType()const
00092 {
00093   return pt_;
00094 }
00095 
00096 inline
00097 const Message *
00098 Operation::getMessage(Wsdl::MessageType type) const     
00099 {
00100   if (type == Input)
00101     return inMessage_;
00102 
00103   else if (type == Output)
00104     return outMessage_;
00105 
00106   else if (type == Fault)
00107     return faultMessage_;
00108 
00109   else
00110     return 0;
00111 }
00112 
00113 inline  
00114 Optype
00115 Operation::getType() const                        
00116 {
00117   return type_;
00118 }
00119 
00120 
00121 inline
00122 void 
00123 Operation::setMessage(const Message * message,
00124                       Wsdl::MessageType type)
00125 {
00126   if (message == 0)
00127     throw WsdlException("Invalid message name");
00128   if (type == Input)
00129     {
00130       inMessage_ = message;
00131       if (type_ == NONE)
00132         type_ = IN;
00133 
00134       else if (type_ == OUT)
00135         type_ = OUT_IN;
00136 
00137       else
00138         type_ = NONE;
00139     }
00140   else if (type == Output)
00141     {
00142       outMessage_ = message;
00143       if (type_ == NONE)
00144         type_ = OUT;
00145 
00146       else if (type_ == IN)
00147         type_ = IN_OUT;
00148 
00149       else
00150         type_ = NONE;
00151     } else if (type == Fault)
00152       faultMessage_ = message;
00153 }
00154 
00155 inline
00156 void 
00157 Operation::print(ostream & out)
00158 {
00159   out << id_ << XmlUtils::dbsp << name_ << endl;
00160   out << type_ << endl;
00161   out << inMessage_ << XmlUtils::dbsp << outMessage_ << XmlUtils::dbsp <<
00162     faultMessage_ << endl;
00163   out << XmlUtils::blk;
00164 }
00165 #endif                                            /*  */

Generated on Sun Oct 16 10:11:52 2005 for wsdlpull by  doxygen 1.3.9.1