Commit 2e937c86 authored by ale's avatar ale

export the stream-based analyzer interface to C

parent f3512603
......@@ -8,9 +8,23 @@
const string AppName = "imms";
imms_features_t imms_analyze(int in_fd) {
Analyzer analyzer;
return analyzer.analyze(in_fd);
imms_analyzer_t imms_stream_analyzer_new() {
return (imms_analyzer_t)new StreamAnalyzer();
}
void imms_stream_analyzer_process(imms_analyzer_t aptr, char *data, int n) {
StreamAnalyzer *sa = reinterpret_cast<StreamAnalyzer*>(aptr);
sa->process(data, n);
}
imms_features_t imms_stream_analyzer_get_result(imms_analyzer_t aptr) {
StreamAnalyzer *sa = reinterpret_cast<StreamAnalyzer*>(aptr);
return (imms_features_t)sa->get_result();
}
void imms_stream_analyzer_free(imms_analyzer_t aptr) {
StreamAnalyzer *sa = reinterpret_cast<StreamAnalyzer*>(aptr);
delete sa;
}
imms_features_t imms_features_from_data(char *buf, int n) {
......
......@@ -6,23 +6,30 @@ extern "C" {
#endif
// Opaque types.
typedef void *imms_similarity_model_t;
typedef void *imms_analyzer_t;
typedef void *imms_features_t;
typedef void *imms_similarity_model_t;
// C wrappers for the analysis/model API.
// Analyze the input stream (given with a file descriptor) and return
// feature data.
imms_features_t imms_analyze(int);
// A StreamAnalyzer analyzes the input stream (passed in buffers of
// arbitrary size by the caller) and returns feature data.
imms_analyzer_t imms_stream_analyzer_new();
void imms_stream_analyzer_process(imms_analyzer_t, char *, int);
imms_features_t imms_stream_analyzer_get_result(imms_analyzer_t);
void imms_stream_analyzer_free(imms_analyzer_t);
// Deserialize feature data.
imms_features_t imms_features_from_data(char *, int);
// Returns the size of the serialized feature data, in bytes.
int imms_features_dump_size();
int imms_features_data_size();
// Serialize feature data into the provided buffer.
void imms_features_dump(imms_features_t, char *, int);
void imms_features_data(imms_features_t, char *, int);
// Free resources associated with feature data.
void imms_features_free(imms_features_t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment