Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126593
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/pointer.h b/util/pointer.h
index f349873b..e42f7d7b 100644
--- a/util/pointer.h
+++ b/util/pointer.h
@@ -1,110 +1,111 @@
#ifndef _paintown_util_pointer_h
#define _paintown_util_pointer_h
namespace Util{
/* Some helpful pointer classes, probably equivalent to stuff in boost
*/
template <class Data>
class ReferenceCount{
public:
ReferenceCount(Data * what = NULL):
- data(what),
- count(NULL){
+ count(NULL),
+ data(what){
count = new int;
*count = 1;
}
ReferenceCount(const ReferenceCount<Data> & him){
data = him.data;
count = him.count;
*count += 1;
}
ReferenceCount & operator=(const ReferenceCount<Data> & him){
release();
data = him.data;
count = him.count;
*count += 1;
+ return *this;
}
Data * operator->() const {
return data;
}
Data & operator*() const {
return *data;
}
bool operator==(const void * what) const {
return data == what;
}
bool operator!=(const void * what) const {
return !(*this == what);
}
virtual ~ReferenceCount(){
}
protected:
void release(){
*count -= 1;
if (*count == 0){
delete data;
delete count;
data = NULL;
count = NULL;
}
}
int * count;
Data * data;
};
/* Initializes its pointer to NULL and deletes the data in the destructor */
template <class Data>
class ClassPointer{
public:
ClassPointer():
data(NULL){
}
ClassPointer & operator=(Data * him){
if (data != NULL){
delete data;
}
data = him;
return *this;
}
Data & operator*() const {
return *data;
}
bool operator==(const void * what) const {
return data == what;
}
bool operator!=(const void * what) const {
return !(*this == what);
}
Data* operator->() const {
return data;
}
virtual ~ClassPointer(){
delete data;
}
private:
Data* data;
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:07 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68957
Default Alt Text
(2 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline