DurabilityArray.h
Go to the documentation of this file.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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017 namespace OpenDDS {
00018 namespace DCPS {
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 template<typename T>
00038 class DurabilityArray : public ACE_Array_Base<T> {
00039 public:
00040
00041 DurabilityArray(size_t size,
00042 ACE_Allocator * allocator)
00043 : ACE_Array_Base<T> (size, allocator)
00044 {}
00045
00046 DurabilityArray(size_t size,
00047 T const & default_value,
00048 ACE_Allocator * allocator)
00049 : ACE_Array_Base<T> (size, default_value, allocator)
00050 {}
00051
00052 DurabilityArray(DurabilityArray<T> const & rhs)
00053 : ACE_Array_Base<T> (rhs.size(), rhs.allocator_)
00054 {
00055 for (size_t i = 0; i < this->size_; ++i)
00056 this->array_[i] = rhs.array_[i];
00057 }
00058
00059 ~DurabilityArray()
00060 {}
00061
00062 void operator= (DurabilityArray<T> const & rhs)
00063 {
00064 DurabilityArray tmp(rhs);
00065 this->swap(rhs);
00066 }
00067
00068
00069 void set_allocator(ACE_Allocator * allocator)
00070 {
00071 if (allocator == 0)
00072 allocator = ACE_Allocator::instance();
00073
00074 this->allocator_ = allocator;
00075 }
00076
00077 void swap(DurabilityArray<T> & rhs)
00078 {
00079 std::swap(this->max_size_, rhs.max_size_);
00080 std::swap(this->cur_size_, rhs.current_size_);
00081 std::swap(this->array_, rhs.array_);
00082 std::swap(this->allocator_, rhs.allocator_);
00083 }
00084 };
00085
00086 }
00087 }
00088
00089 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00090
00091 #endif