Go to the documentation of this file.00001 #ifndef guard_object_reference_traits_hpp
00002 #define guard_object_reference_traits_hpp
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "Object_Reference_Traits_Base_T.h"
00014 #include "ace/OS_NS_string.h"
00015
00016 #include <algorithm>
00017 #include <functional>
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 namespace TAO
00022 {
00023 namespace details
00024 {
00025
00026 template<class object_t, class object_t_var, class derived>
00027 struct object_reference_traits_decorator
00028 {
00029 typedef object_t object_type;
00030 typedef object_type * value_type;
00031 typedef object_type const * const_value_type;
00032 typedef object_t_var object_type_var;
00033
00034 inline static void zero_range(
00035 object_type ** begin, object_type ** end)
00036 {
00037 ACE_OS::memset (begin, 0, (end - begin) * sizeof (object_type*));
00038 }
00039
00040 inline static void initialize_range(
00041 object_type ** begin, object_type ** end)
00042 {
00043 std::generate(begin, end, &derived::default_initializer);
00044 }
00045
00046 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00047
00048 template <typename iter>
00049 inline static void copy_range(
00050 object_type ** begin, object_type ** end, iter dst)
00051 {
00052 std::transform(begin, end, dst, &derived::duplicate);
00053 }
00054 # else
00055 inline static void copy_range(
00056 object_type ** begin, object_type ** end, object_type ** dst)
00057 {
00058 std::transform(begin, end, dst, &derived::duplicate);
00059 }
00060 # endif
00061
00062 # if !defined (ACE_LACKS_MEMBER_TEMPLATES)
00063
00064 template <typename iter>
00065 inline static void copy_swap_range(
00066 object_type ** begin, object_type ** end, iter dst)
00067 {
00068 std::swap_ranges(begin, end, dst);
00069 }
00070 # else
00071 inline static void copy_swap_range(
00072 object_type ** begin, object_type ** end, object_type ** dst)
00073 {
00074 std::swap_ranges(begin, end, dst);
00075 }
00076 # endif
00077
00078 inline static void release_range(
00079 object_type ** begin, object_type ** end)
00080 {
00081 std::for_each(begin, end, &derived::release);
00082 }
00083
00084 inline static object_type const * initialize_if_zero(object_type * & element)
00085 {
00086 if (element == 0)
00087 {
00088 element = derived::nil();
00089 }
00090 return element;
00091 }
00092 };
00093
00094 template<typename object_t, typename object_t_var, bool dummy>
00095 struct object_reference_traits
00096 : public object_reference_traits_base<object_t, object_t_var>
00097 , public object_reference_traits_decorator<object_t, object_t_var, object_reference_traits<object_t,object_t_var,dummy> >
00098 {
00099 typedef object_t object_type;
00100 typedef object_type * value_type;
00101 typedef object_type const * const_value_type;
00102 typedef object_t_var object_type_var;
00103 };
00104
00105 }
00106 }
00107
00108 TAO_END_VERSIONED_NAMESPACE_DECL
00109
00110 #endif // guard_object_reference_traits_hpp