|
@@ -126,12 +126,12 @@ namespace NObjectFactory {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- static THolder<TProduct> VerifiedConstruct(const TKey& key) {
|
|
|
|
- auto result = MakeHolder(key);
|
|
|
|
- Y_VERIFY(result, "Construct by factory failed");
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ static THolder<TProduct> VerifiedConstruct(const TKey& key) {
|
|
|
|
+ auto result = MakeHolder(key);
|
|
|
|
+ Y_VERIFY(result, "Construct by factory failed");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
template<class... Args>
|
|
template<class... Args>
|
|
static THolder<TProduct> MakeHolder(Args&&... args) {
|
|
static THolder<TProduct> MakeHolder(Args&&... args) {
|
|
return THolder<TProduct>(Construct(std::forward<Args>(args)...));
|
|
return THolder<TProduct>(Construct(std::forward<Args>(args)...));
|
|
@@ -151,17 +151,17 @@ namespace NObjectFactory {
|
|
return keys;
|
|
return keys;
|
|
}
|
|
}
|
|
|
|
|
|
- template <class TDerivedProduct>
|
|
|
|
- static TSet<TKey> GetRegisteredKeys() {
|
|
|
|
- TSet<TKey> registeredKeys(GetRegisteredKeys());
|
|
|
|
- TSet<TKey> fileredKeys;
|
|
|
|
- std::copy_if(registeredKeys.begin(), registeredKeys.end(), std::inserter(fileredKeys, fileredKeys.end()), [](const TKey& key) {
|
|
|
|
- THolder<TProduct> objectHolder(Construct(key));
|
|
|
|
- return !!dynamic_cast<const TDerivedProduct*>(objectHolder.Get());
|
|
|
|
- });
|
|
|
|
- return fileredKeys;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ template <class TDerivedProduct>
|
|
|
|
+ static TSet<TKey> GetRegisteredKeys() {
|
|
|
|
+ TSet<TKey> registeredKeys(GetRegisteredKeys());
|
|
|
|
+ TSet<TKey> fileredKeys;
|
|
|
|
+ std::copy_if(registeredKeys.begin(), registeredKeys.end(), std::inserter(fileredKeys, fileredKeys.end()), [](const TKey& key) {
|
|
|
|
+ THolder<TProduct> objectHolder(Construct(key));
|
|
|
|
+ return !!dynamic_cast<const TDerivedProduct*>(objectHolder.Get());
|
|
|
|
+ });
|
|
|
|
+ return fileredKeys;
|
|
|
|
+ }
|
|
|
|
+
|
|
template <class Product>
|
|
template <class Product>
|
|
class TRegistrator {
|
|
class TRegistrator {
|
|
public:
|
|
public:
|
|
@@ -196,13 +196,13 @@ namespace NObjectFactory {
|
|
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>
|
|
|
|
- static THolder<TProduct> VerifiedConstruct(Args&&... args) {
|
|
|
|
- auto result = MakeHolder(std::forward<Args>(args)...);
|
|
|
|
- Y_VERIFY(result, "Construct by factory failed");
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ template <class... Args>
|
|
|
|
+ static THolder<TProduct> VerifiedConstruct(Args&&... args) {
|
|
|
|
+ auto result = MakeHolder(std::forward<Args>(args)...);
|
|
|
|
+ Y_VERIFY(result, "Construct by factory failed");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
template<class... Args>
|
|
template<class... Args>
|
|
static THolder<TProduct> MakeHolder(Args&&... args) {
|
|
static THolder<TProduct> MakeHolder(Args&&... args) {
|
|
return THolder<TProduct>(Construct(std::forward<Args>(args)...));
|
|
return THolder<TProduct>(Construct(std::forward<Args>(args)...));
|