Project import generated by Copybara.
GitOrigin-RevId: d38dc934bcd08e03061c37d26d36da216456d10d
This commit is contained in:
@@ -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"));
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user