Started refactoring of WriterManager

This commit is contained in:
2019-03-29 16:47:00 +01:00
parent 3869f27972
commit e6d4f0fa04
2 changed files with 12 additions and 22 deletions
+5 -11
View File
@@ -48,15 +48,14 @@ void writer_utils::create_destination_folder(const string& output_file)
}
}
WriterManager::WriterManager(const unordered_map<string, DATA_TYPE>& parameters_type,
const string& output_file, uint64_t n_frames):
parameters_type(parameters_type), output_file(output_file), n_frames(n_frames),
running_flag(true), killed_flag(false), n_received_frames(0), n_written_frames(0), n_lost_frames(0)
WriterManager::WriterManager(const unordered_map<string, DATA_TYPE>& parameters_type):
parameters_type(parameters_type), running_flag(true), killed_flag(false),
n_received_frames(0), n_written_frames(0), n_lost_frames(0)
{
#ifdef DEBUG_OUTPUT
using namespace date;
cout << "[" << std::chrono::system_clock::now() << "]";
cout << "[WriterManager::WriterManager] Writer manager for n_frames " << n_frames << endl;
cout << "[WriterManager::WriterManager] Writer manager initialized." << endl;
#endif
}
@@ -99,11 +98,6 @@ string WriterManager::get_status()
}
}
string WriterManager::get_output_file() const
{
return output_file;
}
unordered_map<string, uint64_t> WriterManager::get_statistics() const
{
unordered_map<string, uint64_t> result = {{"n_received_frames", n_received_frames.load()},
@@ -207,4 +201,4 @@ bool WriterManager::are_all_parameters_set()
size_t WriterManager::get_n_frames()
{
return n_frames;
}
}
+7 -11
View File
@@ -21,12 +21,9 @@ class WriterManager
{
std::unordered_map<std::string, boost::any> parameters = {};
std::mutex parameters_mutex;
// Initialize in constructor.
const std::unordered_map<std::string, DATA_TYPE>& parameters_type;
std::string output_file;
size_t n_frames;
std::atomic_bool running_flag;
std::atomic_bool killed_flag;
std::atomic<uint64_t> n_received_frames;
@@ -34,27 +31,26 @@ class WriterManager
std::atomic<uint64_t> n_lost_frames;
public:
WriterManager(const std::unordered_map<std::string, DATA_TYPE>& parameters_type, const std::string& output_file, uint64_t n_frames=0);
WriterManager(const std::unordered_map<std::string, DATA_TYPE>& parameters_type);
virtual ~WriterManager();
void start(const std::unordered_map<std::string, boost:any>& parameters);
const std::unordered_map<std::string, DATA_TYPE>& get_parameters_type() const;
void stop();
void kill();
std::string get_status();
std::unordered_map<std::string, uint64_t> get_statistics() const;
bool is_running();
bool is_killed() const;
std::string get_status();
bool are_all_parameters_set();
std::string get_output_file() const;
const std::unordered_map<std::string, DATA_TYPE>& get_parameters_type() const;
std::unordered_map<std::string, boost::any> get_parameters();
void set_parameters(const std::unordered_map<std::string, boost::any>& new_parameters);
std::unordered_map<std::string, uint64_t> get_statistics() const;
void received_frame(size_t frame_index);
void written_frame(size_t frame_index);
void lost_frame(size_t frame_index);
size_t get_n_frames();
};
#endif
#endif