00001 /* 00002 * HT Editor 00003 * common.cc 00004 * 00005 * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License version 2 as 00009 * published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #include <stdio.h> 00022 #include <stdlib.h> 00023 00024 #include "common.h" 00025 #include "snprintf.h" 00026 00027 Object::Object() 00028 { 00029 #ifdef HTDEBUG 00030 initialized = false; 00031 destroyed = false; 00032 #endif 00033 } 00034 00035 Object::~Object() 00036 { 00037 #ifdef HTDEBUG 00038 if (initialized && !destroyed) { 00039 printf("shit !!! object not destroyed\n"); 00040 exit(66); 00041 // int exit=1; 00042 } 00043 #endif 00044 } 00045 00046 void Object::init() 00047 { 00048 #ifdef HTDEBUG 00049 initialized = true; 00050 #endif 00051 } 00052 00053 void Object::done() 00054 { 00055 #ifdef HTDEBUG 00056 destroyed = true; 00057 #endif 00058 } 00059 00065 int Object::compareTo(const Object *obj) const 00066 { 00067 assert(0); 00068 return 0; 00069 } 00070 00075 Object *Object::duplicate() 00076 { 00077 Object *obj = new Object(); 00078 obj->init(); 00079 return obj; 00080 } 00081 00087 bool Object::idle() 00088 { 00089 return false; 00090 } 00091 00095 bool Object::instanceOf(OBJECT_ID id) 00096 { 00097 return id == object_id(); 00098 } 00099 00100 bool Object::instanceOf(Object *o) 00101 { 00102 return instanceOf(o->object_id()); 00103 } 00104 00109 int Object::load(ht_object_stream *s) 00110 { 00111 return 0; 00112 } 00113 00117 OBJECT_ID Object::object_id() const 00118 { 00119 return ATOM_OBJECT; 00120 } 00121 00125 void Object::store(ht_object_stream *s) 00126 { 00127 } 00128 00133 int Object::toString(char *s, int maxlen) 00134 { 00135 OBJECT_ID oid = object_id(); 00136 unsigned char c1 = (oid >> 24); 00137 unsigned char c2 = (oid >> 16) & 0xff; 00138 unsigned char c3 = (oid >> 8) & 0xff; 00139 unsigned char c4 = oid & 0xff; 00140 return ht_snprintf(s, maxlen, "[OBJECT (%c%c%c%c)]", c1?c1:'0', c2?c2:'0', c3?c3:'0', c4?c4:'0'); 00141 } 00142