00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_DURABILITY_ARRAY_H
00009 #define OPENDDS_DURABILITY_ARRAY_H
00010
00011 #include <ace/Array_Base.h>
00012
00013 #include <algorithm>
00014
00015 namespace OpenDDS {
00016 namespace DCPS {
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 template<typename T>
00036 class DurabilityArray : public ACE_Array_Base<T> {
00037 public:
00038
00039 DurabilityArray(size_t size,
00040 ACE_Allocator * allocator)
00041 : ACE_Array_Base<T> (size, allocator)
00042 {}
00043
00044 DurabilityArray(size_t size,
00045 T const & default_value,
00046 ACE_Allocator * allocator)
00047 : ACE_Array_Base<T> (size, default_value, allocator)
00048 {}
00049
00050 DurabilityArray(DurabilityArray<T> const & rhs)
00051 : ACE_Array_Base<T> (rhs.size(), rhs.allocator_)
00052 {
00053 for (size_t i = 0; i < this->size_; ++i)
00054 this->array_[i] = rhs.array_[i];
00055 }
00056
00057 ~DurabilityArray()
00058 {}
00059
00060 void operator= (DurabilityArray<T> const & rhs)
00061 {
00062 DurabilityArray tmp(rhs);
00063 this->swap(rhs);
00064 }
00065
00066
00067 void set_allocator(ACE_Allocator * allocator)
00068 {
00069 if (allocator == 0)
00070 allocator = ACE_Allocator::instance();
00071
00072 this->allocator_ = allocator;
00073 }
00074
00075 void swap(DurabilityArray<T> & rhs)
00076 {
00077 std::swap(this->max_size_, rhs.max_size_);
00078 std::swap(this->cur_size_, rhs.current_size_);
00079 std::swap(this->array_, rhs.array_);
00080 std::swap(this->allocator_, rhs.allocator_);
00081 }
00082 };
00083
00084 }
00085 }
00086
00087 #endif