![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
00001 00014 using namespace std; 00015 00016 #ifndef LIST 00017 #define LIST //!<Inclusion guard 00018 #include <list> 00019 #endif 00020 00021 #ifndef CHILDADDABLE_H 00022 #define CHILDADDABLE_H //!<Inclusion guard. 00023 00027 template <class T> 00028 class ChildAddable 00029 { 00030 public: 00031 ChildAddable() 00032 { 00033 00034 } 00035 00036 ~ChildAddable() 00037 { 00038 for(typename list<T*>::iterator it = myChildren.begin(); it!=myChildren.end(); it++) 00039 { 00040 (*it)->parentDestroyed(); 00041 } 00042 myChildren.clear(); 00043 } 00044 00045 list<T*> getChildren() const 00046 { 00047 return myChildren; 00048 } 00049 00050 void addChild(T * childPtr) 00051 { 00052 myChildren.push_back(childPtr); 00053 } 00054 00055 void removeChild(T * childPtr) 00056 { 00057 myChildren.remove(childPtr); 00058 } 00059 00060 bool operator==(const ChildAddable<T> & rhs) const 00061 { 00062 for(typename list<T*>::const_iterator it = myChildren.begin(); it!=myChildren.end(); it++) 00063 { 00064 bool found = false; 00065 for(typename list<T*>::const_iterator ir = rhs.myChildren.begin(); ir!=rhs.myChildren.end(); ir++) 00066 { 00067 if(*ir!=NULL && *it!=NULL) 00068 { 00069 //TODO: 00070 //compare objects, not pointers to objects. 00071 if(*ir==*it) 00072 found = true; 00073 } 00074 } 00075 if(!found) 00076 return false; 00077 } 00078 return true; 00079 } 00080 protected: 00081 list<T*> myChildren; 00082 }; 00083 #endif