aboutsummaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-10 21:04:17 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-10 21:04:17 +0000
commit2ba3f84ab559da02a11aa000b3cecb3b3668af61 (patch)
tree266f450b512f607ec54d54af4fa8c13fdbe7ef91 /src/array.h
parentea18007633b31901f2ae275cc0576c3f7ce99fc9 (diff)
parent3611f253f6fdfa4954d374ab85ddaa7f799c130c (diff)
downloadlibbu++-2ba3f84ab559da02a11aa000b3cecb3b3668af61.tar.gz
libbu++-2ba3f84ab559da02a11aa000b3cecb3b3668af61.tar.bz2
libbu++-2ba3f84ab559da02a11aa000b3cecb3b3668af61.tar.xz
libbu++-2ba3f84ab559da02a11aa000b3cecb3b3668af61.zip
Merged in the core branch. This is a major update that fixes many things, and
changes many others, including source files that were deleted and renamed. Before doing this update, I reccomend a full clean, or even a fresh checkout. Things to note, most outstanding about this update: - Bu::Socket was changed to Bu::TcpSocket and the default mode is blocking. - All templatized container classes are SharedCore now, which is good, but SharedCore is inherently non-reentrant safe. However, all SharedCore classes have a "clone" function that return a non-shared copy of the object, safe for passing into a reentrant safe function accessing shared memory.
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/array.h b/src/array.h
index eeee677..f225c97 100644
--- a/src/array.h
+++ b/src/array.h
@@ -18,9 +18,18 @@ namespace Bu
18 subExceptionDecl( ArrayException ) 18 subExceptionDecl( ArrayException )
19 19
20 template<typename value, int inc, typename valuealloc> 20 template<typename value, int inc, typename valuealloc>
21 class Array;
22
23 /** @cond DEVEL */
24 template<typename value, int inc, typename valuealloc>
21 class ArrayCore 25 class ArrayCore
22 { 26 {
23 public: 27 friend class Array<value, inc, valuealloc>;
28 friend class SharedCore<
29 Array<value, inc, valuealloc>,
30 ArrayCore<value, inc, valuealloc>
31 >;
32 private:
24 ArrayCore() : 33 ArrayCore() :
25 pData( NULL ), 34 pData( NULL ),
26 iSize( 0 ), 35 iSize( 0 ),
@@ -99,6 +108,7 @@ namespace Bu
99 long iSize; 108 long iSize;
100 long iCapacity; 109 long iCapacity;
101 }; 110 };
111 /** @endcond */
102 112
103 /** 113 /**
104 * Array type container, just like a normal array only flexible and keeps 114 * Array type container, just like a normal array only flexible and keeps
@@ -110,16 +120,20 @@ namespace Bu
110 *@ingroup Containers 120 *@ingroup Containers
111 */ 121 */
112 template<typename value, int inc=10, typename valuealloc=std::allocator<value> > 122 template<typename value, int inc=10, typename valuealloc=std::allocator<value> >
113 class Array : public SharedCore<ArrayCore<value, inc, valuealloc> > 123 class Array : public SharedCore<
124 Array<value, inc, valuealloc>,
125 ArrayCore<value, inc, valuealloc>
126 >
114 { 127 {
115 private: 128 private:
116 typedef class Array<value, inc, valuealloc> MyType; 129 typedef class Array<value, inc, valuealloc> MyType;
117 typedef class ArrayCore<value, inc, valuealloc> Core; 130 typedef class ArrayCore<value, inc, valuealloc> Core;
118 131
119 protected: 132 protected:
120 using SharedCore< Core >::core; 133 using SharedCore<MyType, Core>::core;
121 using SharedCore< Core >::_hardCopy; 134 using SharedCore<MyType, Core>::_hardCopy;
122 using SharedCore< Core >::_allocateCore; 135 using SharedCore<MyType, Core>::_resetCore;
136 using SharedCore<MyType, Core>::_allocateCore;
123 137
124 public: 138 public:
125 struct const_iterator; 139 struct const_iterator;
@@ -130,7 +144,7 @@ namespace Bu
130 } 144 }
131 145
132 Array( const MyType &src ) : 146 Array( const MyType &src ) :
133 SharedCore< Core >( src ) 147 SharedCore<MyType, Core >( src )
134 { 148 {
135 } 149 }
136 150
@@ -168,8 +182,7 @@ namespace Bu
168 */ 182 */
169 void clear() 183 void clear()
170 { 184 {
171 _hardCopy(); 185 _resetCore();
172 core->clear();
173 } 186 }
174 187
175 MyType &append( const value &rVal ) 188 MyType &append( const value &rVal )