Project import generated by Copybara.

GitOrigin-RevId: d38dc934bcd08e03061c37d26d36da216456d10d
This commit is contained in:
MediaPipe Team
2020-06-12 15:44:38 -04:00
committed by chuoling
parent 59ee17c1f3
commit 67bd8a2bf0
27 changed files with 252 additions and 97 deletions
+4 -4
View File
@@ -158,11 +158,11 @@ TEST(CalculatorTest, SourceProcessOrder) {
// Tests registration of a calculator within a namespace.
// DeadEndCalculator is registered in namespace "mediapipe::test_ns".
TEST(CalculatorTest, CreateByName) {
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
"mediapipe.test_ns.DeadEndCalculator"));
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
"", "mediapipe.test_ns.DeadEndCalculator"));
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
".mediapipe.test_ns.DeadEndCalculator"));
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
"", ".mediapipe.test_ns.DeadEndCalculator"));
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
"alpha", ".mediapipe.test_ns.DeadEndCalculator"));
+8 -4
View File
@@ -322,16 +322,20 @@ class GlobalFactoryRegistry {
return functions()->Register(name, std::move(func));
}
// Same as CreateByNameInNamespace but without a namespace.
// Invokes the specified factory function and returns the result.
// If using namespaces with this registry, the variant with a namespace
// argument should be used.
template <typename... Args2>
static typename Functions::ReturnType CreateByName(const std::string& name,
Args2&&... args) {
return CreateByNameInNamespace("", name, std::forward<Args2>(args)...);
return functions()->Invoke(name, std::forward<Args2>(args)...);
}
// Same as IsRegistered(ns, name) but without a namespace.
// Returns true if the specified factory function is available.
// If using namespaces with this registry, the variant with a namespace
// argument should be used.
static bool IsRegistered(const std::string& name) {
return functions()->IsRegistered("", name);
return functions()->IsRegistered(name);
}
static std::unordered_set<std::string> GetRegisteredNames() {