// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __OBJECTH__
-#define __OBJECTH__
+#ifndef _WX_OBJECTH__
+#define _WX_OBJECTH__
#ifdef __GNUG__
-#pragma interface
+#pragma interface "object.h"
#endif
#include "wx/defs.h"
#endif
class WXDLLEXPORT wxClassInfo;
-
-class WXDLLIMPORT istream;
class WXDLLIMPORT ostream;
+class WXDLLEXPORT wxInputStream;
+class WXDLLEXPORT wxObjectInputStream;
+class WXDLLEXPORT wxObjectOutputStream;
+class WXDLLEXPORT wxHashTable;
+class WXDLLEXPORT wxObject_Serialize;
/*
* Dynamic object system declarations
typedef wxObject * (*wxObjectConstructorFn) (void);
-#ifdef USE_STORABLE_CLASSES
-typedef wxObject* (*wxStorableConstructorFn) ( istream &stream, char *data );
-#endif
-
class WXDLLEXPORT wxClassInfo
{
public:
int objectSize;
wxObjectConstructorFn objectConstructor;
-#ifdef USE_STORABLE_CLASSES
- wxStorableConstructorFn storableConstructor;
-#endif
-
// Pointers to base wxClassInfos: set in InitializeClasses
// called from wx_main.cc
wxClassInfo *baseInfo1;
static wxClassInfo *first;
wxClassInfo *next;
-#ifdef USE_STORABLE_CLASSES
- wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn,
- wxStorableConstructorFn stoFn = NULL );
-#else
+ static wxHashTable classTable;
+
wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn);
-#endif
wxObject *CreateObject(void);
-#ifdef USE_STORABLE_CLASSES
- wxObject* CreateObject( istream &stream, char *data );
-#endif
-
inline char *GetClassName(void) const { return className; }
inline char *GetBaseClassName1(void) const { return baseClassName1; }
inline char *GetBaseClassName2(void) const { return baseClassName2; }
wxObject* WXDLLEXPORT wxCreateDynamicObject(char *name);
-#ifdef USE_STORABLE_CLASSES
-wxObject* WXDLLEXPORT wxCreateStoredObject( char *name, istream &stream, char *data );
+#ifdef USE_SERIAL
+wxObject* WXDLLEXPORT wxCreateStoredObject( wxInputStream& stream );
#endif
#define DECLARE_DYNAMIC_CLASS(name) \
#define DECLARE_ABSTRACT_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
-#ifdef USE_STORABLE_CLASSES
-#define DECLARE_STORABLECLASS(name) DECLARE_DYNAMIC_CLASS(name)
-#endif
-
//////
////// for concrete classes
//////
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
{ return new name; }\
- wxClassInfo name::class##name(#name, #basename, NULL, sizeof(name), wxConstructorFor##name);
+ wxClassInfo name::class##name((char *) #name, (char *) #basename, (char *) NULL, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);
// Multiple inheritance with two base classes
#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
{ return new name; }\
- wxClassInfo name::class##name(#name, #basename1, #basename2, sizeof(name), wxConstructorFor##name);
+ wxClassInfo name::class##name((char *) #name, (char *) #basename1, (char *) #basename2, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);
-//////
-////// for storable classes
-//////
-
-#ifdef USE_STORABLE_CLASSES
-
-#define IMPLEMENT_STORABLE_CLASS(name, basename) \
-wxObject* WXDLLEXPORT_CTORFN wxStorableConstructorFor##name( fstream* stream, char* data )\
- { return new name( stream, data ); }\
-wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void)\
- { return new name; }\
- wxClassInfo name::class##name(#name, #basename, NULL, sizeof(name), wxConstructorFor##name,\
- wxStorableConstructorFor##name );
-
-#define IMPLEMENT_STORABLE_CLASS2(name, basename1, basename2) \
-wxObject* WXDLLEXPORT_CTORFN wxStorableConstructorFor##name( fstream* stream, char* data )\
- { return new name( stream, data ); }\
-wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void)\
- { return new name; }\
- wxClassInfo name::class##name(#name, #basename1, basename2, sizeof(name), wxConstructorFor##name,\
- wxStorableConstructorFor##name );
-
-#endif
-
//////
////// for abstract classes
//////
// Single inheritance with one base class
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
- wxClassInfo name::class##name(#name, #basename, NULL, sizeof(name), NULL);
+ wxClassInfo name::class##name((char *) #name, (char *) #basename, \
+ (char *) NULL, (int) sizeof(name), (wxObjectConstructorFn) NULL);
// Multiple inheritance with two base classes
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
- wxClassInfo name::class##name(#name, #basename1, #basename2, sizeof(name), NULL);
+ wxClassInfo name::class##name((char *) #name, (char *) #basename1, (char *) #basename2, (int) sizeof(name), (wxObjectConstructorFn) NULL);
#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
#endif
-#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##name)
+#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##className)
// Unfortunately Borland seems to need this include.
#ifdef __BORLANDC__
bool IsKindOf(wxClassInfo *info);
-#if DEBUG && USE_MEMORY_TRACING
+#if WXDEBUG && USE_MEMORY_TRACING
void * operator new (size_t size, char * fileName = NULL, int lineNum = 0);
void operator delete (void * buf);
#endif
-#if DEBUG || USE_DEBUG_CONTEXT
+#if WXDEBUG || USE_DEBUG_CONTEXT
virtual void Dump(ostream& str);
#endif
-#ifdef USE_STORABLE_CLASSES
- virtual void StoreObject( ostream &WXUNUSED(stream) ) {};
+#ifdef USE_SERIAL
+ virtual void StoreObject( wxObjectOutputStream &stream );
+ virtual void LoadObject( wxObjectInputStream &stream );
#endif
// make a 'clone' of the object
protected:
wxObjectRefData *m_refData;
+#ifdef USE_SERIAL
+ wxObject_Serialize *m_serialObj;
+#endif
};
/*
int m_count;
};
-#if DEBUG && USE_GLOBAL_MEMORY_OPERATORS
+#if WXDEBUG && USE_GLOBAL_MEMORY_OPERATORS
#ifndef WXDEBUG_NEW
#define WXDEBUG_NEW new(__FILE__,__LINE__)
#endif
#endif
#endif
- // __OBJECTH__
+ // _WX_OBJECTH__