00001 /* 00002 toten 00003 Copyright (C) 2004,2005 Toten Developers 00004 00005 Toten is the legal property of its developers, whose names are 00006 too numerous to list here. Please refer to the COPYRIGHT file 00007 for the full text of this license and to the AUTHORS file for 00008 the complete list of developers. 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00023 */ 00024 00025 #include "toten.h" 00026 00027 static unsigned int id_count = 0; 00028 00029 @implementation TObject : Object 00030 00031 - init 00032 { 00033 [super init]; 00034 00035 self->ID = id_count++; 00036 self->refcount = 1; 00037 00038 } 00039 00040 - free 00041 { 00042 [super free]; 00043 } 00044 00045 - (int)grab 00046 { 00047 return ++refcount; 00048 } 00049 00050 - (int)release 00051 { 00052 int count; 00053 00054 count = --refcount; 00055 00056 if(refcount == 0) 00057 [self free]; 00058 00059 return count; 00060 } 00061 00062 - (int)get_refcount 00063 { 00064 return self->refcount; 00065 } 00066 00067 - (int)get_id 00068 { 00069 return self->ID; 00070 } 00071 00072 @end 00073