--- a/src/utils/refcntr.h
+++ b/src/utils/refcntr.h
@@ -1,5 +1,21 @@
#ifndef _REFCNTR_H_
#define _REFCNTR_H_
+/* Copyright (C) 2014 J.F.Dockes
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
// See Stroustrup C++ 3rd ed, p. 783
// This is only used if std::shared_ptr is not available
@@ -33,8 +49,7 @@
(*pcount)++;
return *this;
}
- void release()
- {
+ void reset() {
if (pcount && --(*pcount) == 0) {
delete rep;
delete pcount;
@@ -42,22 +57,14 @@
rep = 0;
pcount = 0;
}
- void reset() {
- release();
- }
~RefCntr()
{
- release();
+ reset();
}
X *operator->() {return rep;}
- X *getptr() const {return rep;}
X *get() const {return rep;}
- const X *getconstptr() const {return rep;}
- int getcnt() const {return pcount ? *pcount : 0;}
- bool isNull() const {return rep == 0;}
- bool isNotNull() const {return rep != 0;}
+ int use_count() const {return pcount ? *pcount : 0;}
operator bool() const {return rep != 0;}
};
-
#endif /*_REFCNTR_H_ */