1 #include <tjutils/tjlist.h>
2 #include <tjutils/tjlog.h>
10 ListItem<I>::~ListItem() {
13 ODINLOG(odinlog,normalDebug) <<
"deleting object of type >" <<
typeid(I).name() <<
"<" << STD_endl;
16 for(STD_list<ListBase*>::iterator it=objhandlers.begin(); it!=objhandlers.end(); ++it) {
17 (*it)->objlist_remove(
this);
22 const ListItemBase& ListItem<I>::append_objhandler(ListBase& objhandler)
const {
24 objhandlers.push_back(&objhandler);
29 const ListItemBase& ListItem<I>::remove_objhandler(ListBase& objhandler)
const {
31 objhandlers.remove(&objhandler);
38 template<
class I,
class P,
class R>
42 ODINLOG(odinlog,normalDebug) <<
"constructing list of >" <<
typeid(I).name() <<
"<" << STD_endl;
46 template<
class I,
class P,
class R>
50 ODINLOG(odinlog,normalDebug) <<
"destructing list of >" <<
typeid(I).name() <<
"<" << STD_endl;
55 template<
class I,
class P,
class R>
58 for(
typename STD_list<P>::const_iterator it=l.objlist.begin(); it!=l.objlist.end(); ++it) {
64 template<
class I,
class P,
class R>
68 ODINLOG(odinlog,normalDebug) <<
"Clearing list of type >" <<
typeid(I).name() <<
"<" << STD_endl;
70 for(
typename STD_list<P>::iterator it=objlist.begin(); it!=objlist.end(); ++it) {
71 ODINLOG(odinlog,normalDebug) <<
"Unlinking " << (*it) << STD_endl;
75 ODINLOG(odinlog,normalDebug) <<
"Unlinking done" << STD_endl;
77 objlist.erase(objlist.begin(),objlist.end());
81 template<
class I,
class P,
class R>
85 ODINLOG(odinlog,normalDebug) <<
"appending object of type >" <<
typeid(I).name() <<
"<" << STD_endl;
88 objlist.push_back(&item);
92 template<
class I,
class P,
class R>
96 ODINLOG(odinlog,normalDebug) <<
"removing object of type >" <<
typeid(I).name() <<
"<" << STD_endl;
99 objlist.remove(&item);
103 template<
class I,
class P,
class R>
107 ODINLOG(odinlog,normalDebug) <<
"deleting object of type >" <<
typeid(I).name() <<
"<" << STD_endl;
109 P itemItype=
static_cast<P
>(item);
111 objlist.remove(itemItype);
113 ODINLOG(odinlog,errorLog) <<
"static_cast failed" << STD_endl;
118 template<
class I,
class P,
class R>
121 const ListItem<I>* item=
static_cast<const ListItem<I>*
>(ptr);
123 item->append_objhandler(*
this);
125 ODINLOG(odinlog,errorLog) <<
"static_cast failed" << STD_endl;
129 template<
class I,
class P,
class R>
132 const ListItem<I>* item=
static_cast<const ListItem<I>*
>(ptr);
134 item->remove_objhandler(*
this);
136 ODINLOG(odinlog,errorLog) <<
"static_cast failed" << STD_endl;
List & operator=(const List &l)