[7833] Implement levelup spells for non-hunter pets.
[getmangos.git] / src / shared / Base.cpp
blob9929cd41fdf34c764bd5fd1157a102610e7ceac3
1 /*
2 Base class interface
3 Copyright (C) 1998,1999 by Andrew Zabolotny
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "Base.h"
22 Base::~Base ()
26 /**
27 * Decrement object's reference count; as soon as the last reference
28 * to the object is removed, it is destroyed.
31 void Base::DecRef ()
33 if (!--RefCount)
34 delete this;
37 /**
38 * Object initialization. The initial reference count is set to one;
39 * this means if you call DecRef() immediately after creating the object,
40 * it will be destroyed.
42 Base::Base ()
44 RefCount = 1;
47 /**
48 * Increment reference count.
49 * Every time when you copy a pointer to a object and store it for
50 * later use you MUST call IncRef() on it; this will allow to keep
51 * objects as long as they are referenced by some entity.
53 void Base::IncRef ()
55 ++RefCount;
59 /**
60 * Query number of references to this object.
61 * I would rather prefer to have the reference counter strictly private,
62 * but sometimes, mostly for debugging, such a function can help.
64 int Base::GetRefCount ()
66 return RefCount;