/[enigma]/enigma/src/object_mixins.hh
ViewVC logotype

Diff of /enigma/src/object_mixins.hh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by reallysoft, Fri Mar 28 10:01:21 2003 UTC revision 1.4 by dheck, Fri Apr 4 19:37:29 2003 UTC
# Line 24  Line 24 
24    
25  namespace world  namespace world
26  {  {
27  #define CLONEOBJ(type)                                                  \  #define CLONEOBJ(TYPE)                                  \
28          Object* clone() { Object *o= new type; o->init(); return o;}    \          TYPE* clone() { return new TYPE(*this); }       \
29          void dispose() { delete this; }          void dispose() { delete this; }
30    
31    #define CLONEACTOR(TYPE)                                                \
32            TYPE* clone() { TYPE *o=new TYPE(*this); o->init(); return o; } \
33            void dispose() { delete this; }
34    
35    
36  #define SINGLETONOBJ()                          \  #define SINGLETONOBJ()                          \
37          Object* clone() { return this; }        \          TYPE* clone() { return this; }          \
38          void dispose() {}          void dispose() {}
39    
40    
41  #define INSTANCELISTOBJ(type)                                                           \  #define INSTANCELISTOBJ(TYPE)                                                   \
42          typedef std::vector<type*> InstanceList;                                        \          typedef std::vector<TYPE*> InstanceList;                                \
43          static InstanceList instances;                                                  \          static InstanceList instances;                                          \
44          Object *clone() { type *o = new type; instances.push_back(o); return o;}        \          TYPE *clone() { TYPE *o = new TYPE(*this); instances.push_back(o); return o;}  \
45          void dispose() {                                                                \          void dispose() {                                                        \
46              instances.erase(find(instances.begin(), instances.end(), this));            \              instances.erase(find(instances.begin(), instances.end(), this));    \
47              delete this;                                                                \              delete this;                                                        \
48          }          }
49    
50  //----------------------------------------  //----------------------------------------

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26