00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program 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 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 #ifndef lestes__std___object_hh___included 00029 #define lestes__std___object_hh___included 00030 00031 /*! \file 00032 Declaration of object class representing general object. 00033 \author pt 00034 */ 00035 #include <lestes/package.hh> 00036 #include <lestes/std/mem/keystone.hh> 00037 #include <lestes/std/ptr.hh> 00038 #include <lestes/std/srp.hh> 00039 00040 package(lestes); 00041 package(std); 00042 00043 template< typename T > 00044 class list; 00045 class dumper_visitor; 00046 class class_reflection; 00047 00048 /*! 00049 Common ancestor of all ordinary classes, adding basic functionality. 00050 Cannot be instantiated, only inherited. 00051 \todo pt Add hash and equals methods. 00052 */ 00053 class object: public mem::keystone { 00054 public: 00055 // there is a default virtual destructor 00056 //! compares two objects for equality 00057 virtual bool equals(ptr <object> o); 00058 protected: 00059 /*! 00060 \brief creates the object 00061 00062 Creates the object. 00063 Place for debugging and statistics code. 00064 00065 We had to move the definition inside the class. Inline definition outside the class 00066 was miscompiled by gcc. Completely ouf-of-line definition would be too slow. However, 00067 we might have to use it one day, when the following one is miscompiled. 00068 */ 00069 object(void) : uid(0), dump_barrier(false) 00070 {} 00071 private: 00072 //! hides copy constructor 00073 object(const object &); 00074 //! hides assignment operator 00075 object &operator=(const object &); 00076 00077 /* dump part follows */ 00078 public: 00079 typedef list< srp<object> > value_list; 00080 typedef list< srp<value_list> > field_list_list; 00081 typedef list< srp<class_reflection> > reflection_list; 00082 virtual ptr<reflection_list> reflection_get() const; 00083 virtual ptr<field_list_list> field_values_get() const; 00084 virtual void accept_dumper_visitor( ptr<dumper_visitor> v ); 00085 // returns unique id for this object; it does not change throughout its lifetime 00086 ulint uid_get(); 00087 bool dump_barrier_get() const; 00088 void dump_barrier_set( bool ); 00089 private: 00090 static ptr<reflection_list> reflection; 00091 static ulint next_uid; 00092 //! uid, set to zero on creation, only set on demand in uid_get 00093 ulint uid; 00094 //! when set to true, instructs the dumper not to follow pointers from this object 00095 bool dump_barrier; 00096 }; 00097 00098 end_package(std); 00099 end_package(lestes); 00100 00101 #endif 00102
1.5.1-20070107