Array_Traits_T.h

Go to the documentation of this file.
00001 #ifndef guard_array_traits_hpp
00002 #define guard_array_traits_hpp
00003 /**
00004  * @file
00005  *
00006  * @brief Implement the element manipulation traits for types with
00007  * array-like semantics.
00008  *
00009  * $Id: Array_Traits_T.h 77704 2007-03-14 04:33:49Z ossama $
00010  *
00011  * @author Carlos O'Ryan
00012  */
00013 
00014 #include <algorithm>
00015 #include "tao/Array_VarOut_T.h"
00016 
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 namespace TAO
00020 {
00021 namespace details
00022 {
00023 
00024 template <typename T_forany>
00025 struct array_traits
00026 {
00027   typedef T_forany forany_type;
00028   typedef typename T_forany::_array_type value_type;
00029   typedef typename T_forany::_array_type const const_value_type;
00030   typedef typename T_forany::_slice_type slice_type;
00031 
00032   inline static void copy (slice_type * _tao_to, const slice_type * _tao_from)
00033   {
00034     TAO::Array_Traits<forany_type>::copy (_tao_to, _tao_from);
00035   }
00036 
00037   inline static void free (slice_type * value)
00038   {
00039     TAO::Array_Traits<forany_type>::free (value);
00040   }
00041 
00042   inline static slice_type * alloc (void)
00043   {
00044     return TAO::Array_Traits<forany_type>::alloc ();
00045   }
00046 
00047   inline static slice_type * dup(
00048       const slice_type * value)
00049   {
00050     return TAO::Array_Traits<forany_type>::dup (value);
00051   }
00052 
00053   inline static void zero_range(
00054       value_type * begin, value_type * end)
00055   {
00056     std::for_each(
00057         begin, end, &TAO::Array_Traits<forany_type>::zero);
00058   }
00059 
00060   inline static void initialize_range(
00061       value_type * begin, value_type * end)
00062   {
00063     std::for_each(
00064         begin, end, &TAO::Array_Traits<forany_type>::zero);
00065   }
00066 # ifndef ACE_LACKS_MEMBER_TEMPLATES
00067   // Allow MSVC++ >= 8 checked iterators to be used.
00068   template <typename iter>
00069   inline static void copy_range(
00070       value_type * begin, value_type * end, iter dst)
00071   {
00072     for(value_type * i = begin; i != end; ++i, ++dst)
00073     {
00074       TAO::Array_Traits<forany_type>::copy(*dst, *i);
00075     }
00076   }
00077 #else
00078   inline static void copy_range(
00079       value_type * begin, value_type * end, value_type *dst)
00080   {
00081     for(value_type * i = begin; i != end; ++i, ++dst)
00082     {
00083       TAO::Array_Traits<forany_type>::copy(*dst, *i);
00084     }
00085   }
00086 # endif  /* !ACE_LACKS_MEMBER_TEMPLATES */
00087 };
00088 
00089 } // namespace details
00090 } // namespace CORBA
00091 
00092 TAO_END_VERSIONED_NAMESPACE_DECL
00093 
00094 #endif // guard_array_traits_hpp

Generated on Tue Feb 2 17:37:51 2010 for TAO by  doxygen 1.4.7