-
Notifications
You must be signed in to change notification settings - Fork 45
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
What should RecorderLib look like? #11
Comments
I see the primary purpose of this task is to separate the LabRecorder back end from the front end. No more and no less. As such, Chadwick's approach more completely fulfills that goal. It also keeps the back end of the code from crossing language barriers, which is a huge complexity savings. However, it should be done such that the client can get full status and error information, either polled (probably easier with the C ABI) or event driven (probably more fault tolerant). For the command and status blocks, I recommend JSON strings, which allows easier integration with other systems and future extendability. Tristan's approach allows people more control. But at the end of the day, if people want that level of control they should probably just pull out the bits and pieces that they want (from the source code), and integrate them however they want. The future LabRecorder library source will give them a good starting point. |
The more I work on things like remote control, better handling of existing files and so on the more the separation between the recorderlib and the rest of the C++ labrecorder gets in the way. To add the original intent from the discussion on slack:
One of the problems I don't see yet how to properly handle with one big lib:
|
It's going to be hard either way. Chadwick and I believe that more isolation will be easier overall and in the long run. Also, note that the more isolated design is more naturally portable regardless of the language, UI toolkit, and location of the UI (in the same application or across the network).
This can be implemented with During recording
Common and expected errors can be categorized. Unexpected exceptions can return exception::what().
There is no solution that will prevent the user from being able to make errors. Appropriate and helpful error messages should be returned when mistakes are made. Also, overall your solution demands significantly more competency on the part of the downstream developer, so this objection is rather strange. |
The way I envisioned this scenario is that the library function would have a I can propose a compromise: |
That's true, but how compared to liblsl, the recorderlib doesn't need to be portable. Most users will use a PC with a graphical user interface to record the data and some might want to record on mobile devices (android/ios?). Also, the integration with other programs everyone wants is mostly limited to "wait for streams, start recording, stop recording".
Will there be any language other than C++, Python and maybe (if Qt on Android stays a pipe dream) Java?
That's a good point against Qt's signals and slots as core part of the recorderlib.
What did you have in mind? A browser based UI could be nice, but that should be covered by Python + some library.
JSON has it's place, but even in this simple example the pseudocode for that would look like: char* json_info_string = start_recording("filename.xdf", /*rename_if_exists*/ true);
json* result;
int jsonparseresult = json_parse(json_info_string);
if(!jsonparseresult) {
// Handle the JSON parsing error, don't forget to free json_info_string
}
recorderlib_free_string(json_info_string);
if(json_has_field(result, "status")) {
int code = json_get_field(result, "status");
switch(code) {
case 1: // Do stuff, don't forget to free result before returning
break;
// ......
}
} else // Error, don't forget to free result before returning
json_free(result); We're at a minimum of 16 lines (+ a JSON parsing library) for a single function call with all the fun of manual memory management.
The recorderlib needs to keep track of all streams anyway, but we'd need additional code to serialize the stream info into JSON. We could have a
I'd rather start from the other end: we write code samples for the library users in pseudocode and then evaluate, whether that's something that should be exposed and if it's possible / reasonable with a C / C++ API |
There are two different approaches to a recorderlib:
Tristan's approach:
Pros
Cons
Chad's approach:
Copied from Chad's comment:
The text was updated successfully, but these errors were encountered: