diff options
author | Machiavelli <machiavelli.trinity@gmail.com> | 2012-03-25 21:21:23 +0200 |
---|---|---|
committer | Machiavelli <machiavelli.trinity@gmail.com> | 2012-03-25 21:21:23 +0200 |
commit | fa1d3f305b6a31c11b068a3d10924d2adc9d8279 (patch) | |
tree | a5a6e09b15c1165c9eae3bdcffada4b50ad60de5 | |
parent | 44a474f1e383152e205b031614d05d982f870e59 (diff) |
Core/Misc: Implement Trinity::Auto_Ptr. Ditches ACE_Refcounted_AutoPtr (we strongly suspect it does NOT clean up the underlying pointer properly). Underlying type is now ACE_Strong_Bound_Ptr
-rwxr-xr-x | src/server/game/Weather/WeatherMgr.cpp | 4 | ||||
-rw-r--r-- | src/server/shared/AutoPtr.h | 53 | ||||
-rwxr-xr-x | src/server/shared/Database/QueryResult.h | 6 | ||||
-rwxr-xr-x | src/server/shared/Database/Transaction.h | 2 |
4 files changed, 59 insertions, 6 deletions
diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index 731aba8d197..41241583ea1 100755 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -24,14 +24,14 @@ #include "Weather.h" #include "Log.h" #include "ObjectMgr.h" -#include <ace/Refcounted_Auto_Ptr.h> +#include "AutoPtr.h" namespace WeatherMgr { namespace { - typedef UNORDERED_MAP<uint32, ACE_Refcounted_Auto_Ptr<Weather, ACE_Null_Mutex> > WeatherMap; + typedef UNORDERED_MAP<uint32, Trinity::AutoPtr<Weather, ACE_Null_Mutex> > WeatherMap; typedef UNORDERED_MAP<uint32, WeatherData> WeatherZoneMap; WeatherMap m_weathers; diff --git a/src/server/shared/AutoPtr.h b/src/server/shared/AutoPtr.h new file mode 100644 index 00000000000..988c46cc5a2 --- /dev/null +++ b/src/server/shared/AutoPtr.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _TRINITY_AUTO_PTR_H +#define _TRINITY_AUTO_PTR_H + +#include <ace/Bound_Ptr.h> + +namespace Trinity +{ + template <class Pointer, class Lock> + class AutoPtr : public ACE_Strong_Bound_Ptr<Pointer, Lock> + { + public: + AutoPtr() : ACE_Strong_Bound_Ptr<Pointer, Lock>() {} + + AutoPtr(Pointer* x) + { + ACE_Strong_Bound_Ptr<Pointer, Lock>::reset(x); + } + + operator bool() const + { + return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() != NULL; + } + + bool operator !() const + { + return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() == NULL; + } + + bool operator !=(Pointer* x) const + { + return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() != x; + } + }; +}; + +#endif
\ No newline at end of file diff --git a/src/server/shared/Database/QueryResult.h b/src/server/shared/Database/QueryResult.h index 524532f30ec..2c09cb19c81 100755 --- a/src/server/shared/Database/QueryResult.h +++ b/src/server/shared/Database/QueryResult.h @@ -19,7 +19,7 @@ #ifndef QUERYRESULT_H #define QUERYRESULT_H -#include <ace/Refcounted_Auto_Ptr.h> +#include "AutoPtr.h" #include <ace/Thread_Mutex.h> #include "Field.h" @@ -58,7 +58,7 @@ class ResultSet MYSQL_FIELD* _fields; }; -typedef ACE_Refcounted_Auto_Ptr<ResultSet, ACE_Null_Mutex> QueryResult; +typedef Trinity::AutoPtr<ResultSet, ACE_Null_Mutex> QueryResult; class PreparedResultSet { @@ -103,7 +103,7 @@ class PreparedResultSet }; -typedef ACE_Refcounted_Auto_Ptr<PreparedResultSet, ACE_Null_Mutex> PreparedQueryResult; +typedef Trinity::AutoPtr<PreparedResultSet, ACE_Null_Mutex> PreparedQueryResult; #endif diff --git a/src/server/shared/Database/Transaction.h b/src/server/shared/Database/Transaction.h index 92002819951..a12f66ceced 100755 --- a/src/server/shared/Database/Transaction.h +++ b/src/server/shared/Database/Transaction.h @@ -47,7 +47,7 @@ class Transaction bool _cleanedUp; }; -typedef ACE_Refcounted_Auto_Ptr<Transaction, ACE_Null_Mutex> SQLTransaction; +typedef Trinity::AutoPtr<Transaction, ACE_Null_Mutex> SQLTransaction; /*! Low level class*/ class TransactionTask : public SQLOperation |