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 |
//---------------------------------------- |
//---------------------------------------- |