Project import generated by Copybara.
GitOrigin-RevId: 7e1d382a1788ebd8412c5626581b4c4cf2fe75ea
This commit is contained in:
@@ -179,7 +179,9 @@ class Packet {
|
||||
|
||||
// Returns an error if the packet does not contain data of type T.
|
||||
template <typename T>
|
||||
absl::Status ValidateAsType() const;
|
||||
absl::Status ValidateAsType() const {
|
||||
return ValidateAsType(tool::TypeId<T>());
|
||||
}
|
||||
|
||||
// Returns an error if the packet is not an instance of
|
||||
// a protocol buffer message.
|
||||
@@ -218,6 +220,8 @@ class Packet {
|
||||
friend std::shared_ptr<packet_internal::HolderBase>
|
||||
packet_internal::GetHolderShared(Packet&& packet);
|
||||
|
||||
absl::Status ValidateAsType(const tool::TypeInfo& type_info) const;
|
||||
|
||||
std::shared_ptr<packet_internal::HolderBase> holder_;
|
||||
class Timestamp timestamp_;
|
||||
};
|
||||
@@ -770,21 +774,6 @@ inline const T& Packet::Get() const {
|
||||
return holder->data();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
absl::Status Packet::ValidateAsType() const {
|
||||
if (ABSL_PREDICT_FALSE(IsEmpty())) {
|
||||
return absl::InternalError(absl::StrCat(
|
||||
"Expected a Packet of type: ", MediaPipeTypeStringOrDemangled<T>(),
|
||||
", but received an empty Packet."));
|
||||
}
|
||||
if (ABSL_PREDICT_FALSE(holder_->As<T>() == nullptr)) {
|
||||
return absl::InvalidArgumentError(absl::StrCat(
|
||||
"The Packet stores \"", holder_->DebugTypeName(), "\", but \"",
|
||||
MediaPipeTypeStringOrDemangled<T>(), "\" was requested."));
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
inline Timestamp Packet::Timestamp() const { return timestamp_; }
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user