home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWCOLLECT_H__
- #define __RWCOLLECT_H__
- pragma push_align_members(64);
-
- /*
- * Declarations for RWCollectables: an abstract base class.
- *
- * $Header: E:/vcs/rw/collect.h_v 1.8 17 Mar 1992 12:26:36 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave Software, Inc.
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/collect.h_v $
- *
- * Rev 1.8 17 Mar 1992 12:26:36 KEFFER
- * Removed RWTV3_COMPATIBLE macro hooks.
- *
- * Rev 1.7 17 Mar 1992 11:32:36 KEFFER
- * Moved process initialization stuff.
- * Introduced DECLARE_COLLECTABLE macro.
- * Introduced RW generic.h header file.
- *
- * Rev 1.6 21 Feb 1992 12:29:26 KEFFER
- * nil collectable now defined when using the DLL.
- *
- * Rev 1.5 15 Nov 1991 13:01:06 keffer
- *
- * Rev 1.4 13 Nov 1991 11:07:42 keffer
- * More robust DLL code; No longer declares GVector(RWCollectable); store and
- * read tables now maintained by a separate manager.
- *
- * Rev 1.3 28 Oct 1991 09:08:10 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.2 09 Oct 1991 18:34:32 keffer
- * Ported to Zortech V3.0
- *
- */
-
- #ifndef __RWTOOLDEFS_H__
- # include "rw/tooldefs.h"
- #endif
- #ifndef __RWMEMPOOL_H__
- # include "rw/mempool.h"
- #endif
- #ifndef __RWGENERIC_H__
- # include "rw/generic.h"
- #endif
- #if !defined(__RWPROCINIT_H__) && defined(RW_MULTI_THREAD)
- # include "rw/procinit.h"
- #endif
- #ifdef UNDEFINED_REFERENCE_BUG
- # include "rw/rstream.h"
- #endif
-
- /************************************************************************
- * *
- * The macro DECLARE_COLLECTABLE should be included in the declaration *
- * of any class that derives from RWCollectable. *
- * *
- ************************************************************************/
-
- #define DECLARE_COLLECTABLE(className) \
- public: \
- virtual ClassID isA() const; \
- virtual RWCollectable* newSpecies() const;
-
-
- // Base class for collectable objects.
-
- class RWExport RWCollectable {
-
- DECLARE_COLLECTABLE(RWCollectable)
-
- public:
-
- RWCollectable();
- virtual ~RWCollectable();
-
- virtual unsigned binaryStoreSize() const;
- virtual int compareTo(const RWCollectable*) const;
- virtual unsigned hash() const;
- virtual RWBoolean isEqual(const RWCollectable*) const;
- virtual void restoreGuts(RWFile&);
- virtual void restoreGuts(RWvistream&);
- virtual void saveGuts(RWFile&) const;
- virtual void saveGuts(RWvostream&) const;
- unsigned shallowStoreSize() const;
- static RWCollectable* restoreFrom(RWFile&);
- static RWCollectable* restoreFrom(RWvistream&);
- void saveOn(RWFile&) const;
- void saveOn(RWvostream&) const;
- };
-
- extern void rwexport rwDestroy(RWCollectable*, void*);
- extern RWBoolean rwexport rwIsEqualFun(const void* a, const void* b);
- extern void rwexport rwAddToFactory(userCreator fn, ClassID id);
- extern RWCollectable* rwexport rwCreateFromFactory(ClassID);
- extern void rwexport rwRemoveFromFactory(ClassID);
-
- #ifdef RW_MULTI_THREAD
- // Multi-thread situation; get nil object from the instance mgr.
- extern RWCollectable* getRWNilCollectable();
- # define RWnilCollectable (getRWNilCollectable())
- #else
- // Not a multi-threaded situation; use a global nil object.
- extern RWCollectable* RWnilCollectable;
- #endif
-
- /************************************************************************
- * *
- * The macro DEFINE_COLLECTABLE presently serves two functions: *
- * 1) To define and insert a "creator function" to be inserted *
- * into the one-of-a-kind global RWFactory pointed to by theFactory. *
- * 2) To provide a definition for newSpecies(). *
- * *
- * They cannot be combined using a pointer to member function *
- * because there is no global instance that can be used to *
- * dereference it. *
- ************************************************************************/
-
- #define Init(className) name2(className,Init)
- #define createFN(className) name2(className,createFN)
-
- #define DEFINE_COLLECTABLE(className) \
- \
- /* Member function to create an instance of the class.*/ \
- RWCollectable* className::newSpecies() const \
- { return new className; } \
- \
- struct Init(className) { \
- Init(className)(); \
- ~Init(className)(); \
- }; \
- \
- /* Global function to create an instance of the class.*/ \
- RWCollectable* \
- createFN(className)() \
- { return new className; } \
- \
- /* The constructor adds the function to the Factory. */ \
- Init(className)::Init(className)(){ \
- className temp; \
- rwAddToFactory(createFN(className), temp.isA()); \
- } \
- \
- Init(className)::~Init(className)(){ \
- className temp; \
- rwRemoveFromFactory(temp.isA()); \
- } \
- \
- /* Invoke the constructor to do the job: */ \
- Init(className) name2(Dummy,className);
-
- pragma pop_align_members();
- #endif /* __RWCOLLECT_H__ */
-