$szTitle = "wxcustomdataobject"; include "./_header.inc"; ?>
wxcustomdataobject is a specialization of wxdataobjectsimple for some application-specific data in arbitrary (either custom or one of the standard ones). the only restriction is that it is supposed that this data can be copied bitwise (i.e. with memcpy()), so it would be a bad idea to make it contain a c++ object (though c struct is fine).
by default, wxcustomdataobject stores the data inside in a buffer. to put the data into the buffer you may use either setdata or takedata depending on whether you want the object to make a copy of data or not.
if you already store the data in another place, it may be more convenient and efficient to provide the data on-demand which is possible too if you override the virtual functions mentioned below.
virtual functions to override
this class may be used as is, but if you don't want store the data inside the object but provide it on demand instead, you should override getsize, getdata and setdata (or may be only the first two or only the last one if you only allow reading/writing the data)
derived from
wxdataobjectsimple
wxdataobject
include files
<wx/dataobj.h>
see also
members
wxcustomdataobject::wxcustomdataobject
wxcustomdataobject::~wxcustomdataobject
wxcustomdataobject::alloc
wxcustomdataobject::free
wxcustomdataobject::getsize
wxcustomdataobject::getdata
wxcustomdataobject::setdata
wxcustomdataobject::takedata
wxcustomdataobject(const wxdataformat& format = wxformatinvalid)
the constructor accepts a format argument which specifies the (single) format supported by this object. if it isn't set here, setformat should be used.
~wxcustomdataobject()
the destructor will free the data hold by the object. notice that although it calls a virtual free() function, the base class version will always be called (c++ doesn't allow calling virtual functions from constructors or destructors), so if you override free(), you should override the destructor in your class as well (which would probably just call the derived class' version of free()).
virtual void * alloc(size_t size)
this function is called to allocate size bytes of memory from setdata(). the default version just uses the operator new.
virtual void free()
this function is called when the data is freed, you may override it to anything you want (or may be nothing at all). the default version calls operator delete[] on the data.
virtual size_t getsize() const
returns the data size in bytes.
virtual void * getdata() const
returns a pointer to the data.
virtual void setdata( size_t size, const void *data)
set the data. the data object will make an internal copy.
wxpython note: this method expects a string in wxpython. you can pass nearly any object by pickling it first.
virtual void takedata( size_t size, const void *data)
like setdata, but doesn't copy the data - instead the object takes ownership of the pointer.
wxpython note: this method expects a string in wxpython. you can pass nearly any object by pickling it first.
include "./_footer.inc"; ?>