1 #include "mocktuningfork.h" 2 3 #include <iostream> 4 #include <fstream> 5 6 namespace mocktuningfork { 7 8 using ::com::google::tuningfork::Annotation; 9 using ::com::google::tuningfork::Settings; 10 using ::com::google::tuningfork::FidelityParams; 11 12 Annotation current_annotation; 13 FidelityParams latest_params; 14 15 const std::string fparams_fname = "fidelityparams.pbin"; 16 init(const Settings &,const std::function<void (const FidelityParams &)> & callback)17void init(const Settings& /*settings*/, 18 const std::function<void(const FidelityParams&)>& callback) { 19 std::ifstream fin(fparams_fname); 20 if(fin.good()) { 21 std::cout << "Tuning fork got params from Play ( " << fparams_fname 22 << " )" << std::endl; 23 latest_params.ParseFromIstream(&fin); 24 callback(latest_params); 25 } 26 else { 27 std::cerr << "Tuning fork couldn't get parameters from play." 28 << " Run ./play first." << std::endl; 29 } 30 } 31 set(const Annotation & a)32void set(const Annotation& a) { 33 current_annotation = a; 34 } 35 tick(int ikey)36void tick(int ikey) { 37 std::cout << "TF tick {ikey: " << ikey << ", ann: "; 38 std::cout << current_annotation.DebugString(); 39 std::cout << "}" << std::endl; 40 } 41 42 } // namespace mocktuningfork 43