1 | #ifndef _3DV_DISK_WRITER_H
|
---|
2 | #define _3DV_DISK_WRITER_H
|
---|
3 |
|
---|
4 | /* 3dv-client/disk_writer.h
|
---|
5 | *
|
---|
6 | * Copyright (C) 2013 VisLab
|
---|
7 | *
|
---|
8 | * This file is part of lib3dv; you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU Lesser General Public License as published by
|
---|
10 | * the Free Software Foundation; either version 3 of the License, or (at
|
---|
11 | * your option) any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful, but
|
---|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Lesser General Public License
|
---|
19 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "file.h"
|
---|
23 |
|
---|
24 | #include <boost/asio/io_service.hpp>
|
---|
25 | #include <boost/filesystem/path.hpp>
|
---|
26 | #include <boost/shared_ptr.hpp>
|
---|
27 | #include <boost/thread/thread.hpp>
|
---|
28 | #include <boost/filesystem.hpp>
|
---|
29 | #include <iostream>
|
---|
30 | #include <fstream>
|
---|
31 |
|
---|
32 | #include <string>
|
---|
33 | #include <vector>
|
---|
34 |
|
---|
35 | #include <stdint.h>
|
---|
36 |
|
---|
37 | #ifdef ARCHIVE
|
---|
38 | class archive;
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | class disk_writer
|
---|
42 | {
|
---|
43 | public:
|
---|
44 |
|
---|
45 | disk_writer(const std::vector<boost::filesystem::path>& paths, data_file_format::types data_file_format, bool autonumber, device_params params, uint8_t guid_type, uint8_t log_level);
|
---|
46 |
|
---|
47 | #ifdef ARCHIVE
|
---|
48 | disk_writer(const std::vector<boost::filesystem::path>& paths, const std::string& archive_name, archive_file_format::types archive_format, data_file_format::types data_file_format, bool autonumber, device_params params, uint8_t guid_type, uint8_t log_level);
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | void image_callback(boost::shared_ptr<const lib3dv::image> image, uint32_t guid);
|
---|
52 |
|
---|
53 | void terrain_callback(boost::shared_ptr<const lib3dv::terrain> terrain, uint32_t guid);
|
---|
54 |
|
---|
55 | void obstacles_callback(boost::shared_ptr<const std::vector<lib3dv::obstacle> > obstacles, uint32_t guid);
|
---|
56 |
|
---|
57 | void motion_callback(boost::shared_ptr<const lib3dv::motion> pose, uint32_t guid);
|
---|
58 |
|
---|
59 | void classification_callback(boost::shared_ptr<const lib3dv::classification> classification, uint32_t guid);
|
---|
60 |
|
---|
61 | void run();
|
---|
62 |
|
---|
63 | void stop();
|
---|
64 |
|
---|
65 | private:
|
---|
66 |
|
---|
67 | struct disk_queue
|
---|
68 | {
|
---|
69 | disk_queue(const boost::filesystem::path& path, data_file_format::types data_file_format, uint8_t log_level);
|
---|
70 |
|
---|
71 | #ifdef ARCHIVE
|
---|
72 | disk_queue(const boost::filesystem::path& path, const std::string& archive_name, archive_file_format::types archive_format, data_file_format::types data_file_format,device_params params, uint8_t log_level);
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | ~disk_queue();
|
---|
76 |
|
---|
77 | boost::asio::io_service m_io_service;
|
---|
78 | boost::asio::io_service::work* m_io_service_work;
|
---|
79 |
|
---|
80 | boost::filesystem::path m_path;
|
---|
81 | data_file_format::types m_data_file_format;
|
---|
82 | #ifdef ARCHIVE
|
---|
83 | archive* m_archive;
|
---|
84 | #endif
|
---|
85 | uint8_t m_log_level;
|
---|
86 | };
|
---|
87 |
|
---|
88 | bool m_autonumber;
|
---|
89 | uint8_t m_log_level;
|
---|
90 | uint8_t m_guid_type;
|
---|
91 | std::vector<boost::shared_ptr<disk_queue> > m_disk_queues;
|
---|
92 | boost::thread_group m_disk_queue_threads;
|
---|
93 | };
|
---|
94 |
|
---|
95 | #endif
|
---|