Skip to content
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

Utility function to read samples from a file #15

Closed
lkosmid opened this issue Aug 24, 2018 · 4 comments
Closed

Utility function to read samples from a file #15

lkosmid opened this issue Aug 24, 2018 · 4 comments

Comments

@lkosmid
Copy link

lkosmid commented Aug 24, 2018

In the simple_hello_world_cv_2.cpp example the time samples are provided statically in an array defined in the test_cv_values.h header file. However, this means that the program has to be recompiled every time in order to be used with a new data set.

In order chronovise to be easier to use by end-users (e.g. engineers not developers) , it would be useful to provide a utility function that can parse directly an input file such as test_cv_values.txt. Moreover, this will provide compatibility with MBPTA-CV.

@federeghe
Copy link
Owner

You're right, this was a very ugly hack just for the review. However, in C++ it's very easy to read numbers from a file using ifstream, declaring somewhere (let's say global)

std::ifstream my_input_file ("file.txt"); 

and then in onRun() doing something like this:

float num;
my_input_file >> num;
this->add_sample(num);

I didn't put too much effort in that example, because the user is required to implement the class SimpleExecutionContext or ExecutionContext as he or she desires, but I can fix this horrible hack.

@lkosmid
Copy link
Author

lkosmid commented Aug 24, 2018

What I was thinking is that instead of modifying the example, to overload add_sample() in order to get a filename as an argument, since this might be a frequently used feature.

@federeghe
Copy link
Owner

Ok, I created an utility to read files (4a6a573) and a function add_sample_from_file() in SimpleExecutionContext (a4cc916). The example has been modified accordingly. I didn't use the overload to avoid name hiding problem of the parent class methods.

@lkosmid
Copy link
Author

lkosmid commented Aug 27, 2018

I agree, it's fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants