Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   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 SWORD_NAMESPACE_START
00014 #define SWDYNAMIC_CAST(className, object) (className *)((object)?((object->getClass()->isAssignableFrom(#className))?object:0):0)
00015 
00019 class SWDLLEXPORT SWClass {
00020 private:
00021         const char **descends;
00022 
00023 public:
00024         SWClass(const char **descends) {
00025                 this->descends = descends;
00026         }
00027 
00028         bool isAssignableFrom(const char *className) const {
00029                 for (int i = 0; descends[i]; i++) {
00030                         if (!stricmp(descends[i], className))
00031                                 return true;
00032                 }
00033                 return false;
00034         }
00035 };
00036 
00042 class SWObject {
00043 protected:
00044         SWClass * myclass;
00045      
00046 public:
00050         const SWClass *getClass () const {
00051                 return myclass;
00052         }
00053 };
00054 
00055 SWORD_NAMESPACE_END
00056 #endif

Generated on Thu Oct 31 12:11:28 2002 for The Sword Project by doxygen1.2.17