summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/direct3d/ref.h
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-02 21:07:10 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-02 21:07:10 +0000
commit09358c71d149fec793a8cc7f72a70d417ccae9d6 (patch)
tree6d2e8658b95dd8a777cfe443f46e515311e58dba /src/modules/evas/engines/direct3d/ref.h
parent1eac4b2f476d6484fd606ae3c84881a3c29ac09e (diff)
merge: remove direct3d (there are some remaining files, they will be deleted with ecore merge)
SVN revision: 79989
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/direct3d/ref.h210
1 files changed, 0 insertions, 210 deletions
diff --git a/src/modules/evas/engines/direct3d/ref.h b/src/modules/evas/engines/direct3d/ref.h
deleted file mode 100644
index 0853f2e1ad..0000000000
--- a/src/modules/evas/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//
9class Referenc
10{
11public:
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
28private:
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
39template <class T>
40class Ref
41{
42public:
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
66private:
67 T *m_ptr;
68};
69
70//////////////////////////////////////////////////////////////////////////////
71// Constructors & destructor
72template <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
87template <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
97template <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
107template <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
117template <class T> Ref<T>::~Ref()
118{
119 if (m_ptr == NULL)
120 return;
121 RemRef();
122}
123
124// Check pointer on correctness
125template <class T> bool Ref<T>::IsNull()
126{
127 return (m_ptr == NULL);
128}
129
130//////////////////////////////////////////////////////////////////////////////
131// Operators
132
133template <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
149template <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
166template <class T> T *Ref<T>::Addr()
167{
168 return m_ptr;
169}
170
171template <class T> T *Ref<T>::Addr() const
172{
173 return m_ptr;
174}
175
176// Get refs count
177template <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
186template <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
195template <class T> T *Ref<T>::operator ->()
196{
197 return m_ptr;
198}
199
200template <class T> Ref<T>::operator const T *() const
201{
202 return m_ptr;
203}
204
205template <class T> Ref<T>::operator T *()
206{
207 return m_ptr;
208}
209
210#endif // __REF_H__