aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/object_factory
diff options
context:
space:
mode:
authorakhropov <akhropov@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit298c6da79f1d8f35089a67f463f0b541bec36d9b (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/object_factory
parent00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (diff)
downloadydb-298c6da79f1d8f35089a67f463f0b541bec36d9b.tar.gz
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/object_factory')
-rw-r--r--library/cpp/object_factory/object_factory.h10
-rw-r--r--library/cpp/object_factory/object_factory_ut.cpp148
2 files changed, 79 insertions, 79 deletions
diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h
index 57a9ee8f4e..96cc11bcfd 100644
--- a/library/cpp/object_factory/object_factory.h
+++ b/library/cpp/object_factory/object_factory.h
@@ -11,7 +11,7 @@ namespace NObjectFactory {
template <class TProduct, class... TArgs>
class IFactoryObjectCreator {
public:
- virtual TProduct* Create(TArgs... args) const = 0;
+ virtual TProduct* Create(TArgs... args) const = 0;
virtual ~IFactoryObjectCreator() {
}
};
@@ -34,8 +34,8 @@ namespace NObjectFactory {
template <class TBaseProduct, class TDerivedProduct, class... TArgs>
class TFactoryObjectCreator: public IFactoryObjectCreator<TBaseProduct, TArgs...> {
- TDerivedProduct* Create(TArgs... args) const override {
- return new TDerivedProduct(std::forward<TArgs>(args)...);
+ TDerivedProduct* Create(TArgs... args) const override {
+ return new TDerivedProduct(std::forward<TArgs>(args)...);
}
};
@@ -185,7 +185,7 @@ namespace NObjectFactory {
public:
TProduct* Create(const TKey& key, TArgs... args) const {
IFactoryObjectCreator<TProduct, TArgs...>* creator = IObjectFactory<TProduct, TKey, TArgs...>::GetCreator(key);
- return creator == nullptr ? nullptr : creator->Create(std::forward<TArgs>(args)...);
+ return creator == nullptr ? nullptr : creator->Create(std::forward<TArgs>(args)...);
}
static bool Has(const TKey& key) {
@@ -193,7 +193,7 @@ namespace NObjectFactory {
}
static TProduct* Construct(const TKey& key, TArgs... args) {
- return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->Create(key, std::forward<TArgs>(args)...);
+ return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->Create(key, std::forward<TArgs>(args)...);
}
template <class... Args>
diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp
index 49e2ca2cec..06fb0739ff 100644
--- a/library/cpp/object_factory/object_factory_ut.cpp
+++ b/library/cpp/object_factory/object_factory_ut.cpp
@@ -1,7 +1,7 @@
#include <library/cpp/object_factory/object_factory.h>
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/noncopyable.h>
+#include <util/generic/noncopyable.h>
#include <util/generic/string.h>
#include <util/generic/ptr.h>
@@ -59,7 +59,7 @@ private:
};
struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> {
- ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override {
+ ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override {
++CallsCounter;
return new TDirectOrder(provider, factor, argument);
}
@@ -73,65 +73,65 @@ using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const
static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator);
static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse");
-
-
-class IMoveableOnlyInterface {
-public:
- virtual ~IMoveableOnlyInterface() {
- }
-
- virtual TString GetValue() const = 0;
-};
-
-class TMoveableOnly: public IMoveableOnlyInterface, public TMoveOnly {
-public:
- TMoveableOnly(TString&& value)
- : Value(value)
- {}
-
- TString GetValue() const override {
- return Value;
- }
-
-private:
- const TString Value;
-};
-
-
-using TMoveableOnlyFactory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, TString&&>;
-
-static TMoveableOnlyFactory::TRegistrator<TMoveableOnly> MoveableOnlyReg("move");
-
-
-
-class TMoveableOnly2: public IMoveableOnlyInterface, public TMoveOnly {
-public:
- TMoveableOnly2(THolder<TString>&& value)
- : Value(std::move(value))
- {}
-
- TString GetValue() const override {
- return *Value;
- }
-
-private:
- const THolder<TString> Value;
-};
-
-
-using TMoveableOnly2Factory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, THolder<TString>&&>;
-
-static TMoveableOnly2Factory::TRegistrator<TMoveableOnly2> MoveableOnly2Reg("move2");
-
+
+
+class IMoveableOnlyInterface {
+public:
+ virtual ~IMoveableOnlyInterface() {
+ }
+
+ virtual TString GetValue() const = 0;
+};
+
+class TMoveableOnly: public IMoveableOnlyInterface, public TMoveOnly {
+public:
+ TMoveableOnly(TString&& value)
+ : Value(value)
+ {}
+
+ TString GetValue() const override {
+ return Value;
+ }
+
+private:
+ const TString Value;
+};
+
+
+using TMoveableOnlyFactory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, TString&&>;
+
+static TMoveableOnlyFactory::TRegistrator<TMoveableOnly> MoveableOnlyReg("move");
+
+
+
+class TMoveableOnly2: public IMoveableOnlyInterface, public TMoveOnly {
+public:
+ TMoveableOnly2(THolder<TString>&& value)
+ : Value(std::move(value))
+ {}
+
+ TString GetValue() const override {
+ return *Value;
+ }
+
+private:
+ const THolder<TString> Value;
+};
+
+
+using TMoveableOnly2Factory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, THolder<TString>&&>;
+
+static TMoveableOnly2Factory::TRegistrator<TMoveableOnly2> MoveableOnly2Reg("move2");
+
class TDirectOrderDifferentSignature : public TDirectOrder {
public:
TDirectOrderDifferentSignature(const TString& provider, TArgument& argument) :
TDirectOrder(provider, 0.01f, argument)
{
}
-
+
};
-
+
struct TDirectOrderDSCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> {
ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override {
Y_UNUSED(factor);
@@ -157,26 +157,26 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) {
UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1);
}
-
- Y_UNIT_TEST(TestMoveableOnly) {
- TString v = "value1";
-
- THolder<IMoveableOnlyInterface> moveableOnly(TMoveableOnlyFactory::Construct("move", std::move(v)));
-
- UNIT_ASSERT(!!moveableOnly);
-
- UNIT_ASSERT(moveableOnly->GetValue() == "value1");
- }
-
- Y_UNIT_TEST(TestMoveableOnly2) {
- THolder<TString> v = MakeHolder<TString>("value2");
-
- THolder<IMoveableOnlyInterface> moveableOnly2(TMoveableOnly2Factory::Construct("move2", std::move(v)));
-
- UNIT_ASSERT(!!moveableOnly2);
-
- UNIT_ASSERT(moveableOnly2->GetValue() == "value2");
- }
+
+ Y_UNIT_TEST(TestMoveableOnly) {
+ TString v = "value1";
+
+ THolder<IMoveableOnlyInterface> moveableOnly(TMoveableOnlyFactory::Construct("move", std::move(v)));
+
+ UNIT_ASSERT(!!moveableOnly);
+
+ UNIT_ASSERT(moveableOnly->GetValue() == "value1");
+ }
+
+ Y_UNIT_TEST(TestMoveableOnly2) {
+ THolder<TString> v = MakeHolder<TString>("value2");
+
+ THolder<IMoveableOnlyInterface> moveableOnly2(TMoveableOnly2Factory::Construct("move2", std::move(v)));
+
+ UNIT_ASSERT(!!moveableOnly2);
+
+ UNIT_ASSERT(moveableOnly2->GetValue() == "value2");
+ }
Y_UNIT_TEST(TestDifferentSignature) {
TArgument directArg{"Name", nullptr};