Go to the documentation of this file.00001 #ifndef guard_array_traits_hpp
00002 #define guard_array_traits_hpp
00003
00004
00005
00006
00007
00008
00009
00010
00011
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 release_range(
00061 value_type *, value_type *)
00062 {
00063
00064 }
00065
00066 inline static void initialize_range(
00067 value_type * begin, value_type * end)
00068 {
00069 std::for_each(
00070 begin, end, &TAO::Array_Traits<forany_type>::zero);
00071 }
00072
00073 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00074
00075 template <typename iter>
00076 inline static void copy_range(
00077 value_type * begin, value_type * end, iter dst)
00078 {
00079 for(value_type * i = begin; i != end; ++i, ++dst)
00080 {
00081 TAO::Array_Traits<forany_type>::copy(*dst, *i);
00082 }
00083 }
00084 # else
00085 inline static void copy_range(
00086 value_type * begin, value_type * end, value_type *dst)
00087 {
00088 for(value_type * i = begin; i != end; ++i, ++dst)
00089 {
00090 TAO::Array_Traits<forany_type>::copy(*dst, *i);
00091 }
00092 }
00093 # endif
00094
00095 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00096
00097 template <typename iter>
00098 inline static void copy_swap_range(
00099 value_type * begin, value_type * end, iter dst)
00100 {
00101 copy_range(begin, end, dst);
00102 }
00103 # else
00104 inline static void copy_swap_range(
00105 value_type * begin, value_type * end, value_type *dst)
00106 {
00107 copy_range(begin, end, dst);
00108 }
00109 # endif
00110 };
00111
00112 }
00113 }
00114
00115 TAO_END_VERSIONED_NAMESPACE_DECL
00116
00117 #endif // guard_array_traits_hpp