Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXObject.h
1 /********************************************************************************
2 * *
3 * T o p l e v e l O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2021 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXOBJECT_H
22 #define FXOBJECT_H
23 
24 #ifndef FXMETACLASS_H
25 #include "FXMetaClass.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXStream;
32 
33 
35 #define FXDECLARE(classname) \
36  public: \
37  struct FXMapEntry { FX::FXSelector keylo; FX::FXSelector keyhi; long (classname::* func)(FX::FXObject*,FX::FXSelector,void*); }; \
38  static const FX::FXMetaClass metaClass; \
39  static FX::FXObject* manufacture(); \
40  virtual long handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr); \
41  virtual const FX::FXMetaClass* getMetaClass() const { return &metaClass; } \
42  private:
43 
44 
46 #define FXIMPLEMENT(classname,baseclassname,mapping,nmappings) \
47  FX::FXObject* classname::manufacture(){return new classname;} \
48  const FX::FXMetaClass classname::metaClass(#classname,classname::manufacture,&baseclassname::metaClass,mapping,nmappings,sizeof(classname::FXMapEntry)); \
49  long classname::handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr){ \
50  const FXMapEntry* me=(const FXMapEntry*)metaClass.search(sel); \
51  return me ? (this->* me->func)(sender,sel,ptr) : baseclassname::handle(sender,sel,ptr); \
52  }
53 
54 
56 #define FXDECLARE_ABSTRACT(classname) \
57  public: \
58  struct FXMapEntry { FX::FXSelector keylo; FX::FXSelector keyhi; long (classname::* func)(FX::FXObject*,FX::FXSelector,void*); }; \
59  static const FX::FXMetaClass metaClass; \
60  virtual long handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr); \
61  virtual const FX::FXMetaClass* getMetaClass() const { return &metaClass; } \
62  private:
63 
64 
66 #define FXIMPLEMENT_ABSTRACT(classname,baseclassname,mapping,nmappings) \
67  const FX::FXMetaClass classname::metaClass(#classname,FX::FXMetaClass::nullObject,&baseclassname::metaClass,mapping,nmappings,sizeof(classname::FXMapEntry)); \
68  long classname::handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr){ \
69  const FXMapEntry* me=(const FXMapEntry*)metaClass.search(sel); \
70  return me ? (this->* me->func)(sender,sel,ptr) : baseclassname::handle(sender,sel,ptr); \
71  }
72 
73 
75 #define FXMETACLASS(classname) (&classname::metaClass)
76 
77 
79 #define FXDEFMAP(classname) static const classname::FXMapEntry
80 
82 #define FXMAPTYPES(typelo,typehi,func) {FXSEL(typelo,FX::MINKEY),FXSEL(typehi,FX::MAXKEY),&func}
83 
85 #define FXMAPTYPE(type,func) {FXSEL(type,FX::MINKEY),FXSEL(type,FX::MAXKEY),&func}
86 
88 #define FXMAPFUNCS(type,keylo,keyhi,func) {FXSEL(type,keylo),FXSEL(type,keyhi),&func}
89 
91 #define FXMAPFUNC(type,key,func) {FXSEL(type,key),FXSEL(type,key),&func}
92 
93 
103 class FXAPI FXObject {
104  FXDECLARE(FXObject)
105 public:
106 
108  const FXchar* getClassName() const;
109 
111  FXbool isMemberOf(const FXMetaClass* metaclass) const;
112 
114  virtual long tryHandle(FXObject* sender,FXSelector sel,void* ptr);
115 
117  virtual long onDefault(FXObject*,FXSelector,void*);
118 
120  virtual void save(FXStream& store) const;
121 
123  virtual void load(FXStream& store);
124 
126  virtual ~FXObject();
127  };
128 
129 }
130 
131 #endif
Describes a FOX object.
Definition: FXMetaClass.h:49
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:78
Definition: FX4Splitter.h:28
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:103

Copyright © 1997-2020 Jeroen van der Zijp