finally get rid of std::auto_ptr

This commit is contained in:
Günter Obiltschnig
2019-12-15 09:40:40 +01:00
parent 56fe4eaf97
commit 9c197e0ed1
19 changed files with 85 additions and 229 deletions

View File

@@ -42,7 +42,7 @@ public:
}
~DynamicFactory()
/// Destroys the DynamicFactory and deletes the instantiators for
/// Destroys the DynamicFactory and deletes the instantiators for
/// all registered classes.
{
for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
@@ -50,7 +50,7 @@ public:
delete it->second;
}
}
Base* createInstance(const std::string& className) const
/// Creates a new instance of the class with the given name.
/// The class must have been registered with registerClass.
@@ -64,8 +64,8 @@ public:
else
throw NotFoundException(className);
}
template <class C>
template <class C>
void registerClass(const std::string& className)
/// Registers the instantiator for the given class with the DynamicFactory.
/// The DynamicFactory takes ownership of the instantiator and deletes
@@ -75,7 +75,7 @@ public:
{
registerClass(className, new Instantiator<C, Base>);
}
void registerClass(const std::string& className, AbstractFactory* pAbstractFactory)
/// Registers the instantiator for the given class with the DynamicFactory.
/// The DynamicFactory takes ownership of the instantiator and deletes
@@ -87,11 +87,7 @@ public:
FastMutex::ScopedLock lock(_mutex);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
#else
std::unique_ptr<AbstractFactory> ptr(pAbstractFactory);
#endif // POCO_ENABLE_CPP11
typename FactoryMap::iterator it = _map.find(className);
if (it == _map.end())
@@ -99,7 +95,7 @@ public:
else
throw ExistsException(className);
}
void unregisterClass(const std::string& className)
/// Unregisters the given class and deletes the instantiator
/// for the class.
@@ -115,7 +111,7 @@ public:
}
else throw NotFoundException(className);
}
bool isClass(const std::string& className) const
/// Returns true iff the given class has been registered.
{
@@ -129,7 +125,7 @@ private:
DynamicFactory& operator = (const DynamicFactory&);
typedef std::map<std::string, AbstractFactory*> FactoryMap;
FactoryMap _map;
mutable FastMutex _mutex;
};