-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[features/run] Support for output record logging and parsing #2533
base: features/run
Are you sure you want to change the base?
[features/run] Support for output record logging and parsing #2533
Conversation
cca6e13
to
9b50b10
Compare
2857a05
to
8505897
Compare
-- primitive types TODO: Handle arrays (vector of results) * Naive way of parsing integer array log Signed-off-by: Pradnya Khalate <[email protected]>
8505897
to
c7f2849
Compare
c7f2849
to
0171e26
Compare
Signed-off-by: Pradnya Khalate <[email protected]>
0171e26
to
cf3eb4f
Compare
OutputType extractPrimitiveType(const std::string &label) { | ||
if ('i' == label[0]) { | ||
auto digits = std::stoi(label.substr(1)); | ||
if (1 == digits) | ||
return OutputType::BOOL; | ||
return OutputType::INT; | ||
} else if ('f' == label[0]) | ||
return OutputType::DOUBLE; | ||
throw std::runtime_error("Unknown datatype in label"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can store this in a map and get the output type if the label is found in the map.
template <typename T> | ||
void addPrimitiveRecord(T value) { | ||
results.emplace_back( | ||
OutputRecord{static_cast<void *>(new T(value)), sizeof(T)}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of new, we can use unique pointer here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using std::make_unique
to create new value but I couldn't get the value out of it in my tests... :(
I think we can implement object-oriented parser here. We want to handle the different types of objects. Objects being Record, Header, Output. We can have RecordHandler as the parent class with some process method. And then implement that method in the inherited classes. In the RecordParser, we can have a map of object names and unique pointers of handlers. The parse method will then call the respective process method based on the object type. We need to give some thought here for nested structure. |
…ented for testing only * Addressing PR comment Signed-off-by: Pradnya Khalate <[email protected]>
586bab8
to
22b2b7e
Compare
Signed-off-by: Pradnya Khalate <[email protected]>
Towards: #2526