Skip to content
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

Minor refactoring to keep eCAL::hdf5 like it was before hdf5 restructuring #1235

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ endif()
# ecal hdf5 support
# --------------------------------------------------------
if(HAS_HDF5)
add_subdirectory(contrib/measurement/hdf5)
add_subdirectory(contrib/ecalhdf5)
add_subdirectory(contrib/message)
endif()
Expand Down
2 changes: 1 addition & 1 deletion app/meas_cutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} yaml-cpp
tclap::tclap
eCAL::ecal-utils
eCAL::hdf5
eCAL::measurement_hdf5
Threads::Threads)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
Expand Down
4 changes: 2 additions & 2 deletions app/meas_cutter/src/measurement_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/

#include "measurement_exporter.h"
#include <ecalhdf5/eh5_writer.h>
#include <ecal/measurement/hdf5/writer.h>

MeasurementExporter::MeasurementExporter():
_writer(std::make_unique<eCAL::eh5::Writer>())
_writer(std::make_unique<eCAL::measurement::hdf5::Writer>())
{
}

Expand Down
4 changes: 2 additions & 2 deletions app/meas_cutter/src/measurement_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/

#include "measurement_importer.h"
#include <ecalhdf5/eh5_reader.h>
#include <ecal/measurement/hdf5/reader.h>

MeasurementImporter::MeasurementImporter() :
_reader(std::make_unique<eCAL::eh5::Reader>()),
_reader(std::make_unique<eCAL::measurement::hdf5::Reader>()),
_current_opened_channel_data()
{
}
Expand Down
3 changes: 2 additions & 1 deletion app/meas_cutter/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
#define YAML_CPP_STATIC_DEFINE
#include "yaml-cpp/yaml.h"

#include <ecalhdf5/eh5_meas.h>
#include <ecal_utils/str_convert.h>
#include <ecal_utils/filesystem.h>

#include "logger.h"

#include <ecal/measurement/base/types.h>

namespace eCALMeasCutterUtils
{
typedef long long Timestamp;
Expand Down
2 changes: 1 addition & 1 deletion app/play/play_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
eCAL::core
eCAL::app_pb
eCAL::ecaltime_pb
eCAL::hdf5
eCAL::measurement_hdf5
)

target_link_libraries(${PROJECT_NAME} PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions app/play/play_core/src/ecal_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "ecal_play_logger.h"
#include "play_thread.h"
#include "ecalhdf5/eh5_reader.h"
#include <ecal/measurement/hdf5/reader.h>

#include <ecal_utils/string.h>
#include <ecal_utils/filesystem.h>
Expand Down Expand Up @@ -58,7 +58,7 @@ bool EcalPlay::LoadMeasurement(const std::string& path)
{
EcalPlayLogger::Instance()->info("Loading measurement...");

std::shared_ptr<eCAL::measurement::base::Reader> measurement(std::make_shared<eCAL::eh5::Reader>());
std::shared_ptr<eCAL::measurement::base::Reader> measurement(std::make_shared<eCAL::measurement::hdf5::Reader>());

std::string meas_dir; // The directory of the measurement
std::string path_to_load; // The actual path we load the measurement from. May be a directory or a .hdf5 file
Expand Down
2 changes: 1 addition & 1 deletion app/play/play_core/src/measurement_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include "measurement_container.h"
#include <ecalhdf5/eh5_meas.h>
#include <ecal/measurement/hdf5/reader.h>

#include <algorithm>
#include <math.h>
Expand Down
1 change: 0 additions & 1 deletion app/play/play_core/src/play_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "ecal_play_command.h"
#include "stop_watch.h"

#include <ecalhdf5/eh5_meas.h>
#include <ecal/ecal.h>

#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_client_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ target_link_libraries(${PROJECT_NAME}
eCAL::core_pb
eCAL::app_pb
PRIVATE
eCAL::hdf5
eCAL::measurement_hdf5
ThreadingUtils
Threads::Threads
eCAL::ecal-utils
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include "hdf5_writer_thread.h"
#include <ecalhdf5/eh5_writer.h>
#include <ecal/measurement/hdf5/writer.h>

#include "rec_client_core/ecal_rec_logger.h"

Expand All @@ -42,7 +42,7 @@ namespace eCAL
, new_topic_info_map_available_(true)
, flushing_ (false)
{
hdf5_writer_ = std::make_unique<eCAL::eh5::Writer>();
hdf5_writer_ = std::make_unique<eCAL::measurement::hdf5::Writer>();
}

Hdf5WriterThread::~Hdf5WriterThread()
Expand Down
9 changes: 2 additions & 7 deletions contrib/ecalhdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,9 @@ set(ecalhdf5_src
)

set(ecalhdf5_header_base
include/ecal/measurement/imeasurement.h
include/ecal/measurement/measurement.h
include/ecal/measurement/omeasurement.h
include/ecalhdf5/eh5_defs.h
include/ecalhdf5/eh5_meas.h
include/ecalhdf5/eh5_reader.h
include/ecalhdf5/eh5_types.h
include/ecalhdf5/eh5_writer.h
)

ecal_add_library(${PROJECT_NAME} ${ecalhdf5_src} ${ecalhdf5_header_base})
Expand All @@ -79,8 +74,8 @@ target_compile_options(${PROJECT_NAME}
$<$<CXX_COMPILER_ID:GNU>:-Wextra>)

target_link_libraries(${PROJECT_NAME}
PUBLIC
eCAL::message
PUBLIC
eCAL::measurement_base
PRIVATE
eCAL::ecal-utils
)
Expand Down
58 changes: 31 additions & 27 deletions contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <memory>

#include "eh5_types.h"
#include <ecal/measurement/base/measurement.h>

namespace eCAL
{
Expand All @@ -41,7 +40,7 @@ namespace eCAL
/**
* @brief eCAL HDF5 measurement API
**/
class HDF5Meas : public eCAL::measurement::base::Measurement
class HDF5Meas
{
public:
/**
Expand All @@ -61,7 +60,7 @@ namespace eCAL
/**
* @brief Destructor
**/
~HDF5Meas() override;
~HDF5Meas();

/**
* @brief Copy constructor deleted
Expand Down Expand Up @@ -106,42 +105,42 @@ namespace eCAL
* @return true if output (eAccessType::CREATE) measurement directory structure can be accessed/created, false otherwise.
* true if input (eAccessType::RDONLY) measurement/file path was opened, false otherwise.
**/
bool Open(const std::string& path, measurement::base::AccessType access = measurement::base::AccessType::RDONLY) override;
bool Open(const std::string& path, measurement::base::AccessType access = measurement::base::AccessType::RDONLY);

/**
* @brief Close file
*
* @return true if succeeds, false if it fails
**/
bool Close() override;
bool Close();

/**
* @brief Checks if file/measurement is ok
*
* @return true if meas can be opened(read) or location is accessible(write), false otherwise
**/
bool IsOk() const override;
bool IsOk() const;

/**
* @brief Get the File Type Version of the current opened file
*
* @return file version
**/
std::string GetFileVersion() const override;
std::string GetFileVersion() const;

/**
* @brief Gets maximum allowed size for an individual file
*
* @return maximum size in MB
**/
size_t GetMaxSizePerFile() const override;
size_t GetMaxSizePerFile() const;

/**
* @brief Sets maximum allowed size for an individual file
*
* @param size maximum size in MB
**/
void SetMaxSizePerFile(size_t size) override;
void SetMaxSizePerFile(size_t size);

/**
* @brief Whether each Channel shall be writte in its own file
Expand All @@ -152,7 +151,7 @@ namespace eCAL
*
* @return true, if one file per channel is enabled
*/
bool IsOneFilePerChannelEnabled() const override;
bool IsOneFilePerChannelEnabled() const;

/**
* @brief Enable / disable the creation of one individual file per channel
Expand All @@ -163,14 +162,14 @@ namespace eCAL
*
* @param enabled Whether one file shall be created per channel
*/
void SetOneFilePerChannelEnabled(bool enabled) override;
void SetOneFilePerChannelEnabled(bool enabled);

/**
* @brief Get the available channel names of the current opened file / measurement
*
* @return channel names
**/
std::set<std::string> GetChannelNames() const override;
std::set<std::string> GetChannelNames() const;

/**
* @brief Check if channel exists in measurement
Expand All @@ -179,7 +178,7 @@ namespace eCAL
*
* @return true if exists, false otherwise
**/
bool HasChannel(const std::string& channel_name) const override;
bool HasChannel(const std::string& channel_name) const;

/**
* @brief Get the channel description for the given channel
Expand All @@ -188,15 +187,15 @@ namespace eCAL
*
* @return channel description
**/
std::string GetChannelDescription(const std::string& channel_name) const override;
std::string GetChannelDescription(const std::string& channel_name) const;

/**
* @brief Set description of the given channel
*
* @param channel_name channel name
* @param description description of the channel
**/
void SetChannelDescription(const std::string& channel_name, const std::string& description) override;
void SetChannelDescription(const std::string& channel_name, const std::string& description);

/**
* @brief Gets the channel type of the given channel
Expand All @@ -205,15 +204,15 @@ namespace eCAL
*
* @return channel type
**/
std::string GetChannelType(const std::string& channel_name) const override;
std::string GetChannelType(const std::string& channel_name) const;

/**
* @brief Set type of the given channel
*
* @param channel_name channel name
* @param type type of the channel
**/
void SetChannelType(const std::string& channel_name, const std::string& type) override;
void SetChannelType(const std::string& channel_name, const std::string& type);

/**
* @brief Gets minimum timestamp for specified channel
Expand All @@ -222,7 +221,7 @@ namespace eCAL
*
* @return minimum timestamp value
**/
long long GetMinTimestamp(const std::string& channel_name) const override;
long long GetMinTimestamp(const std::string& channel_name) const;

/**
* @brief Gets maximum timestamp for specified channel
Expand All @@ -231,7 +230,7 @@ namespace eCAL
*
* @return maximum timestamp value
**/
long long GetMaxTimestamp(const std::string& channel_name) const override;
long long GetMaxTimestamp(const std::string& channel_name) const;

/**
* @brief Gets the header info for all data entries for the given channel
Expand All @@ -242,7 +241,7 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
bool GetEntriesInfo(const std::string& channel_name, measurement::base::EntryInfoSet& entries) const override;
bool GetEntriesInfo(const std::string& channel_name, measurement::base::EntryInfoSet& entries) const;

/**
* @brief Gets the header info for data entries for the given channel included in given time range (begin->end)
Expand All @@ -255,7 +254,7 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, measurement::base::EntryInfoSet& entries) const override;
bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, measurement::base::EntryInfoSet& entries) const;

/**
* @brief Gets data size of a specific entry
Expand All @@ -265,7 +264,7 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
bool GetEntryDataSize(long long entry_id, size_t& size) const override;
bool GetEntryDataSize(long long entry_id, size_t& size) const;

/**
* @brief Gets data from a specific entry
Expand All @@ -275,14 +274,14 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
bool GetEntryData(long long entry_id, void* data) const override;
bool GetEntryData(long long entry_id, void* data) const;

/**
* @brief Set measurement file base name (desired name for the actual hdf5 files that will be created)
*
* @param base_name Name of the hdf5 files that will be created.
**/
void SetFileBaseName(const std::string& base_name) override;
void SetFileBaseName(const std::string& base_name);

/**
* @brief Add entry to file
Expand All @@ -297,19 +296,24 @@ namespace eCAL
*
* @return true if succeeds, false if it fails
**/
bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override;
bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock);

/**
* @brief Callback function type for pre file split notification
**/
typedef std::function<void(void)> CallbackFunction;

/**
* @brief Connect callback for pre file split notification
*
* @param cb callback function
**/
void ConnectPreSplitCallback(CallbackFunction cb) override;
void ConnectPreSplitCallback(CallbackFunction cb);

/**
* @brief Disconnect pre file split callback
**/
void DisconnectPreSplitCallback() override;
void DisconnectPreSplitCallback();

private:
std::unique_ptr<HDF5MeasImpl> hdf_meas_impl_;
Expand Down
Loading
Loading