21 #include <tjutils/tjutils.h>
22 #include <tjutils/tjstring.h>
29 template<
class T,
class E>
39 void clear_instances() {
40 for(
typename STD_list<T*>::iterator it=instances.begin();it!=instances.end();++it)
delete (*it);
44 T& set_embed_body (
const E& embeddedBody) {
45 T* embedptr=
static_cast<T*
>(
this);
47 if(embedptr) newinst=
new T(*embedptr);
49 newinst->set_body(embeddedBody);
50 newinst->set_label(STD_string(newinst->get_label())+
itos(instances.size()));
51 instances.push_back(newinst);
55 T& set_embed_body (E& embeddedBody) {
56 T* embedptr=
static_cast<T*
>(
this);
58 if(embedptr) newinst=
new T(*embedptr);
60 newinst->set_body(embeddedBody);
61 newinst->set_label(STD_string(newinst->get_label())+
itos(instances.size()));
62 instances.push_back(newinst);
67 typedef typename STD_list<T*>::iterator institer;
68 institer get_inst_begin() {
return instances.begin();}
69 institer get_inst_end() {
return instances.end();}
71 typedef typename STD_list<T*>::const_iterator constinstiter;
72 constinstiter get_const_inst_begin()
const {
return instances.begin();}
73 constinstiter get_const_inst_end()
const {
return instances.end();}
76 STD_list<T*> instances;
STD_string itos(int i, unsigned int maxabs=0)