TAO::Any_Basic_Impl Class Reference

Non-template class for all the basic types. More...

#include <Any_Basic_Impl.h>

Inheritance diagram for TAO::Any_Basic_Impl:

Inheritance graph
[legend]
Collaboration diagram for TAO::Any_Basic_Impl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Any_Basic_Impl (CORBA::TypeCode_ptr, void *value)
virtual ~Any_Basic_Impl (void)
virtual CORBA::Boolean marshal_value (TAO_OutputCDR &)
CORBA::Boolean demarshal_value (TAO_InputCDR &)
CORBA::Boolean demarshal_value (TAO_InputCDR &, CORBA::Long)
virtual void _tao_decode (TAO_InputCDR &)

Static Public Member Functions

void insert (CORBA::Any &, CORBA::TypeCode_ptr, const void *)
CORBA::Boolean extract (const CORBA::Any &, CORBA::TypeCode_ptr, void *)
Any_Basic_Implcreate_empty (CORBA::TypeCode_ptr)

Static Private Member Functions

void assign_value (void *, Any_Basic_Impl *)
void assign_value (void *, Any_Basic_Impl *, CORBA::Long tck)

Private Attributes

CORBA::Long kind_
union {
   CORBA::Short   s
   CORBA::UShort   us
   CORBA::Long   l
   CORBA::ULong   ul
   CORBA::Float   f
   CORBA::Double   d
   CORBA::Boolean   b
   CORBA::Char   c
   CORBA::Octet   o
   CORBA::LongLong   ll
   CORBA::ULongLong   ull
   CORBA::LongDouble   ld
   CORBA::WChar   wc
u_

Detailed Description

Non-template class for all the basic types.

Definition at line 39 of file Any_Basic_Impl.h.


Constructor & Destructor Documentation

TAO::Any_Basic_Impl::Any_Basic_Impl CORBA::TypeCode_ptr  ,
void *  value
 

Definition at line 21 of file Any_Basic_Impl.cpp.

References kind_.

00023     : Any_Impl (0, tc),
00024       kind_ (CORBA::tk_null)
00025   {
00026     this->kind_ = TAO::unaliased_kind (tc);
00027 
00028     switch (this->kind_)
00029     {
00030       case CORBA::tk_short:
00031         this->u_.s = *static_cast<CORBA::Short *> (value);
00032         break;
00033       case CORBA::tk_ushort:
00034         this->u_.us = *static_cast<CORBA::UShort *> (value);
00035         break;
00036       case CORBA::tk_long:
00037         this->u_.l = *static_cast<CORBA::Long *> (value);
00038         break;
00039       case CORBA::tk_ulong:
00040          this->u_.ul = *static_cast<CORBA::ULong *> (value);
00041         break;
00042       case CORBA::tk_float:
00043         this->u_.f = *static_cast<CORBA::Float *> (value);
00044         break;
00045       case CORBA::tk_double:
00046         this->u_.d = *static_cast<CORBA::Double *> (value);
00047         break;
00048       case CORBA::tk_boolean:
00049         this->u_.b = *static_cast<CORBA::Boolean *> (value);
00050         break;
00051       case CORBA::tk_char:
00052         this->u_.c = *static_cast<CORBA::Char *> (value);
00053         break;
00054       case CORBA::tk_octet:
00055         this->u_.o = *static_cast<CORBA::Octet *> (value);
00056         break;
00057       case CORBA::tk_longlong:
00058         this->u_.ll = *static_cast<CORBA::LongLong *> (value);
00059         break;
00060 #if !defined (ACE_LACKS_LONGLONG_T)
00061       case CORBA::tk_ulonglong:
00062   #if !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00063         this->u_.ull = *static_cast<CORBA::ULongLong *> (value);
00064   #else
00065         this->u_.ull = *static_cast<CORBA::LongLong *> (value);
00066   #endif
00067         break;
00068 #endif
00069       case CORBA::tk_longdouble:
00070         this->u_.ld = *static_cast<CORBA::LongDouble *> (value);
00071         break;
00072       case CORBA::tk_wchar:
00073         this->u_.wc = *static_cast<CORBA::WChar *> (value);
00074         break;
00075       default:
00076         break;
00077     }
00078   }

TAO::Any_Basic_Impl::~Any_Basic_Impl void   )  [virtual]
 

Definition at line 80 of file Any_Basic_Impl.cpp.

00081   {
00082   }


Member Function Documentation

void TAO::Any_Basic_Impl::_tao_decode TAO_InputCDR  )  [virtual]
 

Reimplemented from TAO::Any_Impl.

Definition at line 261 of file Any_Basic_Impl.cpp.

References demarshal_value().

00262   {
00263     if (! this->demarshal_value (cdr))
00264       {
00265         throw ::CORBA::MARSHAL ();
00266       }
00267   }

void TAO::Any_Basic_Impl::assign_value void *  ,
Any_Basic_Impl ,
CORBA::Long  tck
[static, private]
 

Definition at line 319 of file Any_Basic_Impl.cpp.

References u_.

00322   {
00323     CORBA::TCKind const kind = static_cast<CORBA::TCKind> (tck);
00324 
00325     switch (kind)
00326       {
00327       case CORBA::tk_short:
00328         *static_cast<CORBA::Short *> (dest) = src->u_.s;
00329         break;
00330       case CORBA::tk_ushort:
00331         *static_cast<CORBA::UShort *> (dest) = src->u_.us;
00332         break;
00333       case CORBA::tk_long:
00334         *static_cast<CORBA::Long *> (dest) = src->u_.l;
00335         break;
00336       case CORBA::tk_ulong:
00337         *static_cast<CORBA::ULong *> (dest) = src->u_.ul;
00338         break;
00339       case CORBA::tk_float:
00340         *static_cast<CORBA::Float *> (dest) = src->u_.f;
00341         break;
00342       case CORBA::tk_double:
00343         *static_cast<CORBA::Double *> (dest) = src->u_.d;
00344         break;
00345       case CORBA::tk_boolean:
00346         *static_cast<CORBA::Boolean *> (dest) = src->u_.b;
00347         break;
00348       case CORBA::tk_char:
00349         *static_cast<CORBA::Char *> (dest) = src->u_.c;
00350         break;
00351       case CORBA::tk_octet:
00352         *static_cast<CORBA::Octet *> (dest) = src->u_.o;
00353         break;
00354       case CORBA::tk_longlong:
00355         *static_cast<CORBA::LongLong *> (dest) = src->u_.ll;
00356         break;
00357 #if !defined (ACE_LACKS_LONGLONG_T)
00358       case CORBA::tk_ulonglong:
00359   #if !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00360         *static_cast<CORBA::ULongLong *> (dest) = src->u_.ull;
00361         break;
00362   #else
00363         *static_cast<CORBA::LongLong *> (dest) = src->u_.ull;
00364   #endif
00365 #endif
00366       case CORBA::tk_longdouble:
00367         *static_cast<CORBA::LongDouble *> (dest) = src->u_.ld;
00368         break;
00369       case CORBA::tk_wchar:
00370         *static_cast<CORBA::WChar *> (dest) = src->u_.wc;
00371         break;
00372       default:
00373         break;
00374       }
00375   }

void TAO::Any_Basic_Impl::assign_value void *  ,
Any_Basic_Impl
[static, private]
 

Definition at line 311 of file Any_Basic_Impl.cpp.

References kind_.

00312   {
00313     Any_Basic_Impl::assign_value (dest,
00314                                   src,
00315                                   src->kind_);
00316   }

Any_Basic_Impl * TAO::Any_Basic_Impl::create_empty CORBA::TypeCode_ptr   )  [static]
 

Definition at line 270 of file Any_Basic_Impl.cpp.

References ACE_CDR_LONG_DOUBLE_INITIALIZER, ACE_CDR_LONGLONG_INITIALIZER, and ACE_NEW_RETURN.

Referenced by extract().

00271   {
00272     CORBA::TCKind const kind = tc->kind ();
00273 
00274     TAO::Any_Basic_Impl * retval = 0;
00275 
00276     switch (kind)
00277     {
00278       case CORBA::tk_longlong:
00279         {
00280           CORBA::LongLong tmp = ACE_CDR_LONGLONG_INITIALIZER;
00281           ACE_NEW_RETURN (retval,
00282                           TAO::Any_Basic_Impl (tc, &tmp),
00283                           0);
00284         }
00285 
00286         break;
00287       case CORBA::tk_longdouble:
00288         {
00289           CORBA::LongDouble tmp = ACE_CDR_LONG_DOUBLE_INITIALIZER;
00290           ACE_NEW_RETURN (retval,
00291                           TAO::Any_Basic_Impl (tc, &tmp),
00292                           0);
00293         }
00294 
00295         break;
00296       default:
00297         {
00298           CORBA::ULongLong tmp = 0;
00299           ACE_NEW_RETURN (retval,
00300                           TAO::Any_Basic_Impl (tc, &tmp),
00301                           0);
00302         }
00303 
00304         break;
00305     }
00306 
00307     return retval;
00308   }

CORBA::Boolean TAO::Any_Basic_Impl::demarshal_value TAO_InputCDR ,
CORBA::Long 
 

Definition at line 221 of file Any_Basic_Impl.cpp.

References CORBA::Any::to_boolean, CORBA::Any::to_char, CORBA::Any::to_octet, and CORBA::Any::to_wchar.

00223   {
00224     CORBA::TCKind const tckind = static_cast<CORBA::TCKind> (tck);
00225     switch (tckind)
00226     {
00227       case CORBA::tk_short:
00228         return cdr >> this->u_.s;
00229       case CORBA::tk_ushort:
00230         return cdr >> this->u_.us;
00231       case CORBA::tk_long:
00232         return cdr >> this->u_.l;
00233       case CORBA::tk_ulong:
00234         return cdr >> this->u_.ul;
00235       case CORBA::tk_float:
00236         return cdr >> this->u_.f;
00237       case CORBA::tk_double:
00238         return cdr >> this->u_.d;
00239       case CORBA::tk_boolean:
00240         return cdr >> CORBA::Any::to_boolean (this->u_.b);
00241       case CORBA::tk_char:
00242         return cdr >> CORBA::Any::to_char (this->u_.c);
00243       case CORBA::tk_octet:
00244         return cdr >> CORBA::Any::to_octet (this->u_.o);
00245       case CORBA::tk_longlong:
00246         return cdr >> this->u_.ll;
00247 #if !defined (ACE_LACKS_LONGLONG_T)
00248       case CORBA::tk_ulonglong:
00249         return cdr >> this->u_.ull;
00250 #endif
00251       case CORBA::tk_longdouble:
00252         return cdr >> this->u_.ld;
00253       case CORBA::tk_wchar:
00254         return cdr >> CORBA::Any::to_wchar (this->u_.wc);
00255       default:
00256         return 0;
00257     }
00258   }

CORBA::Boolean TAO::Any_Basic_Impl::demarshal_value TAO_InputCDR  ) 
 

Definition at line 214 of file Any_Basic_Impl.cpp.

Referenced by _tao_decode(), and extract().

00215   {
00216     return this->demarshal_value (cdr,
00217                                   this->kind_);
00218   }

CORBA::Boolean TAO::Any_Basic_Impl::extract const CORBA::Any ,
CORBA::TypeCode_ptr  ,
void * 
[static]
 

Definition at line 97 of file Any_Basic_Impl.cpp.

References TAO::Unknown_IDL_Type::_tao_get_cdr(), CORBA::Any::_tao_get_typecode(), create_empty(), demarshal_value(), TAO::Any_Impl::encoded(), CORBA::Any::impl(), and ACE_Auto_Basic_Ptr< X >::release().

Referenced by operator>>=(), and CORBA::Any::operator>>=().

00100   {
00101     try
00102       {
00103         CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
00104         CORBA::Boolean const _tao_equiv =
00105           any_tc->equivalent (tc);
00106 
00107         if (!_tao_equiv)
00108           {
00109             return false;
00110           }
00111 
00112         TAO::Any_Impl * const impl = any.impl ();
00113 
00114         if (impl && !impl->encoded ())
00115           {
00116             TAO::Any_Basic_Impl * const narrow_impl =
00117               dynamic_cast<TAO::Any_Basic_Impl *> (impl);
00118 
00119             if (narrow_impl == 0)
00120               {
00121                 return false;
00122               }
00123 
00124             Any_Basic_Impl::assign_value (_tao_elem, narrow_impl);
00125             return true;
00126           }
00127 
00128         TAO::Any_Basic_Impl *replacement =
00129           TAO::Any_Basic_Impl::create_empty (any_tc);
00130 
00131         auto_ptr<TAO::Any_Basic_Impl> replacement_safety (replacement);
00132 
00133         // We know this will work since the unencoded case is covered above.
00134         TAO::Unknown_IDL_Type * const unk =
00135           dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
00136 
00137         if (!unk)
00138           return false;
00139 
00140         // Get the kind of the type where we are extracting in ie. the
00141         // aliased  type if there are any. Passing the aliased kind
00142         // will not help.
00143         CORBA::TCKind const tck = tc->kind ();
00144 
00145         // We don't want the rd_ptr of unk to move, in case it is
00146         // shared by another Any. This copies the state, not the buffer.
00147         TAO_InputCDR for_reading (unk->_tao_get_cdr ());
00148 
00149         CORBA::Boolean const good_decode =
00150           replacement->demarshal_value (for_reading,
00151                                         static_cast<CORBA::Long> (tck));
00152 
00153         if (good_decode)
00154           {
00155             Any_Basic_Impl::assign_value (_tao_elem,
00156                                           replacement,
00157                                           tck);
00158             const_cast<CORBA::Any &> (any).replace (replacement);
00159             replacement_safety.release ();
00160             return true;
00161           }
00162 
00163         // Duplicated by Any_Impl base class constructor.
00164         ::CORBA::release (any_tc);
00165       }
00166     catch (const ::CORBA::Exception&)
00167       {
00168       }
00169 
00170     return false;
00171   }

void TAO::Any_Basic_Impl::insert CORBA::Any ,
CORBA::TypeCode_ptr  ,
const void * 
[static]
 

Definition at line 85 of file Any_Basic_Impl.cpp.

References ACE_NEW, and CORBA::Any::replace().

Referenced by operator<<=(), and CORBA::Any::operator<<=().

00088   {
00089     Any_Basic_Impl *new_impl = 0;
00090     ACE_NEW (new_impl,
00091              Any_Basic_Impl (tc,
00092                              const_cast<void *> (value)));
00093     any.replace (new_impl);
00094   }

CORBA::Boolean TAO::Any_Basic_Impl::marshal_value TAO_OutputCDR  )  [virtual]
 

Implements TAO::Any_Impl.

Definition at line 174 of file Any_Basic_Impl.cpp.

References CORBA::Any::from_boolean, CORBA::Any::from_char, CORBA::Any::from_octet, CORBA::Any::from_wchar, and kind_.

00175   {
00176     CORBA::TCKind const tckind = static_cast<CORBA::TCKind> (this->kind_);
00177 
00178     switch (tckind)
00179     {
00180       case CORBA::tk_short:
00181         return cdr << this->u_.s;
00182       case CORBA::tk_ushort:
00183         return cdr << this->u_.us;
00184       case CORBA::tk_long:
00185         return cdr << this->u_.l;
00186       case CORBA::tk_ulong:
00187         return cdr << this->u_.ul;
00188       case CORBA::tk_float:
00189         return cdr << this->u_.f;
00190       case CORBA::tk_double:
00191         return cdr << this->u_.d;
00192       case CORBA::tk_boolean:
00193         return cdr << CORBA::Any::from_boolean (this->u_.b);
00194       case CORBA::tk_char:
00195         return cdr << CORBA::Any::from_char (this->u_.c);
00196       case CORBA::tk_octet:
00197         return cdr << CORBA::Any::from_octet (this->u_.o);
00198       case CORBA::tk_longlong:
00199         return cdr << this->u_.ll;
00200 #if !defined (ACE_LACKS_LONGLONG_T)
00201       case CORBA::tk_ulonglong:
00202         return cdr << this->u_.ull;
00203 #endif
00204       case CORBA::tk_longdouble:
00205         return cdr << this->u_.ld;
00206       case CORBA::tk_wchar:
00207         return cdr << CORBA::Any::from_wchar (this->u_.wc);
00208       default:
00209         return false;
00210     }
00211   }


Member Data Documentation

CORBA::Boolean TAO::Any_Basic_Impl::b [private]
 

Definition at line 80 of file Any_Basic_Impl.h.

CORBA::Char TAO::Any_Basic_Impl::c [private]
 

Definition at line 81 of file Any_Basic_Impl.h.

CORBA::Double TAO::Any_Basic_Impl::d [private]
 

Definition at line 79 of file Any_Basic_Impl.h.

CORBA::Float TAO::Any_Basic_Impl::f [private]
 

Definition at line 78 of file Any_Basic_Impl.h.

CORBA::Long TAO::Any_Basic_Impl::kind_ [private]
 

Definition at line 71 of file Any_Basic_Impl.h.

Referenced by Any_Basic_Impl(), assign_value(), and marshal_value().

CORBA::Long TAO::Any_Basic_Impl::l [private]
 

Definition at line 76 of file Any_Basic_Impl.h.

CORBA::LongDouble TAO::Any_Basic_Impl::ld [private]
 

Definition at line 91 of file Any_Basic_Impl.h.

CORBA::LongLong TAO::Any_Basic_Impl::ll [private]
 

Definition at line 83 of file Any_Basic_Impl.h.

CORBA::Octet TAO::Any_Basic_Impl::o [private]
 

Definition at line 82 of file Any_Basic_Impl.h.

CORBA::Short TAO::Any_Basic_Impl::s [private]
 

Definition at line 74 of file Any_Basic_Impl.h.

union { ... } TAO::Any_Basic_Impl::u_ [private]
 

Referenced by assign_value().

CORBA::ULong TAO::Any_Basic_Impl::ul [private]
 

Definition at line 77 of file Any_Basic_Impl.h.

CORBA::ULongLong TAO::Any_Basic_Impl::ull [private]
 

Definition at line 85 of file Any_Basic_Impl.h.

CORBA::UShort TAO::Any_Basic_Impl::us [private]
 

Definition at line 75 of file Any_Basic_Impl.h.

CORBA::WChar TAO::Any_Basic_Impl::wc [private]
 

Definition at line 92 of file Any_Basic_Impl.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:22:04 2008 for TAO_AnyTypeCode by doxygen 1.3.6