diff --git a/include/MLModelRunner/MLModelRunner.h b/include/MLModelRunner/MLModelRunner.h index 15ddaa6..1ebb908 100644 --- a/include/MLModelRunner/MLModelRunner.h +++ b/include/MLModelRunner/MLModelRunner.h @@ -41,6 +41,7 @@ #include "SerDes/jsonSerDes.h" #include +#include #include #include #include @@ -55,6 +56,7 @@ namespace MLBridge { /// MLModelRunner - The main interface for interacting with the ML models. class MLModelRunner { public: + std::ofstream of; // Disallows copy and assign. MLModelRunner(const MLModelRunner &) = delete; MLModelRunner &operator=(const MLModelRunner &) = delete; @@ -89,6 +91,33 @@ class MLModelRunner { virtual void requestExit() = 0; std::promise *exit_requested; + template + void passMetaInfo(std::pair &var1, + std::pair &...var2) { + of.open("observation.txt", std::ios::app); + of << var1.first << ": " << var1.second << "\n"; + of.close(); + passMetaInfo(var2...); + } + + void passMetaInfo() {} + + template void dumpFeature(std::pair &var1) { + of.open("observation.txt", std::ios::app); + of << var1.first << ": " << var1.second << "\n"; + of.close(); + } + + template + void dumpFeature(std::pair> &var1) { + of.open("observation.txt", std::ios::app); + of << var1.first << ": "; + for (const auto &elem : var1.second) { + of << elem << " "; + } + of << "\n"; + of.close(); + } /// User-facing interface for setting the features to be sent to the model. /// The features are passed as a list of key-value pairs. /// The key is the name of the feature and the value is the value of the @@ -97,6 +126,10 @@ class MLModelRunner { void populateFeatures(std::pair &var1, std::pair &...var2) { SerDes->setFeature(var1.first, var1.second); + dumpFeature(var1); + // of.open("observation.txt",std::ios::app); + // of << var1.first << ": " << reinterpret_cast(var1.second) << "\n"; + // of.close(); populateFeatures(var2...); }