00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 require_once(dirname(__FILE__) . '/KjwLib.php');
00021
00022 static $kjw_object_count = 0;
00023
00027 class KjwObject {
00028 var $_kjwobject_id = -1;
00029 var $_kjwobject_last_error;
00034 function KjwObject() {
00035 global $kjw_object_count;
00036 ++$kjw_object_count;
00037 static $kjwobject_id = 0;
00038 $this->_kjwobject_id = ++$kjwobject_id;
00039 $this->_kjwobject_last_error = null;
00040
00041 if (KJW_DEBUG)
00042 $this->trace("Creating " . $this->id() . ", total objects now = $kjw_object_count.", 'MEMORY');
00043 }
00044
00049 function destroy() {
00050 global $kjw_object_count;
00051 --$kjw_object_count;
00052 if (KJW_DEBUG)
00053 $this->trace("Destroying " . $this->id() . ", total objects left = $kjw_object_count.", 'MEMORY');
00054 }
00055
00061 function id() {
00062 return 'KjwObject(#' . $this->_kjwobject_id . ')::' . get_class($this);
00063 }
00064
00070 function setError($errorMessage) {
00071 assert('is_string($errorMessage)');
00072 $this->trace("(transient) $errorMessage", 'ERROR');
00073 if ($this->_kjwobject_last_error === null)
00074 $this->_kjwobject_last_error = $errorMessage;
00075 }
00076
00082 function getError() {
00083 return $this->_kjwobject_last_error;
00084 }
00085
00090 function notImplemented() {
00091 $this->croak('Library Component Error', 'Abstract method not implemented!');
00092 }
00093
00100 function trace($msg, $level = 'DEBUG') {
00101 kjw_trace($msg, $level, $this->id());
00102 }
00103
00107 function croak($shortMsg, $detailedMsg, $backtraceShift = 1) {
00108 kjw_croak($this->id(), $shortMsg, $detailedMsg, $backtraceShift);
00109 }
00110 }
00111
00112 ?>