diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-19 21:39:28 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-19 21:49:03 +0200 |
commit | ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e (patch) | |
tree | 6b86d64d03dfda4efc4a41e5814a229507289cb9 /apps/sample-select.h | |
parent | 0374af511d7efdb856af372f126e66e5a78841d7 (diff) | |
download | ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.gz ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.bz2 ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.tar.xz ble-toys-ae2d05eee4ffcec4c0611d907779ce8ef61d3a6e.zip |
o Going back to a bunch of cpp files instead of launcher+bunch of header files. This ends up with an easier build file and faster builds with CMake's "OBJECT" library type.
Diffstat (limited to 'apps/sample-select.h')
-rw-r--r-- | apps/sample-select.h | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/apps/sample-select.h b/apps/sample-select.h deleted file mode 100644 index 8ae5cc3..0000000 --- a/apps/sample-select.h +++ /dev/null @@ -1,119 +0,0 @@ -#include "trygvis/sensor.h" -#include "apps.h" -#include <boost/tokenizer.hpp> - -namespace trygvis { -namespace apps { - -using namespace std; -using namespace trygvis::apps; -using namespace trygvis::sensor; -using boost::tokenizer; -namespace po = boost::program_options; - -class sample_select : public app { -private: - string fields; - -public: - sample_select() : app("sample-select") { - } - - ~sample_select() = default; - - void add_options(po::options_description_easy_init &options) override { - options("fields", po::value<string>(&fields)->required()); - } - - int main(app_execution &execution) override { - tokenizer<> tok(fields); - - for (tokenizer<>::iterator beg = tok.begin(); beg != tok.end(); ++beg) { - cout << *beg << "\n"; - } - - /* - KeyDictionary dict; - - relative_key = dict.indexOf(relative_name); - - auto sample_buffer = make_shared<VectorSampleOutputStream>(); - auto parser = open_sample_input_stream(sample_buffer, dict); - while (!input.fail()) { - char buffer[buffer_size]; - input.read(buffer, buffer_size); - auto count = (size_t) input.gcount(); - - cerr << "eof? " << input.eof() << endl; - mutable_buffers_1 b = boost::asio::buffer(buffer, count); - parser->process(b); - } - - if (sample_buffer->samples.empty()) { - cerr << "Could not find any samples" << endl; - return EXIT_FAILURE; - } - - time_t end_time = buf.st_mtim.tv_sec; - - SampleRecord sample = *--sample_buffer->samples.end(); - - o<string> s = sample.at(relative_key); - if (!s) { - cerr << "Missing key '" + relative_name + "'." << endl; - cerr << "Found " << sample_buffer->samples.size() << " samples." << endl; - cerr << "keys: " << sample.to_string() << endl; - return EXIT_FAILURE; - } - - long relative; - try { - relative = boost::lexical_cast<long>(s.get()); - } catch (const boost::bad_lexical_cast &e) { - cerr << "Bad integer value '" + s.get() + "'." << endl; - return EXIT_FAILURE; - } - - if (relative_resolution == time_resolution::MILLISECONDS) { - relative /= 1000; - } - - time_t start_time = end_time - relative; - cerr << "end_time " << end_time << endl; - cerr << "relative " << relative << endl; - cerr << "start_time " << start_time << endl; - - // Restart the reading of the input file and add the adjusted timestamp - input.clear(ios::eofbit); - input.seekg(0); - if(input.fail()) { - cerr << "Coult not seek input file" << endl; - return EXIT_FAILURE; - } - - vector<sample_output_stream_option*> options = {}; - unique_ptr<SampleOutputStream> unique_output_stream = open_sample_output_stream(shared_ptr<ostream>(&cout, - noop_deleter), dict, parser->type(), options); - shared_ptr<SampleOutputStream> output_stream{std::move(unique_output_stream)}; - shared_ptr<SampleOutputStream> p = make_shared<TimestampFixingSampleOutputStream>(output_stream, dict, - timestamp_name, relative_name, relative_resolution, start_time); - parser = open_sample_stream_parser(p, dict, parser->type()); - - int recordCount = 0; - - while (!input.eof()) { - char buffer[buffer_size]; - input.read(buffer, buffer_size); - size_t gcount = (size_t)input.gcount(); - - recordCount++; - - mutable_buffers_1 b = boost::asio::buffer(buffer, gcount); - parser->process(b); - } - */ - return EXIT_SUCCESS; - }; -}; -} -} |