it_bus/binary_nillable_type.h

00001 #ifndef _IT_BUS_BINARY_NILLABLE_TYPE_H_
00002 #define _IT_BUS_BINARY_NILLABLE_TYPE_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/api_defines.h>
00008 #include <it_bus/nillable.h>
00009 #include <it_bus/binary_buffer_nillable.h>
00010 #include <it_bus/binary_type.h>
00011 #include <it_bus/qname.h>
00012 #include <it_bus/complex_type_writer.h>
00013 #include <it_bus/complex_type_reader.h>
00014 #include <it_schema_model/w3c_constants.h>
00015 
00016 namespace IT_Bus
00017 {
00018     template <const QName* TYPE>
00019     class BinaryOutParamNillable: public Nillable
00020     {
00021       public:
00022         BinaryOutParamNillable(
00023             const BinaryOutParamNillable& other
00024         );
00025 
00026         BinaryOutParamNillable(
00027             IT_Bus::BinaryBufferNillable& other
00028         );
00029 
00030         virtual ~BinaryOutParamNillable();
00031 
00032         BinaryOutParamNillable&
00033         operator=(
00034             const BinaryOutParamNillable& other
00035         );
00036 
00037         AnyType&
00038         copy(
00039             const AnyType& other
00040         );
00041 
00042         virtual const QName&
00043         get_type() const;
00044 
00045         virtual Boolean
00046         is_nil() const;
00047 
00048         virtual void
00049         set_nil();
00050         
00051         virtual void 
00052         write_value(
00053             const QName& name,
00054             ComplexTypeWriter& writer
00055         ) const throw((SerializationException));
00056 
00057         virtual void
00058         read_value(
00059             const QName& name,
00060             ComplexTypeReader& reader
00061         ) throw((DeserializationException));
00062 
00067         virtual const IT_Bus::BinaryBufferNillable&
00068         get() const throw((NoDataException));
00069         
00074         virtual IT_Bus::BinaryBufferNillable&
00075         get() throw((NoDataException));
00076         
00080         virtual void
00081         set(
00082             const IT_Bus::BinaryBufferNillable& data
00083         );
00084 
00088         virtual void
00089         reset();
00090 
00091       private:
00092 
00093         typedef BinaryOutParamNillable ThisType; // needed for DYNAMIC_CAST macro
00094         IT_Bus::BinaryBufferNillable&      m_data;
00095     };
00096 
00097 
00098     template <const QName* TYPE>
00099     class BinaryInParamNillable: public Nillable
00100     {
00101       public:
00102         BinaryInParamNillable(
00103             const BinaryInParamNillable& other
00104         );
00105 
00106         BinaryInParamNillable(
00107             const IT_Bus::BinaryBufferNillable& other
00108         );
00109 
00110         virtual ~BinaryInParamNillable();
00111 
00112         BinaryInParamNillable&
00113         operator=(
00114             const BinaryInParamNillable& other
00115         );
00116 
00117         AnyType&
00118         copy(
00119             const AnyType& other
00120         );
00121 
00122         virtual const QName&
00123         get_type() const;
00124 
00125         virtual Boolean
00126         is_nil() const;
00127 
00128         virtual void 
00129         write_value(
00130             const QName& name,
00131             ComplexTypeWriter& writer
00132         ) const throw((SerializationException));
00133 
00134         virtual void
00135         read_value(
00136             const QName& name,
00137             ComplexTypeReader& reader
00138         ) throw((DeserializationException));
00139 
00144         virtual const IT_Bus::BinaryBufferNillable&
00145         get() const throw((NoDataException));
00146         
00147    
00148       private:
00149         typedef BinaryInParamNillable ThisType; // needed for DYNAMIC_CAST macro
00150         const IT_Bus::BinaryBufferNillable&      m_data;
00151     };
00152 
00153 
00154     template <const QName* TYPE>
00155     BinaryOutParamNillable<TYPE>::BinaryOutParamNillable(
00156         const BinaryOutParamNillable& other
00157     ) 
00158         :m_data(other.m_data)
00159     {
00160         // Complete.
00161     }
00162 
00163     template <const QName* TYPE>
00164     BinaryOutParamNillable<TYPE>::BinaryOutParamNillable(
00165          IT_Bus::BinaryBufferNillable& data
00166     ) 
00167         :m_data(data)
00168     {
00169         // Complete.
00170     }
00171 
00172     template <const QName* TYPE>
00173     BinaryOutParamNillable<TYPE>::~BinaryOutParamNillable()
00174     {
00175         // Complete.
00176     }
00177 
00178     template <const QName* TYPE>
00179     BinaryOutParamNillable<TYPE>&
00180     BinaryOutParamNillable<TYPE>::operator=(
00181         const BinaryOutParamNillable<TYPE>& other
00182     ) 
00183     {
00184         if (other.is_nil())
00185         {
00186             reset();
00187         }
00188         else
00189         {
00190             set(other.get());
00191         }
00192         return *this;
00193     }
00194 
00195     template <const QName* TYPE>
00196     AnyType&
00197     BinaryOutParamNillable<TYPE>::copy(
00198         const AnyType& rhs
00199     ) 
00200     {
00201         const ThisType& other = IT_DYNAMIC_CAST(const ThisType&, rhs);
00202         *this = other;
00203         return *this;
00204     }
00205 
00206     template <const QName* TYPE>
00207     const QName&
00208     BinaryOutParamNillable<TYPE>::get_type() const
00209     {
00210         return *TYPE;
00211     }
00212 
00213     template <const QName* TYPE>
00214     IT_Bus::Boolean
00215     BinaryOutParamNillable<TYPE>::is_nil() const
00216     {
00217         return  m_data.is_nil();
00218     }
00219 
00220     template <const QName* TYPE>
00221     void
00222     BinaryOutParamNillable<TYPE>::set_nil() 
00223     {
00224         m_data.set_nil();
00225     }
00226 
00227     template <const QName* TYPE>
00228     void
00229     BinaryOutParamNillable<TYPE>::write_value(
00230         const QName& element_name,
00231         ComplexTypeWriter& writer
00232     ) const throw((SerializationException)) 
00233     {
00234         if (is_nil())
00235         {
00236             throw SerializationException("Attempt to write nil value");
00237         }
00238         else 
00239         {
00240             if ( *TYPE == IT_W3CConstants::NT_SCHEMA_BASE64 )
00241             {
00242                 Base64BinaryInParam in_param(m_data.get());
00243                 writer.write(element_name, in_param);
00244             }
00245             else
00246             {
00247                 HexBinaryInParam in_param(m_data.get());
00248                 writer.write(element_name, in_param);
00249             }
00250         }
00251 
00252     }
00253 
00254     template <const QName* TYPE>
00255     void
00256     BinaryOutParamNillable<TYPE>::read_value(
00257         const QName& name,
00258         ComplexTypeReader& reader
00259     ) throw((DeserializationException))
00260     {
00261         if ( *TYPE == IT_W3CConstants::NT_SCHEMA_BASE64 )
00262         {
00263             Base64Binary out_param;
00264             reader.read(name, out_param);
00265             m_data.set(out_param);
00266         }
00267         else
00268         {
00269             HexBinary out_param;
00270             reader.read(name, out_param);
00271             m_data.set(out_param);
00272         }
00273     }
00274 
00275     template <const QName* TYPE>
00276     IT_Bus::BinaryBufferNillable&
00277     BinaryOutParamNillable<TYPE>::get() throw((NoDataException))
00278     {
00279         if (is_nil())
00280         {
00281             throw NoDataException("Nillable value has no data");
00282         }
00283         return m_data;
00284     }
00285 
00286     template <const QName* TYPE>
00287     const IT_Bus::BinaryBufferNillable&
00288     BinaryOutParamNillable<TYPE>::get() const throw((NoDataException))
00289     {
00290         if (is_nil())
00291         {
00292             throw NoDataException("Nillable value has no data");
00293         }
00294         return m_data;
00295     }
00296 
00297     template <const QName* TYPE>
00298     void
00299     BinaryOutParamNillable<TYPE>::set(
00300         const IT_Bus::BinaryBufferNillable& data
00301     )
00302     {
00303         m_data = data;
00304     }
00305 
00306     template <const QName* TYPE>
00307     void
00308     BinaryOutParamNillable<TYPE>::reset()
00309     {
00310          m_data.reset();   
00311     }
00312 
00313     template <const QName* TYPE>
00314     BinaryInParamNillable<TYPE>::BinaryInParamNillable(
00315         const BinaryInParamNillable& other
00316     ) 
00317         :m_data(other.m_data)
00318     {
00319         // Complete.
00320     }
00321 
00322     template <const QName* TYPE>
00323     BinaryInParamNillable<TYPE>::BinaryInParamNillable(
00324          const IT_Bus::BinaryBufferNillable& data
00325     ) 
00326         :m_data(data)
00327     {
00328         // Complete.
00329     }
00330 
00331     template <const QName* TYPE>
00332     BinaryInParamNillable<TYPE>::~BinaryInParamNillable()
00333     {
00334         // Complete.
00335     }
00336 
00337     template <const QName* TYPE>
00338     BinaryInParamNillable<TYPE>&
00339     BinaryInParamNillable<TYPE>::operator=(
00340         const BinaryInParamNillable<TYPE>& other
00341     ) 
00342     {
00343         if (other.is_nil())
00344         {
00345             this->reset();
00346         }
00347         else
00348         {
00349             BinaryInParamNillable<TYPE>::set(other.get());
00350         }
00351         return *this;
00352     }
00353 
00354     template <const QName* TYPE>
00355     AnyType&
00356     BinaryInParamNillable<TYPE>::copy(
00357         const AnyType& rhs
00358     ) 
00359     {
00360         const ThisType& other = IT_DYNAMIC_CAST(const ThisType&, rhs);
00361         *this = other;
00362         return *this;
00363     }
00364 
00365     template <const QName* TYPE>
00366     const QName&
00367     BinaryInParamNillable<TYPE>::get_type() const
00368     {
00369         return *TYPE;
00370     }
00371 
00372     template <const QName* TYPE>
00373     IT_Bus::Boolean
00374     BinaryInParamNillable<TYPE>::is_nil() const
00375     {
00376         return  m_data.is_nil();
00377     }
00378 
00379     template <const QName* TYPE>
00380     const IT_Bus::BinaryBufferNillable&
00381     BinaryInParamNillable<TYPE>::get() const throw((NoDataException))
00382     {
00383         if (is_nil())
00384         {
00385             throw NoDataException("Nillable value has no data");
00386         }
00387         return m_data;
00388     }
00389 }
00390 
00391 #endif  

Generated on Tue Mar 20 15:27:41 2007 for Artix by  doxygen 1.5.1-p1