To create a custom index, inherit from the Indexing::Index class and implement the protected virtual method handleClause(Clause* c, bool adding).
The Index class provides hooks for managing clause lifecycle via a ClauseContainer. When a clause is added to or removed from the container, the index is notified through onAddedToContainer and onRemovedFromContainer, which in turn call your implementation of handleClause.
c: The pointer to the Clause being processed.adding: A boolean indicating whether the clause is being added (true) or removed (false) from the container.
class MyCustomIndex : public Indexing::Index {
protected:
void handleClause(Clause* c, bool adding) override {
if (adding) {
// Logic to add clause c to your index
} else {
// Logic to remove clause c from your index
}
}
};
// Usage:
MyCustomIndex myIndex;
ClauseContainer container;
myIndex.attachContainer(&container);
// Now, adding clauses to 'container' will trigger 'handleClause' in 'myIndex'