The Sword Project: swobject.h Source File |
00001 /****************************************************************************** 00002 * swobject.h - definition for SWObject used as lowest base class for many 00003 * SWORD objects 00004 * 00005 * $Id: swobject.h 1790 2005-05-03 03:49:04Z scribe $ 00006 * 00007 * Copyright 2005 CrossWire Bible Society (http://www.crosswire.org) 00008 * CrossWire Bible Society 00009 * P. O. Box 2528 00010 * Tempe, AZ 85280-2528 00011 * 00012 * This program is free software; you can redistribute it and/or modify it 00013 * under the terms of the GNU General Public License as published by the 00014 * Free Software Foundation version 2. 00015 * 00016 * This program is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * General Public License for more details. 00020 * 00021 */ 00022 00023 #ifndef SWOBJECT_H 00024 #define SWOBJECT_H 00025 00026 #include <defs.h> 00027 00028 SWORD_NAMESPACE_START 00029 #define SWDYNAMIC_CAST(className, object) (className *)((object)?((object->getClass()->isAssignableFrom(#className))?object:0):0) 00030 00034 class SWDLLEXPORT SWClass { 00035 private: 00036 const char **descends; 00037 00038 public: 00039 SWClass(const char **descends) { 00040 this->descends = descends; 00041 } 00042 00043 bool isAssignableFrom(const char *className) const; 00044 }; 00045 00051 class SWObject { 00052 protected: 00053 SWClass * myclass; 00054 00055 public: 00059 const SWClass *getClass () const { 00060 return myclass; 00061 } 00062 }; 00063 00064 SWORD_NAMESPACE_END 00065 #endif
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |