*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)

*Fix a possible crash in Spell::DoAllEffectOnTarget

--HG--
branch : trunk
This commit is contained in:
maximius committed 2009-10-17 15:35:07 -07:00
1 parent f21f47005d
commit 26b5e033ff
2257 files changed
+750 -103852

No files matched your search

@@ -17,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_REFERENCE_H
#define TRINITY_REFERENCE_H
/**
* Referencer<T>
* Referencer is an object that holds a reference holder that hold a reference
@@ -31,12 +29,10 @@
* reference around. Objects can be reference counted in both single threaded
* model and multi-threaded model
*/
#include <stdexcept>
#include "Platform/Define.h"
#include "Policies/ThreadingModel.h"
#include "ReferenceHolder.h"
template
<
typename T,
@@ -47,52 +43,39 @@ class TRINITY_DLL_DECL Referencer
typedef typename THREADING_MODEL::Lock Lock;
typedef ReferenceHolder<T, THREADING_MODEL> ReferenceeHolder;
public:
/// Constructs a referencer.
Referencer(T *ref = NULL);
/// Copy constructor
Referencer(const Referencer &obj) : i_holder(NULL) { *this = obj; }
/// Destructor
~Referencer();
/// Referencee accessor
T* referencee(void) { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T* referencee(void) const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
//T& referencee(void){ return _referencee(); }
//const T& referencee(void) const { return const_cast<Referencer *>(this)->_referencee(); }
operator T&(void) { return _referencee(); }
operator const T&(void) const { return *const_cast<Referencer *>(this)->_referencee(); }
/// cast operators
T* operator*() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
T const * operator*() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
/// overload operators
T* operator->() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T * operator->() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
/// operator =
Referencer& operator=(const Referencer &obj);
Referencer& operator=(T *);
/// returns true if i_referencee is null
bool isNull(void) const { return i_holder == NULL; }
private:
T& _referencee(void)
{
if( i_holder == NULL )
throw std::runtime_error("Invalid access to null pointer");
return *i_holder->i_referencee;
}
void deReference(ReferenceeHolder *);
void addReference(ReferenceeHolder *);
// private data
ReferenceeHolder *i_holder;
};