[array] add array_t

This commit is contained in:
Joe Thornber 2013-01-29 11:35:37 +00:00
parent 9e5213530f
commit 7a6d09866a
3 changed files with 11 additions and 3 deletions

View File

@ -142,9 +142,13 @@ namespace persistent_data {
tm_ptr tm_; tm_ptr tm_;
bool destroy_; bool destroy_;
unsigned entries_per_block_; // FIXME: initialise unsigned entries_per_block_; // FIXME: initialise
btree<1, array_block_traits<ValueTraits> > block_tree_;
typedef array_block_traits<ValueTraits> btree_traits;
btree<1, btree_traits> block_tree_;
typename ValueTraits::ref_counter rc_; typename ValueTraits::ref_counter rc_;
}; };
// FIXME: we need an array checker
} }
#include "array.tcc" #include "array.tcc"

View File

@ -71,8 +71,8 @@ array<ValueTraits>::array(typename persistent_data::transaction_manager::ptr tm,
value_type const &default_value) value_type const &default_value)
: tm_(tm), : tm_(tm),
destroy_(false), destroy_(false),
block_tree_(tm, array_block_traits<ValueTraits>()),
entries_per_block_(calc_max_entries(sizeof(value_type), MD_BLOCK_SIZE)), entries_per_block_(calc_max_entries(sizeof(value_type), MD_BLOCK_SIZE)),
block_tree_(tm, typename btree_traits::ref_counter()),
rc_(rc) rc_(rc)
{ {
} }
@ -83,8 +83,8 @@ array<ValueTraits>::array(typename persistent_data::transaction_manager::ptr tm,
block_address root) block_address root)
: tm_(tm), : tm_(tm),
destroy_(false), destroy_(false),
block_tree_(tm, root, array_block_traits<ValueTraits>()),
entries_per_block_(calc_max_entries(sizeof(value_type), MD_BLOCK_SIZE)), entries_per_block_(calc_max_entries(sizeof(value_type), MD_BLOCK_SIZE)),
block_tree_(tm, root, typename btree_traits::ref_counter()),
rc_(rc) rc_(rc)
{ {
} }

View File

@ -17,6 +17,7 @@
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
TEST_SOURCE=\ TEST_SOURCE=\
unit-tests/array_t.cc \
unit-tests/buffer_t.cc \ unit-tests/buffer_t.cc \
unit-tests/cache_t.cc \ unit-tests/cache_t.cc \
unit-tests/block_t.cc \ unit-tests/block_t.cc \
@ -32,6 +33,9 @@ unit-test: $(TEST_PROGRAMS)
.PHONY: unit-test .PHONY: unit-test
unit-tests/array_t: unit-tests/array_t.o $(OBJECTS)
g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
unit-tests/buffer_t: unit-tests/buffer_t.o $(OBJECTS) unit-tests/buffer_t: unit-tests/buffer_t.o $(OBJECTS)
g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT) g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)