00001 /*00002 * The Software License00003 * =================================================================================00004 * Copyright (c) 2003-2009 The Terimber Corporation. All rights reserved.00005 * =================================================================================00006 * Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer.00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 * this list of conditions and the following disclaimer in the documentation 00010 * and/or other materials provided with the distribution.00011 * The end-user documentation included with the redistribution, if any, 00012 * must include the following acknowledgment:00013 * "This product includes software developed by the Terimber Corporation."00014 * =================================================================================00015 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE TERIMBER CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR 00019 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.00025 * ================================================================================00026 */00027
00028 #ifndef _terimber_number_h_00029 #define _terimber_number_h_00030
00031 #include "base/memory.h"00032
00033 BEGIN_TERIMBER_NAMESPACE00034 #pragma pack(4)00035
00037 template < class T >
00038class room_array00039 {
00041enumroom_size { S = sizeof(T) };
00042
00043 public:
00045 room_array< T >(size_tsize,
00046 byte_allocator* allocator_ = 0
00047 );
00049 room_array< T >(constroom_array< T >& src);
00051 room_array< T >& operator=(constroom_array< T >& src);
00053 ~room_array< T >();
00055 inline00056 room_array< T >&
00057 operator>>( size_t shift
00058 );
00060 inline00061 room_array< T >&
00062 operator<<( size_t shift
00063 );
00065 inline00066 room_array< T >&
00067 resize( size_t size,
00068 bool clean = false00069 );
00071 inline00072 room_array< T >&
00073 reserve( size_t size
00074 );
00076 inline00077 void00078 swap( room_array& src
00079 );
00081 inline00082operator T*()
00083 {
00084 return_buffer;
00085 }
00087inlineoperator const T*() const 00088 {
00089 return_buffer;
00090 }
00092 inline00093 size_t00094 size() const;
00096 inline00097 room_array< T >&
00098 fill( const T& src,
00099 size_t len
00100 );
00102 inline00103 room_array< T >&
00104 copy( const T* src,
00105 size_t len
00106 );
00108 inline00109 void00110 back( T* src,
00111 size_t len
00112 ) const;
00114 inline00115 room_array< T >&
00116 clear();
00118 inline00119 byte_allocator*
00120 get_allocator();
00121 private:
00122byte_allocator* _allocator;
00123 T* _buffer;
00124size_t_size;
00125 };
00126
00127 #pragma pack()00128 END_TERIMBER_NAMESPACE00129
00130 #endif // _terimber_number_h_00131