Skip to content

Commit

Permalink
GetChannelDataTypeInformation and SetChannelDataTypeInformation in al…
Browse files Browse the repository at this point in the history
…l of eh5.
  • Loading branch information
KerstinKeller committed Jan 30, 2024
1 parent 57839cc commit 9ad7177
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 299 deletions.
22 changes: 21 additions & 1 deletion contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ namespace eCAL
*
* @return channel description
**/
[[deprecated("Please use GetChannelDataTypeInformation instead")]]
std::string GetChannelDescription(const std::string& channel_name) const;

/**
Expand All @@ -195,6 +196,7 @@ namespace eCAL
* @param channel_name channel name
* @param description description of the channel
**/
[[deprecated("Please use SetChannelDataTypeInformation instead")]]
void SetChannelDescription(const std::string& channel_name, const std::string& description);

/**
Expand All @@ -204,6 +206,7 @@ namespace eCAL
*
* @return channel type
**/
[[deprecated("Please use GetChannelDataTypeInformation instead")]]
std::string GetChannelType(const std::string& channel_name) const;

/**
Expand All @@ -212,10 +215,27 @@ namespace eCAL
* @param channel_name channel name
* @param type type of the channel
**/
[[deprecated("Please use SetChannelDataTypeInformation instead")]]
void SetChannelType(const std::string& channel_name, const std::string& type);

/**
* @brief Get data type information of the given channel
*
* @param channel_name channel name
*
* @return channel type
**/
DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const;


/**
* @brief Set data type information of the given channel
*
* @param channel_name channel name
* @param info datatype info of the channel
*
* @return channel type
**/
void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info);

/**
* @brief Gets minimum timestamp for specified channel
Expand Down
2 changes: 2 additions & 0 deletions contrib/ecalhdf5/include/ecalhdf5/eh5_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace eCAL
using eAccessType = eCAL::experimental::measurement::base::AccessType;
using eCAL::experimental::measurement::base::RDONLY;
using eCAL::experimental::measurement::base::CREATE;

using eCAL::experimental::measurement::base::DataTypeInformation;
//!< @endcond
} // namespace eh5
} // namespace eCAL
29 changes: 5 additions & 24 deletions contrib/ecalhdf5/src/eh5_meas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,41 +233,22 @@ bool eCAL::eh5::HDF5Meas::HasChannel(const std::string& channel_name) const
return ret_val;
}

std::string eCAL::eh5::HDF5Meas::GetChannelDescription(const std::string& channel_name) const
eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5Meas::GetChannelDataTypeInformation(const std::string& channel_name) const
{
std::string ret_val;
if (hdf_meas_impl_)
{
ret_val = hdf_meas_impl_->GetChannelDescription(GetEscapedTopicname(channel_name));
}

return ret_val;
}

void eCAL::eh5::HDF5Meas::SetChannelDescription(const std::string& channel_name, const std::string& description)
{
if (hdf_meas_impl_)
{
hdf_meas_impl_->SetChannelDescription(GetEscapedTopicname(channel_name), description);
}
}

std::string eCAL::eh5::HDF5Meas::GetChannelType(const std::string& channel_name) const
{
std::string ret_val;
eCAL::eh5::DataTypeInformation ret_val;
if (hdf_meas_impl_)
{
ret_val = hdf_meas_impl_->GetChannelType(GetEscapedTopicname(channel_name));
ret_val = hdf_meas_impl_->GetChannelDataTypeInformation(GetEscapedTopicname(channel_name));
}

return ret_val;
}

void eCAL::eh5::HDF5Meas::SetChannelType(const std::string& channel_name, const std::string& type)
void eCAL::eh5::HDF5Meas::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info)
{
if (hdf_meas_impl_)
{
hdf_meas_impl_->SetChannelType(GetEscapedTopicname(channel_name), type);
hdf_meas_impl_->SetChannelDataTypeInformation(GetEscapedTopicname(channel_name), info);
}
}

Expand Down
39 changes: 10 additions & 29 deletions contrib/ecalhdf5/src/eh5_meas_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,44 +196,24 @@ bool eCAL::eh5::HDF5MeasDir::HasChannel(const std::string& channel_name) const
return channels_info_.count(channel_name) != 0;
}

std::string eCAL::eh5::HDF5MeasDir::GetChannelDescription(const std::string& channel_name) const
eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasDir::GetChannelDataTypeInformation(const std::string& channel_name) const
{
std::string ret_val;
eCAL::eh5::DataTypeInformation ret_val;

const auto& found = channels_info_.find(channel_name);

if (found != channels_info_.end())
{
ret_val = found->second.description;
ret_val = found->second.info;
}
return ret_val;
}

void eCAL::eh5::HDF5MeasDir::SetChannelDescription(const std::string& channel_name, const std::string& description)
void eCAL::eh5::HDF5MeasDir::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info)
{
// Get an existing writer or create a new one
auto file_writer_it = GetWriter(channel_name);
file_writer_it->second->SetChannelDescription(channel_name, description);
}

std::string eCAL::eh5::HDF5MeasDir::GetChannelType(const std::string& channel_name) const
{
std::string ret_val;

const auto& found = channels_info_.find(channel_name);

if (found != channels_info_.end())
{
ret_val = found->second.type;
}
return ret_val;
}

void eCAL::eh5::HDF5MeasDir::SetChannelType(const std::string& channel_name, const std::string& type)
{
// Get an existing writer or create a new one
auto file_writer_it = GetWriter(channel_name);
file_writer_it->second->SetChannelType(channel_name, type);
file_writer_it->second->SetChannelDataTypeInformation(channel_name, info);
}

long long eCAL::eh5::HDF5MeasDir::GetMinTimestamp(const std::string& channel_name) const
Expand Down Expand Up @@ -457,17 +437,18 @@ bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, eAccessType access
for (const auto& channel : channels)
{
auto escaped_name = GetEscapedTopicname(channel);
auto description = reader->GetChannelDescription(channel);
auto info = reader->GetChannelDataTypeInformation(channel);

// What exactly does that do? what are we overwriting?
if (channels_info_.find(escaped_name) == channels_info_.end())
{
channels_info_[escaped_name] = ChannelInfo(reader->GetChannelType(channel), description);
channels_info_[escaped_name] = ChannelInfo(info);
}
else
{
if (!description.empty())
if (!info.descriptor.empty())
{
channels_info_[escaped_name].description = description;
channels_info_[escaped_name].info.descriptor = info.descriptor;
}
}

Expand Down
49 changes: 16 additions & 33 deletions contrib/ecalhdf5/src/eh5_meas_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,38 +143,23 @@ namespace eCAL
bool HasChannel(const std::string& channel_name) const override;

/**
* @brief Get the channel description for the given channel
*
* @param channel_name channel name
*
* @return channel description
**/
std::string GetChannelDescription(const std::string& channel_name) const override;

/**
* @brief Set description of the given channel
*
* @param channel_name channel name
* @param description description of the channel
* @brief Get data type information of the given channel
*
* @param channel_name channel name
*
* @return channel type
**/
void SetChannelDescription(const std::string& channel_name, const std::string& description) override;
DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override;

/**
* @brief Gets the channel type of the given channel
*
* @param channel_name channel name
*
* @return channel type
**/
std::string GetChannelType(const std::string& channel_name) const override;

/**
* @brief Set type of the given channel
*
* @param channel_name channel name
* @param type type of the channel
* @brief Set data type information of the given channel
*
* @param channel_name channel name
* @param info datatype info of the channel
*
* @return channel type
**/
void SetChannelType(const std::string& channel_name, const std::string& type) override;
void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) override;

/**
* @brief Gets minimum timestamp for specified channel
Expand Down Expand Up @@ -280,14 +265,12 @@ namespace eCAL
protected:
struct ChannelInfo
{
std::string type;
std::string description;
DataTypeInformation info;
std::list<const eCAL::eh5::HDF5Meas*> files;

ChannelInfo() = default;
ChannelInfo(const std::string& type_, const std::string& description_)
: type(type_)
, description(description_)
ChannelInfo(const DataTypeInformation& info_)
: info(info_)
{}
};

Expand Down
24 changes: 7 additions & 17 deletions contrib/ecalhdf5/src/eh5_meas_file_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,32 +164,22 @@ bool eCAL::eh5::HDF5MeasFileV1::HasChannel(const std::string& channel_name) cons
return std::find(channels.cbegin(), channels.cend(), channel_name) != channels.end();
}

std::string eCAL::eh5::HDF5MeasFileV1::GetChannelDescription(const std::string& channel_name) const
eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV1::GetChannelDataTypeInformation(const std::string& channel_name) const
{
std::string description;
std::string type;

if (EcalUtils::String::Icompare(channel_name, channel_name_))
GetAttributeValue(file_id_, kChnDescAttrTitle, description);

return description;
}

void eCAL::eh5::HDF5MeasFileV1::SetChannelDescription(const std::string& /*channel_name*/, const std::string& /*description*/)
{
ReportUnsupportedAction();
}
GetAttributeValue(file_id_, kChnTypeAttrTitle, type);

std::string eCAL::eh5::HDF5MeasFileV1::GetChannelType(const std::string& channel_name) const
{
std::string type;
std::string description;

if (EcalUtils::String::Icompare(channel_name, channel_name_))
GetAttributeValue(file_id_, kChnTypeAttrTitle, type);
GetAttributeValue(file_id_, kChnDescAttrTitle, description);

return type;
return CreateInfo(type, description);
}

void eCAL::eh5::HDF5MeasFileV1::SetChannelType(const std::string& /*channel_name*/, const std::string& /*type*/)
void eCAL::eh5::HDF5MeasFileV1::SetChannelDataTypeInformation(const std::string& /*channel_name*/, const eCAL::eh5::DataTypeInformation& /*info*/)
{
ReportUnsupportedAction();
}
Expand Down
41 changes: 13 additions & 28 deletions contrib/ecalhdf5/src/eh5_meas_file_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,38 +135,23 @@ namespace eCAL
bool HasChannel(const std::string& channel_name) const override;

/**
* @brief Get the channel description for the given channel
*
* @param channel_name channel name
*
* @return channel description
**/
std::string GetChannelDescription(const std::string& channel_name) const override;

/**
* @brief Set description of the given channel
*
* @param channel_name channel name
* @param description description of the channel
* @brief Get data type information of the given channel
*
* @param channel_name channel name
*
* @return channel type
**/
void SetChannelDescription(const std::string& channel_name, const std::string& description) override;
DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override;

/**
* @brief Gets the channel type of the given channel
*
* @param channel_name channel name
*
* @return channel type
**/
std::string GetChannelType(const std::string& channel_name) const override;

/**
* @brief Set type of the given channel
*
* @param channel_name channel name
* @param type type of the channel
* @brief Set data type information of the given channel
*
* @param channel_name channel name
* @param info datatype info of the channel
*
* @return channel type
**/
void SetChannelType(const std::string& channel_name, const std::string& type) override;
void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) override;

/**
* @brief Gets minimum timestamp for specified channel
Expand Down
28 changes: 5 additions & 23 deletions contrib/ecalhdf5/src/eh5_meas_file_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,29 @@ bool eCAL::eh5::HDF5MeasFileV2::HasChannel(const std::string& channel_name) cons
return std::find(channels.cbegin(), channels.cend(), channel_name) != channels.end();
}

std::string eCAL::eh5::HDF5MeasFileV2::GetChannelDescription(const std::string& channel_name) const
eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV2::GetChannelDataTypeInformation(const std::string& channel_name) const
{
std::string type;
std::string description;

if (this->IsOk())
{
auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT);
if (dataset_id >= 0)
{
GetAttributeValue(dataset_id, kChnTypeAttrTitle, type);
GetAttributeValue(dataset_id, kChnDescAttrTitle, description);
H5Dclose(dataset_id);
}
}

return description;
return CreateInfo(type, description);
}

void eCAL::eh5::HDF5MeasFileV2::SetChannelDescription(const std::string& /*channel_name*/, const std::string& /*description*/)
void eCAL::eh5::HDF5MeasFileV2::SetChannelDataTypeInformation(const std::string& /*channel_name*/, const eCAL::eh5::DataTypeInformation& /*info*/)
{
}

std::string eCAL::eh5::HDF5MeasFileV2::GetChannelType(const std::string& channel_name) const
{
std::string type;

if (this->IsOk())
{
auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT);
if (dataset_id >= 0)
{
GetAttributeValue(dataset_id, kChnTypeAttrTitle, type);
H5Dclose(dataset_id);
}
}

return type;
}

void eCAL::eh5::HDF5MeasFileV2::SetChannelType(const std::string& /*channel_name*/, const std::string& /*type*/)
{
}

long long eCAL::eh5::HDF5MeasFileV2::GetMinTimestamp(const std::string& channel_name) const
{
Expand Down
Loading

0 comments on commit 9ad7177

Please sign in to comment.