Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Sequence_Unit_Tests / testing_allocation_traits.hpp
blob9b937afc32802ab04105d5247bd179f5348b1090
1 #ifndef guard_testing_allocation_traits_hpp
2 #define guard_testing_allocation_traits_hpp
3 /**
4 * @file
6 * @brief Specialize the allocation traits in a manner suitable for
7 * testing.
9 * @author Carlos O'Ryan
12 #include "tao/Unbounded_Value_Allocation_Traits_T.h"
13 #include "tao/Bounded_Value_Allocation_Traits_T.h"
14 #include "tao/Unbounded_Reference_Allocation_Traits_T.h"
15 #include "tao/Bounded_Reference_Allocation_Traits_T.h"
16 #include "testing_exception.hpp"
17 #include "testing_counters.hpp"
19 template<typename T, class base>
20 struct testing_allocation_traits : public base
22 typedef typename base::value_type value_type;
24 static call_counter default_buffer_allocation_calls;
25 inline static value_type * default_buffer_allocation()
27 default_buffer_allocation_calls();
28 return base::default_buffer_allocation();
31 static call_counter allocbuf_calls;
32 inline static value_type * allocbuf(CORBA::ULong maximum)
34 allocbuf_calls();
35 return base::allocbuf(maximum);
38 // allocbuf_calls must be updated when allocbuf_noinit is called as well.
39 inline static value_type * allocbuf_noinit(CORBA::ULong maximum)
41 allocbuf_calls();
42 return base::allocbuf_noinit(maximum);
45 static call_counter freebuf_calls;
46 inline static void freebuf(value_type * buffer)
48 freebuf_calls();
49 base::freebuf(buffer);
53 template<typename T, class base> call_counter
54 testing_allocation_traits<T,base>::allocbuf_calls;
56 template<typename T, class base> call_counter
57 testing_allocation_traits<T,base>::freebuf_calls;
59 template<typename T, class base> call_counter
60 testing_allocation_traits<T,base>::default_buffer_allocation_calls;
62 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
63 namespace TAO
65 namespace details
68 template<typename T>
69 struct unbounded_value_allocation_traits<T,true>
70 : public testing_allocation_traits<T, unbounded_value_allocation_traits<T,false> >
74 template<typename T, CORBA::ULong MAX>
75 struct bounded_value_allocation_traits<T,MAX,true>
76 : public testing_allocation_traits<T, bounded_value_allocation_traits<T,MAX,false> >
80 template<typename T, class reference_traits>
81 struct unbounded_reference_allocation_traits<T,reference_traits,true>
82 : public testing_allocation_traits<T, unbounded_reference_allocation_traits<T,reference_traits,false> >
86 template<typename T, class reference_traits, CORBA::ULong MAX>
87 struct bounded_reference_allocation_traits<T,reference_traits,MAX,true>
88 : public testing_allocation_traits<T, bounded_reference_allocation_traits<T,reference_traits,MAX,false> >
92 } // namespace details
93 } // namespace TAO
94 TAO_END_VERSIONED_NAMESPACE_DECL
96 #endif // guard_testing_allocation_traits_hpp