| 60 | }; |
| 61 | |
| 62 | struct TestItemRequest |
| 63 | { |
| 64 | TestItem& m_item; |
| 65 | bool m_compareData; |
| 66 | |
| 67 | TestItemRequest(TestItem& item, bool compareData = false) |
| 68 | : m_item(item) |
| 69 | , m_compareData(compareData) |
| 70 | { |
| 71 | } |
| 72 | enum { |
| 73 | AverageSize = 700 //This should be the approximate average size of an Item |
| 74 | }; |
| 75 | |
| 76 | uint hash() const |
| 77 | { |
| 78 | return m_item.hash(); |
| 79 | } |
| 80 | |
| 81 | //Should return the size of an item created with createItem |
| 82 | uint itemSize() const |
| 83 | { |
| 84 | return m_item.itemSize(); |
| 85 | } |
| 86 | |
| 87 | void createItem(TestItem* item) const |
| 88 | { |
| 89 | memcpy(reinterpret_cast<void*>(item), &m_item, m_item.itemSize()); |
| 90 | } |
| 91 | |
| 92 | static void destroy(TestItem* /*item*/, AbstractItemRepository&) |
| 93 | { |
| 94 | //Nothing to do |
| 95 | } |
| 96 | |
| 97 | static bool persistent(const TestItem* /*item*/) |
| 98 | { |
| 99 | return true; |
| 100 | } |
| 101 | |
| 102 | //Should return whether the here requested item equals the given item |
| 103 | bool equals(const TestItem* item) const |
| 104 | { |
| 105 | return hash() == item->hash() && (!m_compareData || m_item.equals(item)); |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | uint smallItemsFraction = 20; //Fraction of items between 0 and 1 kb |
| 110 | uint largeItemsFraction = 1; //Fraction of items between 0 and 200 kb |
no outgoing calls