diff options
author | fyodor <fyodor@yandex-team.ru> | 2022-02-10 16:50:11 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:11 +0300 |
commit | f96c49839404784ec306cf2b5523a240c63f8eea (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | c8229369090a90a5c969ed7d86afc9bdf2819e34 (diff) | |
download | ydb-f96c49839404784ec306cf2b5523a240c63f8eea.tar.gz |
Restoring authorship annotation for <fyodor@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/object_factory/object_factory.h | 4 | ||||
-rw-r--r-- | library/cpp/object_factory/object_factory_ut.cpp | 32 | ||||
-rw-r--r-- | util/system/shmat.cpp | 2 |
3 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 796424d131..96cc11bcfd 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -57,7 +57,7 @@ namespace NObjectFactory { void Register(const TKey& key, IFactoryObjectCreator<TProduct, TArgs...>* creator) { if (!creator) ythrow yexception() << "Please specify non-null creator for " << key; - + TWriteGuard guard(CreatorsLock); if (!Creators.insert(typename ICreators::value_type(key, creator)).second) ythrow yexception() << "Product with key " << key << " already registered"; @@ -187,7 +187,7 @@ namespace NObjectFactory { IFactoryObjectCreator<TProduct, TArgs...>* creator = IObjectFactory<TProduct, TKey, TArgs...>::GetCreator(key); return creator == nullptr ? nullptr : creator->Create(std::forward<TArgs>(args)...); } - + static bool Has(const TKey& key) { return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->HasImpl(key); } diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index f5f113b98b..06fb0739ff 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -58,19 +58,19 @@ private: const TArgument Argument; }; -struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { +struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { - ++CallsCounter; - return new TDirectOrder(provider, factor, argument); - } - - static int CallsCounter; -}; -int TDirectOrderCreator::CallsCounter = 0; - -using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const TString&, float, TArgument&>; - -static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator); + ++CallsCounter; + return new TDirectOrder(provider, factor, argument); + } + + static int CallsCounter; +}; +int TDirectOrderCreator::CallsCounter = 0; + +using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const TString&, float, TArgument&>; + +static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator); static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); @@ -146,16 +146,16 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { Y_UNIT_TEST(TestParametrized) { TArgument directArg{"Name", nullptr}; TArgument inverseArg{"Fake", nullptr}; - THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); - THolder<ICommonInterface> inverse(TTestFactory::Construct("inverse", "prov2", 1, inverseArg)); + THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); + THolder<ICommonInterface> inverse(TTestFactory::Construct("inverse", "prov2", 1, inverseArg)); UNIT_ASSERT(!!direct); UNIT_ASSERT(!!inverse); UNIT_ASSERT(direct->GetValue() == "prov0.42Name"); UNIT_ASSERT(inverse->GetValue() == "Fake1prov2"); - - UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1); + + UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1); } Y_UNIT_TEST(TestMoveableOnly) { diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp index 7d043df34e..07ff0d6caa 100644 --- a/util/system/shmat.cpp +++ b/util/system/shmat.cpp @@ -171,7 +171,7 @@ static key_t GetKey(const TGUID& id) { bool TSharedMemory::Open(const TGUID& id, int size) { Y_VERIFY(id, "invalid shared memory guid: %s", GetGuidAsString(id).data()); - + //Y_ASSERT(Data == 0); Size = size; |