I use a method which is similar to tiago's but is extremely simplified. I use Bullet physics as my collision detection system, artemis-cpp for the ECS architecture.
- Bullet has a function performDiscreteCollisionDetection() (or stepSimulation() if you want dynamics as well). After calling this, all overlapping pairs (ie colliding objects) will be available in an array that bullet maintains internally.
- Loop over this array (note: it's an array of btCollisionObjects so use the userPointer field to get the entity) and add a collided component to the entities in each pair
- The collided component in one entity stores the id of the other entity.
Here is the system logic
- All entities having the collided component as well as a health component will have their health reduced by the amount in the other entity's damage component
- All entities having the collided component as well as a Damage component will just destroy themselves
For your case, you can store additional info in the collided component, and use that to update the transforms of your entities so they no longer collide.
Ofcourse this might be a poor method to do this, but hopefully you can see how a collision detection system can cooperate with entities and systems.