00001 // $Id: walker_utils.h,v 1.1.1.1 2000/06/08 00:10:04 afikes Exp $ 00002 00003 #ifndef OSUIFUTILITIES__WALKER_UTILS_H 00004 #define OSUIFUTILITIES__WALKER_UTILS_H 00005 00006 #include "suifkernel/suifkernel_forwarders.h" 00007 #include "iokernel/cast.h" 00008 #include "common/suif_list.h" 00009 #include "suifkernel/group_walker.h" 00010 00011 00015 class CollectWalker : public SelectiveWalker { 00016 protected: 00017 list<SuifObject *> _hit_list; 00018 00019 public: 00020 CollectWalker( SuifEnv* env, const LString& the_type ) : 00021 SelectiveWalker( env, the_type) { } 00022 00023 list<SuifObject*> get_hit_list() { return _hit_list; } 00024 00025 ApplyStatus operator () (SuifObject* obj) =0; 00026 }; 00027 00028 00033 template<class T> 00034 class CollectWalkerT : public CollectWalker { 00035 public: 00036 CollectWalkerT( SuifEnv* env ) : 00037 CollectWalker( env, T::get_class_name() ) { } 00038 00039 // iterator interface 00040 unsigned size() { return _hit_list.size(); } 00041 T* at( int i ) { return to<T>( _hit_list[i] ); } 00042 T* operator[]( int i ) { return at(i); } 00043 00044 ApplyStatus operator () (SuifObject* obj) { 00045 T* hit = to<T>( obj ); 00046 _hit_list.push_back( hit ); 00047 return Walker::Continue; 00048 } 00049 }; 00050 00051 00052 #endif /* OSUIFUTILITIES__WALKER_UTILS_H */