[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / visualizations / Vortex / VortexVis / Core / EffectBase.h
1 /*
2  *  Copyright © 2010-2013 Team XBMC
3  *  http://xbmc.org
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program 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
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19
20 #ifndef _EFFECT_H_
21 #define _EFFECT_H_
22
23 struct IDirect3DTexture9;
24
25 class EffectBase
26 {
27 public:
28         static void RegisterScriptInterface( class asIScriptEngine* );
29         EffectBase()
30         {
31                 m_iRefCount = 1;
32         }
33
34         virtual ~EffectBase() {};
35
36         void AddRef()
37         {
38                 m_iRefCount++;
39         }
40
41         void Release()
42         {
43                 if ( --m_iRefCount == 0 )
44                         delete this;
45         }
46
47         virtual  IDirect3DTexture9* GetTexture() { return 0; }
48         virtual  IDirect3DTexture9* GetRenderTarget() { return 0; }
49
50 protected:
51         int m_iRefCount;
52 };
53
54 template<class A, class B>
55 B* refCast(A* a)
56 {
57         // If the handle already is a null handle, then just return the null handle
58         if( !a ) return 0;
59
60         // Now try to dynamically cast the pointer to the wanted type
61         B* b = dynamic_cast<B*>(a);
62         if( b != 0 )
63         {
64                 // Since the cast was made, we need to increase the ref counter for the returned handle
65                 b->AddRef();
66         }
67         return b;
68 }
69
70 #endif