storage.h
Go to the documentation of this file.
00001 
00059 /*
00060  * storage.h
00061  *
00062  *  Created on: 11.06.2012
00063  *      Author: josh
00064  */
00065 
00066 #ifndef STORAGE_H_
00067 #define STORAGE_H_
00068 
00069 
00070 namespace Slam  
00071 {
00072 
00092   template<typename NODE>
00093   class Storage
00094   {
00095 
00096     int seq_nr_, seq_thr_;
00097 
00098     struct STORAGE
00099     {
00100       typename NODE::Ptr node_;
00101       int seq_nr_;
00102     };
00103 
00104     std::list<STORAGE> used_list_;
00105 
00106   public:
00107 
00108     Storage(const int thr):
00109       seq_nr_(0),
00110       seq_thr_(thr)
00111     {
00112 
00113     }
00114 
00115     void update(typename NODE::Ptr node)
00116     {
00117       for(std::list<STORAGE>::iterator it=used_list_.begin(); it!=used_list_.end(); it++)
00118       {
00119         if(it->node_ == node)
00120         {
00121           it->seq_nr_ = seq_nr_;
00122           used_list_.push_back(*it);
00123           used_list_.remove(it);
00124           return;
00125         }
00126       }
00127 
00128       Storage S;
00129       S.seq_nr_ = seq_nr_;
00130       S.node_ = node;
00131 
00132       used_list_.push_back(S);
00133     }
00134 
00135     void finish()
00136     {
00137       ++seq_nr_;
00138       for(std::list<STORAGE>::iterator it=used_list_.begin(); it!=used_list_.end(); it++)
00139       {
00140         if(seq_nr_-it->seq_nr_>seq_thr_)
00141         {
00142           it->node_->store();
00143           it->node_->remove();
00144         }
00145         else
00146           return;
00147       }
00148     }
00149 
00150   };
00151 
00152 };
00153 
00154 
00155 #endif /* STORAGE_H_ */


cob_3d_mapping_slam
Author(s): Joshua Hampp
autogenerated on Wed Aug 26 2015 11:04:51