Bounded_Reference_Allocation_Traits_T.h

Go to the documentation of this file.
00001 #ifndef guard_bounded_reference_allocation_traits_hpp
00002 #define guard_bounded_reference_allocation_traits_hpp
00003 /**
00004  * @file
00005  *
00006  * @brief Details can be found in the documentation for
00007  * TAO::details::generic_sequence
00008  *
00009  * Bounded_Reference_Allocation_Traits_T.h,v 1.2 2006/04/19 08:20:57 jwillemsen Exp
00010  *
00011  * @author Carlos O'Ryan
00012  */
00013 
00014 #include "tao/Basic_Types.h"
00015 
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace TAO
00019 {
00020 namespace details
00021 {
00022 
00023 template<typename T, class ref_traits, CORBA::ULong MAX, bool dummy>
00024 struct bounded_reference_allocation_traits
00025 {
00026   typedef T value_type;
00027   typedef ref_traits reference_traits;
00028 
00029   inline static CORBA::ULong default_maximum()
00030   {
00031     return MAX;
00032   }
00033 
00034   inline static value_type * default_buffer_allocation()
00035   {
00036     return allocbuf(MAX);
00037   }
00038 
00039   inline static value_type * allocbuf(CORBA::ULong /* maximum */)
00040   {
00041     value_type * buffer = new value_type[MAX];
00042     // no throw
00043     reference_traits::zero_range(buffer, buffer + MAX);
00044 
00045     return buffer;
00046   }
00047 
00048   inline static void freebuf(value_type * buffer)
00049   {
00050     reference_traits::release_range(buffer, buffer + MAX);
00051     delete[] buffer;
00052   }
00053 
00054   inline static CORBA::ULong maximum()
00055   {
00056     return MAX;
00057   }
00058 };
00059 
00060 } // namespace details
00061 } // namespace TAO
00062 
00063 TAO_END_VERSIONED_NAMESPACE_DECL
00064 
00065 #endif // guard_bounded_reference_allocation_traits_hpp

Generated on Thu Nov 9 11:54:08 2006 for TAO by doxygen 1.3.6