ComponentActionListener.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #include <rtm/ComponentActionListener.h>
00020 
00021 namespace RTC
00022 {
00023 
00024   //============================================================
00032   PostComponentActionListener::~PostComponentActionListener(){}
00033 
00041   PreComponentActionListener::~PreComponentActionListener(){}
00042 
00050   PortActionListener::~PortActionListener(){}
00051   
00059   ExecutionContextActionListener::~ExecutionContextActionListener(){}
00060   
00061 
00062 
00063 
00064 
00065   //============================================================
00073   PreComponentActionListenerHolder::PreComponentActionListenerHolder()
00074   {
00075   }
00076     
00077   
00078   PreComponentActionListenerHolder::~PreComponentActionListenerHolder()
00079   {
00080     Guard guard(m_mutex);
00081     for (int i(0), len(m_listeners.size()); i < len; ++i)
00082       {
00083         if (m_listeners[i].second)
00084           {
00085             delete m_listeners[i].first;
00086           }
00087       }
00088   }
00089 
00090   
00091   void PreComponentActionListenerHolder::
00092   addListener(PreComponentActionListener* listener,
00093               bool autoclean)
00094   {
00095     Guard guard(m_mutex);
00096     m_listeners.push_back(Entry(listener, autoclean));
00097   }
00098   
00099   
00100   void PreComponentActionListenerHolder::
00101   removeListener(PreComponentActionListener* listener)
00102   {
00103     Guard guard(m_mutex);
00104     std::vector<Entry>::iterator it(m_listeners.begin());
00105     
00106     for (; it != m_listeners.end(); ++it)
00107       {
00108         if ((*it).first == listener)
00109           {
00110             if ((*it).second)
00111               {
00112                 delete (*it).first;
00113               }
00114             m_listeners.erase(it);
00115             return;
00116           }
00117       }
00118     
00119   }
00120   
00121   
00122   void PreComponentActionListenerHolder::notify(UniqueId ec_id)
00123   {
00124     Guard guard(m_mutex);
00125     for (int i(0), len(m_listeners.size()); i < len; ++i)
00126       {
00127         m_listeners[i].first->operator()(ec_id);
00128       }
00129   }
00130 
00131   //============================================================
00139   PostComponentActionListenerHolder::PostComponentActionListenerHolder()
00140   {
00141   }
00142   
00143 
00144   PostComponentActionListenerHolder::~PostComponentActionListenerHolder()
00145   {
00146     Guard guard(m_mutex);
00147     for (int i(0), len(m_listeners.size()); i < len; ++i)
00148       {
00149         if (m_listeners[i].second)
00150           {
00151             delete m_listeners[i].first;
00152           }
00153       }
00154   }
00155 
00156   
00157   void PostComponentActionListenerHolder::
00158   addListener(PostComponentActionListener* listener, bool autoclean)
00159   {
00160     Guard guard(m_mutex);
00161     m_listeners.push_back(Entry(listener, autoclean));
00162   }
00163 
00164   
00165   void PostComponentActionListenerHolder::
00166   removeListener(PostComponentActionListener* listener)
00167   {
00168     Guard guard(m_mutex);
00169     std::vector<Entry>::iterator it(m_listeners.begin());
00170     for (; it != m_listeners.end(); ++it)
00171       {
00172         if ((*it).first == listener)
00173           {
00174             if ((*it).second)
00175               {
00176                 delete (*it).first;
00177               }
00178             m_listeners.erase(it);
00179             return;
00180           }
00181       }
00182     
00183   }
00184 
00185     
00186   void PostComponentActionListenerHolder::notify(UniqueId ec_id,
00187                                                  ReturnCode_t ret)
00188   {
00189     Guard guard(m_mutex);
00190     for (int i(0), len(m_listeners.size()); i < len; ++i)
00191       {
00192         m_listeners[i].first->operator()(ec_id, ret);
00193       }
00194   }
00195 
00196 
00204   PortActionListenerHolder::PortActionListenerHolder()
00205   {
00206   }
00207     
00208   
00209   PortActionListenerHolder::~PortActionListenerHolder()
00210   {
00211     Guard guard(m_mutex);
00212     for (int i(0), len(m_listeners.size()); i < len; ++i)
00213       {
00214         if (m_listeners[i].second)
00215           {
00216             delete m_listeners[i].first;
00217           }
00218       }
00219   }
00220 
00221   
00222   void PortActionListenerHolder::addListener(PortActionListener* listener,
00223                                              bool autoclean)
00224   {
00225     Guard guard(m_mutex);
00226     m_listeners.push_back(Entry(listener, autoclean));
00227   }
00228   
00229   
00230   void PortActionListenerHolder::removeListener(PortActionListener* listener)
00231   {
00232     Guard guard(m_mutex);
00233     std::vector<Entry>::iterator it(m_listeners.begin());
00234     
00235     for (; it != m_listeners.end(); ++it)
00236       {
00237         if ((*it).first == listener)
00238           {
00239             if ((*it).second)
00240               {
00241                 delete (*it).first;
00242               }
00243             m_listeners.erase(it);
00244             return;
00245           }
00246       }
00247     
00248   }
00249   
00250   
00251   void PortActionListenerHolder::notify(const RTC::PortProfile& pprofile)
00252   {
00253     Guard guard(m_mutex);
00254     for (int i(0), len(m_listeners.size()); i < len; ++i)
00255       {
00256         m_listeners[i].first->operator()(pprofile);
00257       }
00258   }
00259 
00260 
00261 
00269   ExecutionContextActionListenerHolder::ExecutionContextActionListenerHolder()
00270   {
00271   }
00272     
00273   
00274   ExecutionContextActionListenerHolder::~ExecutionContextActionListenerHolder()
00275   {
00276     Guard guard(m_mutex);
00277     for (int i(0), len(m_listeners.size()); i < len; ++i)
00278       {
00279         if (m_listeners[i].second)
00280           {
00281             delete m_listeners[i].first;
00282           }
00283       }
00284   }
00285 
00286   
00287   void ExecutionContextActionListenerHolder::
00288   addListener(ExecutionContextActionListener* listener,
00289               bool autoclean)
00290   {
00291     Guard guard(m_mutex);
00292     m_listeners.push_back(Entry(listener, autoclean));
00293   }
00294   
00295   
00296   void ExecutionContextActionListenerHolder::
00297   removeListener(ExecutionContextActionListener* listener)
00298   {
00299     Guard guard(m_mutex);
00300     std::vector<Entry>::iterator it(m_listeners.begin());
00301     
00302     for (; it != m_listeners.end(); ++it)
00303       {
00304         if ((*it).first == listener)
00305           {
00306             if ((*it).second)
00307               {
00308                 delete (*it).first;
00309               }
00310             m_listeners.erase(it);
00311             return;
00312           }
00313       }
00314     
00315   }
00316   
00317   
00318   void ExecutionContextActionListenerHolder::notify(UniqueId ec_id)
00319   {
00320     Guard guard(m_mutex);
00321     for (int i(0), len(m_listeners.size()); i < len; ++i)
00322       {
00323         m_listeners[i].first->operator()(ec_id);
00324       }
00325   }
00326 
00327 };
00328 
00329 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:03