A Generalised Approach for Encoding and Reasoning with Qualitative Theories in Answer Set Programming