TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GridReference.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _GRIDREFERENCE_H
20 #define _GRIDREFERENCE_H
21 
23 
24 template<class OBJECT>
26 
27 template<class OBJECT>
28 class GridReference : public Reference<GridRefManager<OBJECT>, OBJECT>
29 {
30  protected:
31  void targetObjectBuildLink() override
32  {
33  // called from link()
34  this->getTarget()->insertFirst(this);
35  this->getTarget()->incSize();
36  }
37  void targetObjectDestroyLink() override
38  {
39  // called from unlink()
40  if (this->isValid()) this->getTarget()->decSize();
41  }
42  void sourceObjectDestroyLink() override
43  {
44  // called from invalidate()
45  this->getTarget()->decSize();
46  }
47  public:
48  GridReference() : Reference<GridRefManager<OBJECT>, OBJECT>() { }
49  ~GridReference() { this->unlink(); }
51 };
52 #endif
void unlink()
Definition: Reference.h:61
void targetObjectDestroyLink() override
Definition: GridReference.h:37
~GridReference()
Definition: GridReference.h:49
GridReference()
Definition: GridReference.h:48
Definition: GridReference.h:25
Definition: Reference.h:27
Definition: GridReference.h:28
void sourceObjectDestroyLink() override
Definition: GridReference.h:42
bool isValid() const
Definition: Reference.h:78
void targetObjectBuildLink() override
Definition: GridReference.h:31
GridReference * next()
Definition: GridReference.h:50
GridRefManager< OBJECT > * getTarget() const
Definition: Reference.h:94