finally convert the Trainer fully to C++
comply to the new core API