diff options
Diffstat (limited to 'libraries/evas/src/modules/engines/direct3d/ref.h')
-rw-r--r-- | libraries/evas/src/modules/engines/direct3d/ref.h | 210 |
1 files changed, 0 insertions, 210 deletions
diff --git a/libraries/evas/src/modules/engines/direct3d/ref.h b/libraries/evas/src/modules/engines/direct3d/ref.h deleted file mode 100644 index 0853f2e..0000000 --- a/libraries/evas/src/modules/engines/direct3d/ref.h +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | #ifndef __REF_H__ | ||
2 | #define __REF_H__ | ||
3 | |||
4 | ////////////////////////////////////////////////////////////////////////////// | ||
5 | // class Referenc | ||
6 | // Desc: Base class enabling reference interface | ||
7 | // Note: Class should derive as virtual | ||
8 | // | ||
9 | class Referenc | ||
10 | { | ||
11 | public: | ||
12 | Referenc() | ||
13 | : refs_count(0) {}; | ||
14 | |||
15 | inline int AddRef() | ||
16 | { | ||
17 | return ++refs_count; | ||
18 | } | ||
19 | inline int RemRef() | ||
20 | { | ||
21 | return --refs_count; | ||
22 | } | ||
23 | inline int RefCount() | ||
24 | { | ||
25 | return refs_count; | ||
26 | } | ||
27 | |||
28 | private: | ||
29 | int refs_count; | ||
30 | }; | ||
31 | |||
32 | |||
33 | ////////////////////////////////////////////////////////////////////////////// | ||
34 | // template Ref | ||
35 | // Desc: Holder in smart-pointers system. | ||
36 | // Important: Only Referenc subclasses may be used as template param. | ||
37 | // | ||
38 | |||
39 | template <class T> | ||
40 | class Ref | ||
41 | { | ||
42 | public: | ||
43 | // Constructors & destructor | ||
44 | Ref(); | ||
45 | //Ref(Ref<T> &ref); | ||
46 | Ref(const Ref<T> &ref); | ||
47 | Ref(T *ptr); | ||
48 | Ref(const T *ptr); | ||
49 | ~Ref(); | ||
50 | |||
51 | Ref<T> &operator =(Ref<T> &ref); | ||
52 | Ref<T> &operator =(T *ptr); | ||
53 | |||
54 | inline T *Addr(); | ||
55 | inline T *Addr() const; | ||
56 | inline int RefCount(); | ||
57 | inline bool IsNull(); | ||
58 | |||
59 | inline T *operator ->(); | ||
60 | inline operator const T *() const; | ||
61 | inline operator T *(); | ||
62 | |||
63 | //private: | ||
64 | void RemRef(); | ||
65 | |||
66 | private: | ||
67 | T *m_ptr; | ||
68 | }; | ||
69 | |||
70 | ////////////////////////////////////////////////////////////////////////////// | ||
71 | // Constructors & destructor | ||
72 | template <class T> Ref<T>::Ref() | ||
73 | : m_ptr(NULL) | ||
74 | { | ||
75 | } | ||
76 | |||
77 | //template <class T> Ref<T>::Ref(Ref<T> &ref) | ||
78 | //: m_ptr(NULL) | ||
79 | //{ | ||
80 | // if (ref.Addr() != NULL) | ||
81 | // { | ||
82 | // m_ptr = ref.Addr(); | ||
83 | // ((Referenc *)m_ptr)->AddRef(); | ||
84 | // } | ||
85 | //} | ||
86 | |||
87 | template <class T> Ref<T>::Ref(const Ref<T> &ref) | ||
88 | : m_ptr(NULL) | ||
89 | { | ||
90 | if (ref.Addr() != NULL) | ||
91 | { | ||
92 | m_ptr = ref.Addr(); | ||
93 | ((Referenc *)m_ptr)->AddRef(); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | template <class T> Ref<T>::Ref(T *ptr) | ||
98 | : m_ptr(NULL) | ||
99 | { | ||
100 | if (ptr != NULL) | ||
101 | { | ||
102 | m_ptr = ptr; | ||
103 | ((Referenc *)m_ptr)->AddRef(); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | template <class T> Ref<T>::Ref(const T *ptr) | ||
108 | : m_ptr(NULL) | ||
109 | { | ||
110 | if (ptr != NULL) | ||
111 | { | ||
112 | m_ptr = ptr; | ||
113 | ((Referenc *)m_ptr)->AddRef(); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | template <class T> Ref<T>::~Ref() | ||
118 | { | ||
119 | if (m_ptr == NULL) | ||
120 | return; | ||
121 | RemRef(); | ||
122 | } | ||
123 | |||
124 | // Check pointer on correctness | ||
125 | template <class T> bool Ref<T>::IsNull() | ||
126 | { | ||
127 | return (m_ptr == NULL); | ||
128 | } | ||
129 | |||
130 | ////////////////////////////////////////////////////////////////////////////// | ||
131 | // Operators | ||
132 | |||
133 | template <class T> Ref<T> &Ref<T>::operator =(T *ptr) | ||
134 | { | ||
135 | if (ptr != NULL) | ||
136 | { | ||
137 | if (m_ptr != ptr) | ||
138 | { | ||
139 | RemRef(); | ||
140 | m_ptr = ptr; | ||
141 | ((Referenc *)m_ptr)->AddRef(); | ||
142 | } | ||
143 | } | ||
144 | else if (m_ptr != NULL) | ||
145 | RemRef(); | ||
146 | return *this; | ||
147 | } | ||
148 | |||
149 | template <class T> Ref<T> &Ref<T>::operator =(Ref<T> &ref) | ||
150 | { | ||
151 | if (ref.Addr() != NULL) | ||
152 | { | ||
153 | if (m_ptr != ref.Addr()) | ||
154 | { | ||
155 | RemRef(); | ||
156 | m_ptr = ref.Addr(); | ||
157 | ((Referenc *)m_ptr)->AddRef(); | ||
158 | } | ||
159 | } | ||
160 | else if (m_ptr != NULL) | ||
161 | RemRef(); | ||
162 | return *this; | ||
163 | } | ||
164 | |||
165 | // Get pointer | ||
166 | template <class T> T *Ref<T>::Addr() | ||
167 | { | ||
168 | return m_ptr; | ||
169 | } | ||
170 | |||
171 | template <class T> T *Ref<T>::Addr() const | ||
172 | { | ||
173 | return m_ptr; | ||
174 | } | ||
175 | |||
176 | // Get refs count | ||
177 | template <class T> int Ref<T>::RefCount() | ||
178 | { | ||
179 | if (m_ptr == NULL) | ||
180 | return 0; | ||
181 | return ((Referenc *)m_ptr)->RefCount(); | ||
182 | } | ||
183 | |||
184 | // Remove ref to the object and delete it if necessary | ||
185 | // WARNING: arrays cannot be deleted | ||
186 | template <class T> void Ref<T>::RemRef() | ||
187 | { | ||
188 | if (m_ptr == NULL) | ||
189 | return; | ||
190 | if (((Referenc *)m_ptr)->RemRef() == 0) | ||
191 | delete m_ptr; | ||
192 | m_ptr = NULL; | ||
193 | } | ||
194 | |||
195 | template <class T> T *Ref<T>::operator ->() | ||
196 | { | ||
197 | return m_ptr; | ||
198 | } | ||
199 | |||
200 | template <class T> Ref<T>::operator const T *() const | ||
201 | { | ||
202 | return m_ptr; | ||
203 | } | ||
204 | |||
205 | template <class T> Ref<T>::operator T *() | ||
206 | { | ||
207 | return m_ptr; | ||
208 | } | ||
209 | |||
210 | #endif // __REF_H__ | ||