Azure-Kinect-Sensor-SDK
Azure-Kinect-Sensor-SDK copied to clipboard
is_valid(), operator bool(), handle() missing on C++ classes
I request boolean tests for validity for k4a::calibration
and k4a::transformation
.
Those tests areoperator bool()
and bool is_valid()
This will align those classes with the already existing validity tests on device
, capture
, and image
; and remove the need for project-specific boilerplate code for users of this SDK.
I also request handle()
added to k4a::transformation
. It is missing as compared to the others that manage handles.
Some discussion points:
- The validity test/condition for each class.
- Consider that
k4a::calibration
has no constructor like the others. Therefore, the in-memory state is different betweenk4a::calibration cali;
andk4a::calibration cali{};
. I lean towards defining ak4a::calibration()
constructor that specifically sets member variables to a known invalid state (rather than leaving them random bits leftover in memory).
Below are pseudocode suggestions.
k4a::calibration
calibration() noexcept : depth_mode(K4A_DEPTH_MODE_OFF), color_resolution(K4A_COLOR_RESOLUTION_OFF) {}
bool is_valid() {
return (depth_mode != K4A_DEPTH_MODE_OFF) || (color_resolution != K4A_COLOR_RESOLUTION_OFF);
}
explicit operator bool() const noexcept {
return is_valid();
}
k4a::transformation
bool is_valid() {
return m_handle != nullptr;
}
explicit operator bool() const noexcept {
return is_valid();
}
k4a_transformation_t handle() const noexcept {
return m_handle;
}