X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/04558943953dd545e6000816877f54e0128e5879..e4097f77c440b1f31a80fe273cc732c14d606096:/interface/wx/object.h diff --git a/interface/wx/object.h b/interface/wx/object.h index f827d2445c..5635116895 100644 --- a/interface/wx/object.h +++ b/interface/wx/object.h @@ -2,18 +2,17 @@ // Name: object.h // Purpose: interface of wxRefCounter // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @class wxObjectRefData This class is just a typedef to wxRefCounter and is used by wxObject. - Derive classes from this to store your own data in wxObject derived + Derive classes from this to store your own data in wxObject-derived classes. When retrieving information from a wxObject's reference data, you will need to cast to your own derived class. - + Below is an example illustrating how to store reference counted data in a class derived from wxObject including copy-on-write semantics. @@ -42,7 +41,7 @@ virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - DECLARE_DYNAMIC_CLASS(MyCar) + wxDECLARE_DYNAMIC_CLASS(MyCar) }; @@ -83,7 +82,7 @@ #define M_CARDATA ((MyCarRefData *)m_refData) - IMPLEMENT_DYNAMIC_CLASS(MyCar,wxObject) + wxIMPLEMENT_DYNAMIC_CLASS(MyCar, wxObject); MyCar::MyCar( int price ) { @@ -91,7 +90,7 @@ m_refData = new MyCarRefData(); M_CARDATA->m_price = price; } - + wxObjectRefData *MyCar::CreateRefData() const { return new MyCarRefData; @@ -106,7 +105,7 @@ { if (m_refData == car.m_refData) return true; - if (!m_refData || !car.m_refData) + if (!m_refData || !car.m_refData) return false; // here we use the MyCarRefData::operator==() function. @@ -135,7 +134,7 @@ } @endcode - + @library{wxbase} @category{rtti} @@ -151,9 +150,9 @@ typedef wxRefCounter wxObjectRefData; interface and a counter. wxRefCounter can be easily used together with wxObjectDataPtr to ensure that no calls to wxRefCounter::DecRef() are missed - thus avoiding memory leaks. - + wxObjectRefData is a typedef to wxRefCounter and is used as the - built-in reference counted storage for wxObject derive classes. + built-in reference counted storage for wxObject-derived classes. @library{wxbase} @category{rtti} @@ -227,7 +226,7 @@ public: @library{wxbase} @category{rtti} - @see wxClassInfo, @ref overview_debugging, @ref overview_refcount, + @see wxClassInfo, @ref overview_debugging, @ref overview_refcount, wxObjectDataRef, wxObjectDataPtr */ class wxObject @@ -257,12 +256,12 @@ public: /** This virtual function is redefined for every class that requires run-time - type information, when using the ::DECLARE_CLASS macro (or similar). + type information, when using the ::wxDECLARE_CLASS macro (or similar). */ virtual wxClassInfo* GetClassInfo() const; /** - Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. + Returns the wxObject::m_refData pointer, i.e.\ the data referenced by this object. @see Ref(), UnRef(), wxObject::m_refData, SetRefData(), wxObjectRefData */ @@ -275,12 +274,12 @@ public: Example: @code - bool tmp = obj->IsKindOf(CLASSINFO(wxFrame)); + bool tmp = obj->IsKindOf(wxCLASSINFO(wxFrame)); @endcode @param info A pointer to a class information object, which may be obtained - by using the ::CLASSINFO macro. + by using the ::wxCLASSINFO macro. @return @true if the class represented by info is the same class as this one or is derived from it. @@ -357,10 +356,10 @@ protected: Ensure that this object's data is not shared with any other object. If we have no data, it is created using CreateRefData(); - if we have shared data (i.e. data with a reference count greater than 1), + if we have shared data (i.e. data with a reference count greater than 1), it is copied using CloneRefData(); otherwise nothing is done (the data is already present and is not shared by other object instances). - + If you use this function you should make sure that you override the CreateRefData() and CloneRefData() functions in your class otherwise an assertion will fail at runtime. @@ -370,7 +369,7 @@ protected: /** Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. - + This is usually implemented as a one-line call: @code wxObjectRefData *MyObject::CreateRefData() const @@ -384,7 +383,7 @@ protected: /** Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying @a data. - + This is usually implemented as a one-line call: @code wxObjectRefData *MyObject::CloneRefData(const wxObjectRefData *data) const @@ -412,8 +411,8 @@ protected: This class stores meta-information about classes. Instances of this class are not generally defined directly by an application, - but indirectly through use of macros such as ::DECLARE_DYNAMIC_CLASS and - ::IMPLEMENT_DYNAMIC_CLASS. + but indirectly through use of macros such as ::wxDECLARE_DYNAMIC_CLASS and + ::wxIMPLEMENT_DYNAMIC_CLASS. @library{wxbase} @category{rtti} @@ -505,10 +504,10 @@ public: public: MyCarRefData( int price = 0 ) : m_price(price) { } MyCarRefData( const MyCarRefData& data ) : m_price(data.m_price) { } - + void SetPrice( int price ) { m_price = price; } int GetPrice() const { return m_price; } - + protected: int m_price; }; @@ -536,7 +535,7 @@ public: if (m_data.get() == other.m_data.get()) return true; // this instance and the 'other' one share the // same MyCarRefData data... - + return (m_data.GetPrice() == other.m_data.GetPrice()); } @@ -545,7 +544,7 @@ public: // make sure changes to this class do not affect other instances // currently sharing our same refcounted data: UnShare(); - + m_data->SetPrice( price ); } @@ -655,21 +654,12 @@ public: @header{wx/object.h} */ -#define CLASSINFO( className ) - -/** - Used inside a class declaration to declare that the class should be made - known to the class hierarchy, but objects of this class cannot be created - dynamically. The same as DECLARE_ABSTRACT_CLASS(). - - @header{wx/object.h} -*/ -#define DECLARE_CLASS( className ) +#define wxCLASSINFO( className ) /** Used inside a class declaration to declare that the class should be made known to the class hierarchy, but objects of this class cannot be created - dynamically. The same as DECLARE_CLASS(). + dynamically. @header{wx/object.h} @@ -678,7 +668,7 @@ public: @code class wxCommand: public wxObject { - DECLARE_ABSTRACT_CLASS(wxCommand) + wxDECLARE_ABSTRACT_CLASS(wxCommand); private: ... @@ -687,14 +677,14 @@ public: }; @endcode */ -#define DECLARE_ABSTRACT_CLASS( className ) +#define wxDECLARE_ABSTRACT_CLASS( className ) /** Used inside a class declaration to make the class known to wxWidgets RTTI system and also declare that the objects of this class should be dynamically creatable from run-time type information. Notice that this implies that the class should have a default constructor, if this is not - the case consider using DECLARE_CLASS(). + the case consider using wxDECLARE_ABSTRACT_CLASS(). @header{wx/object.h} @@ -703,7 +693,7 @@ public: @code class wxFrame: public wxWindow { - DECLARE_DYNAMIC_CLASS(wxFrame) + wxDECLARE_DYNAMIC_CLASS(wxFrame); private: const wxString& frameTitle; @@ -712,35 +702,29 @@ public: }; @endcode */ -#define DECLARE_DYNAMIC_CLASS( className ) +#define wxDECLARE_DYNAMIC_CLASS( className ) /** - Used in a C++ implementation file to complete the declaration of a class - that has run-time type information. The same as IMPLEMENT_ABSTRACT_CLASS(). - - @header{wx/object.h} -*/ -#define IMPLEMENT_CLASS( className, baseClassName ) + Used inside a class declaration to declare that the class should be made + known to the class hierarchy, but objects of this class cannot be created + dynamically. -/** - Used in a C++ implementation file to complete the declaration of a class - that has run-time type information and two base classes. The same as - IMPLEMENT_ABSTRACT_CLASS2(). + The same as wxDECLARE_ABSTRACT_CLASS(). @header{wx/object.h} */ -#define IMPLEMENT_CLASS2( className, baseClassName1, baseClassName2 ) +#define wxDECLARE_CLASS( className ) /** Used in a C++ implementation file to complete the declaration of a class - that has run-time type information. The same as IMPLEMENT_CLASS(). - + that has run-time type information. + @header{wx/object.h} Example: @code - IMPLEMENT_ABSTRACT_CLASS(wxCommand, wxObject) + wxIMPLEMENT_ABSTRACT_CLASS(wxCommand, wxObject); wxCommand::wxCommand(void) { @@ -748,16 +732,15 @@ public: } @endcode */ -#define IMPLEMENT_ABSTRACT_CLASS( className, baseClassName ) +#define wxIMPLEMENT_ABSTRACT_CLASS( className, baseClassName ) /** Used in a C++ implementation file to complete the declaration of a class - that has run-time type information and two base classes. The same as - IMPLEMENT_CLASS2(). + that has run-time type information and two base classes. @header{wx/object.h} */ -#define IMPLEMENT_ABSTRACT_CLASS2( className, baseClassName1, baseClassName2 ) +#define wxIMPLEMENT_ABSTRACT_CLASS2( className, baseClassName1, baseClassName2 ) /** Used in a C++ implementation file to complete the declaration of a class @@ -769,7 +752,7 @@ public: Example: @code - IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) + wxIMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow); wxFrame::wxFrame(void) { @@ -777,7 +760,7 @@ public: } @endcode */ -#define IMPLEMENT_DYNAMIC_CLASS( className, baseClassName ) +#define wxIMPLEMENT_DYNAMIC_CLASS( className, baseClassName ) /** Used in a C++ implementation file to complete the declaration of a class @@ -786,7 +769,25 @@ public: @header{wx/object.h} */ -#define IMPLEMENT_DYNAMIC_CLASS2( className, baseClassName1, baseClassName2 ) +#define wxIMPLEMENT_DYNAMIC_CLASS2( className, baseClassName1, baseClassName2 ) + +/** + Used in a C++ implementation file to complete the declaration of a class + that has run-time type information, and whose instances can be created + dynamically. The same as wxIMPLEMENT_DYNAMIC_CLASS(). + + @header{wx/object.h} +*/ +#define wxIMPLEMENT_CLASS( className, baseClassName ) + +/** + Used in a C++ implementation file to complete the declaration of a class + that has run-time type information and two base classes, and whose instances + can be created dynamically. The same as wxIMPLEMENT_DYNAMIC_CLASS2(). + + @header{wx/object.h} +*/ +#define wxIMPLEMENT_CLASS2( className, baseClassName1, baseClassName2 ) /** Same as @c const_cast(x) if the compiler supports const cast or @c (T)x for