root/trunk/src/game/MapReference.h @ 257

Revision 257, 1.8 kB (checked in by yumileroy, 17 years ago)

*Merge from Mangos. Add MapReference?. Author: hunuza.
*Also re-commit the patches reverted in 255.

Original author: megamage
Date: 2008-11-18 19:40:06-06:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19#ifndef _MAPREFERENCE_H
20#define _MAPREFERENCE_H
21
22#include "Utilities/LinkedReference/Reference.h"
23#include "Map.h"
24
25class TRINITY_DLL_SPEC MapReference : public Reference<Map, Player>
26{
27    protected:
28        void targetObjectBuildLink()
29        {
30            // called from link()
31            getTarget()->m_mapRefManager.insertFirst(this);
32            getTarget()->m_mapRefManager.incSize();
33        }
34        void targetObjectDestroyLink()
35        {
36            // called from unlink()
37            if(isValid()) getTarget()->m_mapRefManager.decSize();
38        }
39        void sourceObjectDestroyLink()
40        {
41            // called from invalidate()
42            getTarget()->m_mapRefManager.decSize();
43        }
44    public:
45        MapReference() : Reference<Map, Player>() {}
46        ~MapReference() { unlink(); }
47        MapReference *next() { return (MapReference*)Reference<Map, Player>::next(); }
48        MapReference const *next() const { return (MapReference const*)Reference<Map, Player>::next(); }
49};
50#endif
Note: See TracBrowser for help on using the browser.