Example: A customized ContainerFactory using a nonhashed IdxContainer type

// ... classes as in IndexedDBView example ....
typedef DBView<Example, ParamObjExample> ViewType;
typedef CBFunctor2wRet<const Example *, const Example *, bool> IVCompare;
typedef multiset<Example *, IVCompare> MultisetType; 
typedef DBIndex<ViewType. MultisetType, NO_HASH > IdxType;

// reverse comparison on exampleStr
bool reverse_compare_strings(const Example *pData1, const Example *pData2)
{
	return pData1->GetExampleStr() > pData2->GetExampleStr();
}


// "specialized" ContainerFactory() tells the indices in the IndexedDBView
// to use a custom container for indexing records
// in this case, the container is a multiset which sorts in reverse order
// for the Primary Index and normal for all other indices
// assume the IndexedDBView<ViewType, MultisetType, NO_HASH> that uses this
// specialization of ContainerFactory has the following indices:
// PrimaryIndex = nonunique key with fields: STRING_VALUE = we want sorted // based on reverse_compare_strings() // AlternateIndex = unique key with fields: EXAMPLE_LONG, EXAMPLE_DATE = // we want sorted based on the default DBIndex::lt() function
template<> class dtl::ContainerFactory<IdxType> { public: MultisetType operator()(IdxType *pDBIndex, NO_HASH h) { // for STRING_VALUE's, compare true if first exampleStr > second exampleStr if (pDBIndex->GetName() == "PrimaryIndex") return MultisetType(cb_ptr_fun_w_ret(reverse_compare_strings)); else // for all other indices, in this case, pDBIndex->GetName() == "AlternateIndex", use generic comparison return MultisetType(cb_ptr_fun_w_ret(*pDBIndex, &IdxType::lt)); } };