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
This commit is contained in:
@@ -24,14 +24,14 @@
|
|||||||
#include "Weather.h"
|
#include "Weather.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include <ace/Refcounted_Auto_Ptr.h>
|
#include "AutoPtr.h"
|
||||||
|
|
||||||
namespace WeatherMgr
|
namespace WeatherMgr
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace
|
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;
|
typedef UNORDERED_MAP<uint32, WeatherData> WeatherZoneMap;
|
||||||
|
|
||||||
WeatherMap m_weathers;
|
WeatherMap m_weathers;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
#ifndef QUERYRESULT_H
|
#ifndef QUERYRESULT_H
|
||||||
#define QUERYRESULT_H
|
#define QUERYRESULT_H
|
||||||
|
|
||||||
#include <ace/Refcounted_Auto_Ptr.h>
|
#include "AutoPtr.h"
|
||||||
#include <ace/Thread_Mutex.h>
|
#include <ace/Thread_Mutex.h>
|
||||||
|
|
||||||
#include "Field.h"
|
#include "Field.h"
|
||||||
@@ -58,7 +58,7 @@ class ResultSet
|
|||||||
MYSQL_FIELD* _fields;
|
MYSQL_FIELD* _fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ACE_Refcounted_Auto_Ptr<ResultSet, ACE_Null_Mutex> QueryResult;
|
typedef Trinity::AutoPtr<ResultSet, ACE_Null_Mutex> QueryResult;
|
||||||
|
|
||||||
class PreparedResultSet
|
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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Transaction
|
|||||||
bool _cleanedUp;
|
bool _cleanedUp;
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef ACE_Refcounted_Auto_Ptr<Transaction, ACE_Null_Mutex> SQLTransaction;
|
typedef Trinity::AutoPtr<Transaction, ACE_Null_Mutex> SQLTransaction;
|
||||||
|
|
||||||
/*! Low level class*/
|
/*! Low level class*/
|
||||||
class TransactionTask : public SQLOperation
|
class TransactionTask : public SQLOperation
|
||||||
|
|||||||
Reference in New Issue
Block a user