Project import generated by Copybara.

GitOrigin-RevId: 0f2489d226f1e2a5d718a8b9efe5e8198ba4ab3b
This commit is contained in:
MediaPipe Team
2022-06-29 18:45:02 +00:00
committed by Sebastian Schmidt
parent c688862570
commit 63e679d99c
11 changed files with 27 additions and 16 deletions
+1
View File
@@ -401,6 +401,7 @@ cc_library(
hdrs = ["streaming_buffer.h"],
deps = [
"//mediapipe/framework/port:logging",
"//mediapipe/framework/tool:type_util",
"@com_google_absl//absl/container:node_hash_map",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:any",
+4 -10
View File
@@ -25,6 +25,7 @@
#include "absl/container/node_hash_map.h"
#include "absl/types/any.h"
#include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/tool/type_util.h"
namespace mediapipe {
@@ -128,14 +129,6 @@ TaggedType TaggedPointerType(const std::string& tag);
template <class T>
std::unique_ptr<T> MakeUnique(T* ptr);
template <typename Type>
inline size_t TypeId() {
static_assert(sizeof(char*) <= sizeof(size_t),
"ptr size too large for size_t");
static char dummy_var;
return reinterpret_cast<size_t>(&dummy_var);
}
// Note: If any of the function below are called with a tag not registered by
// the constructor, the function will fail with CHECK.
// Also, if any of the functions below is called with an existing tag but
@@ -318,7 +311,8 @@ class StreamingBuffer {
//// Implementation details.
template <class T>
TaggedType TaggedPointerType(const std::string& tag) {
return std::make_pair(tag, TypeId<StreamingBuffer::PointerType<T>>());
return std::make_pair(tag,
kTypeId<StreamingBuffer::PointerType<T>>.hash_code());
}
template <class T>
@@ -330,7 +324,7 @@ template <class T>
void StreamingBuffer::AddDatum(const std::string& tag,
std::unique_ptr<T> pointer) {
CHECK(HasTag(tag));
CHECK_EQ(data_config_[tag], TypeId<PointerType<T>>());
CHECK_EQ(data_config_[tag], kTypeId<PointerType<T>>.hash_code());
auto& buffer = data_[tag];
absl::any packet(PointerType<T>(CreatePointer(pointer.release())));
buffer.push_back(packet);