Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

swobject.h

00001 #ifndef SWOBJECT_H
00002 #define SWOBJECT_H
00003 
00004 #include <utilfuns.h>
00005 #if !defined(__GNUC__) && !defined(_WIN32_WCE)
00006 #else
00007 #include <unixstr.h>
00008 #endif
00009 
00010 #include <defs.h>
00011 #include <string.h>
00012 
00013 #define SWDYNAMIC_CAST(className, object) (className *)((object->getClass()->isAssignableFrom(#className))?object:0)
00014 
00015 class SWDLLEXPORT SWClass {
00016 private:
00017         const char **descends;
00018 
00019 public:
00020         SWClass (const char **descends) {
00021                 this->descends = descends;
00022         }
00023 
00024         bool isAssignableFrom (const char *className) const {
00025                 for (int i = 0; descends[i]; i++) {
00026                         if (!stricmp (descends[i], className))
00027                                 return true;
00028                 }
00029                 return false;
00030         }
00031 };
00032 
00033 
00034 class SWObject {
00035 protected:
00036         SWClass * myclass;
00037      
00038 public:
00039         const SWClass *getClass () const {
00040                 return myclass;
00041         }
00042 };
00043 
00044 #endif

Generated at Thu May 24 19:50:26 2001 for The Sword Project by doxygen1.1.5 written by Dimitri van Heesch, © 1997-2000