VCF::Object Class Reference
Base class for the entire Visual Component Framework. More...
#include <vcf/FoundationKit/Object.h>
Inheritance diagram for VCF::Object:

Public Member Functions | |
| Object () | |
| virtual | ~Object () |
| void | init () |
| This is going to be removed from the bext release. | |
| void | free () |
| Call this method to free up the memory of the class for heap based objects. | |
| virtual uint32 | addRef (Object *owner=NULL) |
| increments the reference count of the object | |
| virtual uint32 | release (Object *owner=NULL) |
| decrements the reference count of the object | |
| uint32 | getRefCount () |
| returns the number of outstanding references for this object | |
| virtual String | toString () |
| returns a string representation of the object | |
| String | getClassName () |
| returns the class name of the object. | |
| virtual bool | isEqual (Object *object) const |
| This determines if object is equal to this the equivalent of operator ==(). | |
| virtual void | copy (Object *source) |
| Copies the data from source to this object. | |
| virtual Object * | clone (bool deep=false) |
| Makes a complete clone of this object. | |
| Class * | getClass () |
| returns the RTTI Class instance associated object of this type | |
| virtual uintptr | hash () |
| returns a hash value that represents the object instance | |
Static Public Member Functions | |
| static void | trackDebugMemory (const bool &trackMemory) |
| indicates whether or not debug memory should be tracked. | |
| static bool | isDebugMemoryTracked () |
| returns whether or not debug memory tracking is on | |
| static uint32 | objectAllocationCount () |
| returns the total number of objects currently allocated. | |
Protected Member Functions | |
| virtual void | destroy () |
| called by the free() method. | |
Protected Attributes | |
| uint32 | refCount_ |
Detailed Description
Base class for the entire Visual Component Framework.New as of July 5,2001, Object will also support refcounting for those who need this kind of support. There are several places in the ApplicationKit that will need to make use of this fairly soon.
Also Object supports a new technique for destroying Object derived instances. In general, in C++, when creating a destroying an object instance on the heap (free-store) you would use the operator delete() function. This is being phased out in the VCF for a variety of reasons, in favor of a different scheme. Destroying the memory now happens in two ways: The first is the equivalent of the operator delete() call. This involves calling the objects free() method, which will call the virtual destroy() method before calling operator delete() on itself; The second way an object can be destroyed is if it's refcount drops to 0, at which point the object's free() method will be invoked. Calling the object's release() method decrements the reference count on the object. By default if an object is created on the heap via new, and no one addref()'s it, then a single call to the release() method will free up it's memory.
Object::destroy() is a virtual method, where common shared cleanup may take place. Because this is called before the delete() method, it is still safe to call virtual methods and have them execute correctly (in C++ virtual calls inside of a constructor or destructor are not allowed and if made then the behaviour is undefined).
Classes which are heap based (such as all of the UI classes that derive from Component) should define their destructor as having protected access. In addition the majority of the cleanup code should be placed in the overridden Object::destroy() method as opposed to the class destructor. Anything that requires method calls to other object or the class itself (particularly if the method is a virtual one) should be moved to the
Semantics of the addRef/release usage are as follows: An object's refcount indicates "ownership " of the object. In other words, the "owner" of the object is responsible for releasing it's hold on the object, thus decrementing the objects refcount, which, when reduced to 0, causes the object to be deleted. This is also known as a strong reference to an object, as opposed to a weak reference where the "owner" doesn't claim any responsibility over the object.
Note that this whole scheme is aimed at heap based objects. Many objects that are created on the stack do not need this. For example, common utility objects like Rect or Point do not need this - they can be created on the stack.
Constructor & Destructor Documentation
|
|
|
|
|
|
Member Function Documentation
|
|
increments the reference count of the object
|
|
|
|
Copies the data from source to this object. This is the equivalent of operator=() Reimplemented in VCF::Color, VCF::Font, and VCF::Matrix2D. |
|
|
called by the free() method. Should be overriden and any clean up code performed here Reimplemented in VCF::ComboBoxControl, VCF::Component, VCF::Control, VCF::Frame, VCF::ListBoxControl, VCF::Menu, VCF::MenuBar, VCF::PopupMenu, VCF::SystemTray, and VCF::Window. |
|
|
Call this method to free up the memory of the class for heap based objects. Use this instead of calling the operator delete. For example: Mutex* m = new Mutex();
m->free();
|
|
|
returns the RTTI Class instance associated object of this type
|
|
|
returns the class name of the object.
|
|
|
returns the number of outstanding references for this object
|
|
|
returns a hash value that represents the object instance
|
|
|
This is going to be removed from the bext release.
Reimplemented in VCF::AbstractContainer, VCF::AbstractWin32Component, VCF::Application, VCF::ComboBoxControl, VCF::ControlContainer, VCF::ControlGraphicsContext, VCF::CustomControl, VCF::DataObject, VCF::DefaultColumnModel, VCF::DefaultListItem, VCF::DefaultMenuItem, VCF::DefaultTreeItem, VCF::DefaultTreeModel, VCF::GTKFileOpenDialog, VCF::ImageList, VCF::ListBoxControl, VCF::ListViewControl, VCF::MenuBar, VCF::OSXDialog, VCF::Panel, VCF::PopupMenu, VCF::Splitter, VCF::TabbedPages, VCF::TableControl, VCF::TextControl, VCF::TreeControl, VCF::TreeListControl, VCF::UIShell, VCF::UIToolkit, VCF::Win32FileOpenDialog, VCF::Win32FileSaveDialog, VCF::Win32Object, VCF::Win32Tree, VCF::X11Context, VCF::X11Font, VCF::X11Image, VCF::Event, VCF::FileStreamBase, VCF::Library, VCF::MemoryStream, VCF::GraphicsContext, VCF::GTKContext, VCF::GTKFont, VCF::GTKGraphicsToolkit, VCF::GTKImage, VCF::ImageEvent, VCF::OSXContext, VCF::OSXFont, VCF::OSXImage, VCF::Point, VCF::Size, VCF::Win32Context, VCF::Win32FontManager, VCF::Win32Image, VCF::Win32GrayScaleImage, VCFNet::Socket, and VCF::OpenGLControlContext. |
|
|
returns whether or not debug memory tracking is on
|
|
|
This determines if object is equal to this the equivalent of operator ==().
Reimplemented in VCF::Matrix2D. |
|
|
returns the total number of objects currently allocated. Only meaningful for _DEBUG builds with memory tracking turned on.
|
|
|
decrements the reference count of the object
|
|
|
returns a string representation of the object
Reimplemented in VCF::AbstractWin32Component, VCFCOM::DataRendering, VCF::DateTime, VCF::XMLAttr, VCF::XMLNode, VCF::Color, VCF::Size, VCFNet::Socket, VCFRemote::ClassRegistryEntry, and VCFRemote::InstanceID. |
|
|
indicates whether or not debug memory should be tracked. Note that debug memory is tracked only in debug builds (meaning the VCF has been compiled with the _DEBUG symbol defined). Memory tracking is turned off for release builds.
|
Member Data Documentation
|
|
|
The documentation for this class was generated from the following file:
- vcf/FoundationKit/Object.h
