* Fixes and new features in wxObject*Stream
* Fixes: wxChoice (GTK), wxCheckBox (GTK) * Fixes: wxStream * wxObject calls wx*Serialize::LoadObject/StoreObject in StoreObject/LoadObject * Added support for dynamic library (Linux only, Windows will follow) * Added serbase.h (Serialization base defines and base object) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
95
include/wx/dynlib.h
Normal file
95
include/wx/dynlib.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef __DYNLIB_H__
|
||||
#define __DYNLIB_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/list.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Some more info on a class
|
||||
|
||||
typedef struct {
|
||||
wxClassInfo *class_info;
|
||||
wxString path;
|
||||
} wxClassLibInfo;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Useful arrays
|
||||
|
||||
WX_DEFINE_ARRAY(wxClassInfo *, wxArrayClassInfo);
|
||||
WX_DEFINE_ARRAY(wxClassLibInfo *, wxArrayClassLibInfo);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxClassLibrary
|
||||
|
||||
class wxClassLibrary {
|
||||
protected:
|
||||
wxArrayClassLibInfo m_list;
|
||||
public:
|
||||
wxClassLibrary(void);
|
||||
~wxClassLibrary(void);
|
||||
|
||||
// Dynamic (un)register a (new) class in the database
|
||||
void RegisterClass(wxClassInfo *class_info, const wxString& path);
|
||||
void UnregisterClass(wxClassInfo *class_info);
|
||||
|
||||
// Fetch all infos whose name matches the string (wildcards allowed)
|
||||
bool FetchInfos(const wxString& path, wxArrayClassLibInfo& infos);
|
||||
|
||||
// Create all objects whose name matches the string (wildcards allowed)
|
||||
bool CreateObjects(const wxString& path, wxArrayClassInfo& objs);
|
||||
|
||||
// Create one object using the EXACT name
|
||||
wxObject *CreateObject(const wxString& path);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxLibrary
|
||||
|
||||
class wxLibrary: public wxObject {
|
||||
protected:
|
||||
wxClassLibrary *m_liblist;
|
||||
void *m_handle;
|
||||
public:
|
||||
wxLibrary(void *handle);
|
||||
~wxLibrary(void);
|
||||
|
||||
// Get a symbol from the dynamic library
|
||||
void *GetSymbol(const wxString& symbname);
|
||||
|
||||
// Create the object whose classname is "name"
|
||||
wxObject *CreateObject(const wxString& name);
|
||||
|
||||
wxClassLibrary *ClassLib() const;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxLibraries
|
||||
|
||||
class wxLibraries {
|
||||
protected:
|
||||
wxList m_loaded;
|
||||
public:
|
||||
wxLibraries(void);
|
||||
~wxLibraries(void);
|
||||
|
||||
wxLibrary *LoadLibrary(const wxString& name);
|
||||
wxObject *CreateObject(const wxString& name);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Global variables
|
||||
|
||||
extern wxLibraries wxTheLibraries;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Interesting defines
|
||||
|
||||
#define WXDLL_ENTRY_FUNCTION() extern "C" wxClassLibrary *GetClassList()
|
||||
#define WXDLL_EXIT_FUNCTION(param) extern "C" void FreeClassList(wxClassLibrary *param)
|
||||
|
||||
#endif
|
@@ -179,8 +179,8 @@ class WXDLLEXPORT wxObject
|
||||
#endif
|
||||
|
||||
#ifdef USE_STORABLE_CLASSES
|
||||
virtual void StoreObject( wxObjectOutputStream &WXUNUSED(stream) ) {};
|
||||
virtual void LoadObject( wxObjectInputStream &WXUNUSED(stream) ) {};
|
||||
virtual void StoreObject( wxObjectOutputStream &stream );
|
||||
virtual void LoadObject( wxObjectInputStream &stream );
|
||||
#endif
|
||||
|
||||
// make a 'clone' of the object
|
||||
|
@@ -23,9 +23,9 @@
|
||||
class wxObjectStreamInfo : public wxObject {
|
||||
public:
|
||||
wxString object_name;
|
||||
int n_children;
|
||||
int n_children, children_removed;
|
||||
wxList children;
|
||||
wxObject *parent;
|
||||
wxObjectStreamInfo *parent;
|
||||
wxObject *object;
|
||||
};
|
||||
|
||||
@@ -56,7 +56,9 @@ class wxObjectInputStream : public wxFilterInputStream {
|
||||
wxObjectInputStream(wxInputStream& s);
|
||||
|
||||
wxObject *GetChild(int no) const;
|
||||
wxObject *GetParent() const { return m_current_info->parent; }
|
||||
int NumberOfChildren() const { return m_current_info->n_children; }
|
||||
void RemoveChildren(int nb);
|
||||
wxObject *GetParent() const;
|
||||
wxObject *LoadObject();
|
||||
|
||||
wxObject *SolveName(const wxString& objName) const;
|
||||
|
57
include/wx/serbase.h
Normal file
57
include/wx/serbase.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: serbase.h
|
||||
// Purpose: Serialization plug-ins
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: July 1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __WX_SERBASEH_H__
|
||||
#define __WX_SERBASEH_H__
|
||||
|
||||
#include <wx/dynlib.h>
|
||||
|
||||
#define WXSERIAL(classname) classname##_Serialize
|
||||
|
||||
class wxObject_Serialize : public wxObject {
|
||||
DECLARE_DYNAMIC_CLASS(wxObject_Serialize)
|
||||
public:
|
||||
wxObject_Serialize() {}
|
||||
virtual ~wxObject_Serialize() {}
|
||||
|
||||
void SetObject(wxObject *obj) { m_object = obj; }
|
||||
wxObject *Object() { return m_object; }
|
||||
|
||||
protected:
|
||||
wxObject *m_object;
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_SERIAL_CLASS(classname, parent) \
|
||||
class WXSERIAL(classname) : public WXSERIAL(parent) { \
|
||||
DECLARE_DYNAMIC_CLASS(classname##_Serialize) \
|
||||
public: \
|
||||
WXSERIAL(classname)() { } \
|
||||
virtual ~WXSERIAL(classname)() { } \
|
||||
\
|
||||
virtual void StoreObject(wxObjectOutputStream& stream); \
|
||||
virtual void LoadObject(wxObjectInputStream& stream); \
|
||||
};
|
||||
|
||||
#define DECLARE_ALIAS_SERIAL_CLASS(classname, parent) \
|
||||
class WXSERIAL(classname) : public WXSERIAL(parent) { \
|
||||
DECLARE_DYNAMIC_CLASS(classname##_Serialize) \
|
||||
public: \
|
||||
WXSERIAL(classname)() { } \
|
||||
virtual ~WXSERIAL(classname)() { } \
|
||||
};
|
||||
|
||||
#define IMPLEMENT_SERIAL_CLASS(classname, parent) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
|
||||
|
||||
#define IMPLEMENT_ALIAS_SERIAL_CLASS(classname, parent) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
|
||||
|
||||
#endif
|
@@ -78,8 +78,8 @@ class WXDLLEXPORT wxInputStream {
|
||||
wxInputStream& Read(wxOutputStream& stream_out);
|
||||
|
||||
// Position functions
|
||||
off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellI() const;
|
||||
virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
virtual off_t TellI() const;
|
||||
|
||||
// State functions
|
||||
bool Eof() const { return m_eof; }
|
||||
@@ -174,6 +174,7 @@ class WXDLLEXPORT wxFilterInputStream: public wxInputStream {
|
||||
|
||||
virtual bool Eof() const { return m_parent_i_stream->Eof(); }
|
||||
virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); }
|
||||
virtual off_t TellI() const { return m_parent_i_stream->TellI(); }
|
||||
|
||||
protected:
|
||||
virtual size_t DoRead(void *buffer, size_t size);
|
||||
@@ -191,9 +192,9 @@ class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
|
||||
|
||||
virtual bool Bad() const { return m_parent_o_stream->Bad(); }
|
||||
virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
|
||||
virtual off_t TellO() const { return m_parent_o_stream->TellO(); }
|
||||
|
||||
protected:
|
||||
|
||||
// The forward is implicitely done by wxStreamBuffer.
|
||||
|
||||
virtual size_t DoWrite(const void *buffer, size_t size);
|
||||
|
Reference in New Issue
Block a user