Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Object.h

Go to the documentation of this file.
00001 /*
00002  * Object.h
00003  *
00004  * Smalltalk like class library for C++
00005  * Base class. Header.
00006  *
00007  * Copyright (c) 2003-05 Milan Cermak
00008  */
00009 /*
00010  * This library 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 library 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 library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 #ifndef __OBJECT_H
00025 #define __OBJECT_H
00026 
00027 #if !defined(NOGC)
00028 #  define GC_LINUX_THREADS
00029 #  ifndef _REENTRANT
00030 #    define _REENTRANT
00031 #  endif
00032 #  include <gc/gc_cpp.h>
00033 #endif
00034 
00035 #define nil (0)
00036 
00037 #define abstract = 0
00038 
00042 #if defined __GNUC__ && defined __GNUC_MINOR__
00043 # define __GNUC_PREREQ(maj, min) \
00044         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
00045 #else
00046 # define __GNUC_PREREQ(maj, min) 0
00047 #endif
00048 
00055 namespace Core {
00056 
00057 class Collection;
00058 class String;
00059 class Stream;
00060 class Visitor;
00061 
00070 class Object
00071 #if !defined(NOGC)
00072              : public gc_cleanup
00073 #endif
00074 {
00075   protected:
00076     long oid;       
00078   public:
00079     Object(void);
00080     virtual ~Object(void);
00081 
00082     /* Class-accessing protocol */
00089     virtual String *className(void) const;
00090 
00091     /* Error handling protocol */
00094     virtual void error(String *message, String *selector = nil,
00095                        Object *parameter = nil);
00096 
00103     virtual void shouldNotImplement(String *selector);
00104     virtual void shouldNotImplement(const char *selector);
00105 
00106     /* Comparing protocol */
00111     virtual long hash(void) const;
00119     virtual bool isEqual(const Object *object) const;
00124     virtual bool isEqual(const Object &object) const;
00125 
00126     virtual bool isEqualToByteArray(const Object *array) const;
00127 
00132     virtual bool operator==(const Object &object) const;
00133 
00138     virtual bool isIdentical(const Object *object) const;
00143     virtual bool isIdentical(const Object &object) const;
00144 
00145     /* Printing protocol */
00151     virtual void printOn(Stream *stream) const;
00154     virtual String *printString(void) const;
00155 
00156     /* Testing protocol */
00158     virtual bool isAssociation(void) const;
00160     virtual bool isBoolean(void) const;
00162     virtual bool isCharacter(void) const;
00164     virtual bool isNumber(void) const;
00166     virtual bool isString(void) const;
00167 
00171     virtual bool isInstanceOf(String *className);
00172 
00177     virtual bool isInstanceOf(const char *className);
00178 
00179     /* Visiting protocol */
00180     virtual void visitBy(Visitor *visitor);
00181 };
00182 
00183 };
00184 
00185 using namespace Core;    // Make Core namespace globally accessible
00186 
00187 #endif /* __OBJECT_H */

Generated on Mon Nov 27 09:47:55 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2