Commit ca499bb7 authored by Pavel Vainerman's avatar Pavel Vainerman

(UniSetManager): use std::function

parent 469532a0
...@@ -126,10 +126,11 @@ namespace uniset ...@@ -126,10 +126,11 @@ namespace uniset
// Функции для работы со списками подчиненных объектов // Функции для работы со списками подчиненных объектов
// --------------- // ---------------
UniSetManagerList::const_iterator beginMList(); typedef std::function<void(const std::shared_ptr<UniSetObject>&)> OFunction;
UniSetManagerList::const_iterator endMList(); void apply_for_objects( OFunction f );
ObjectsList::const_iterator beginOList();
ObjectsList::const_iterator endOList(); typedef std::function<void(const std::shared_ptr<UniSetManager>&)> MFunction;
void apply_for_managers( MFunction f );
private: private:
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <functional> #include <functional>
#include <algorithm> #include <algorithm>
#include "Configuration.h"
#include "Exceptions.h" #include "Exceptions.h"
#include "ORepHelpers.h" #include "ORepHelpers.h"
#include "UInterface.h" #include "UInterface.h"
...@@ -247,7 +248,7 @@ void UniSetManager::managers( OManagerCommand cmd ) ...@@ -247,7 +248,7 @@ void UniSetManager::managers( OManagerCommand cmd )
//lock //lock
uniset_rwmutex_rlock lock(mlistMutex); uniset_rwmutex_rlock lock(mlistMutex);
for( auto& li : mlist ) for( const auto& li: mlist )
{ {
if( !li ) if( !li )
continue; continue;
...@@ -346,7 +347,7 @@ void UniSetManager::objects(OManagerCommand cmd) ...@@ -346,7 +347,7 @@ void UniSetManager::objects(OManagerCommand cmd)
//lock //lock
uniset_rwmutex_rlock lock(olistMutex); uniset_rwmutex_rlock lock(olistMutex);
for( auto& li : olist ) for( const auto& li: olist )
{ {
if( !li ) if( !li )
continue; continue;
...@@ -606,11 +607,11 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S ...@@ -606,11 +607,11 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
if( ind > uplimit ) if( ind > uplimit )
return ind; return ind;
for( auto it = mngr->beginOList(); it != mngr->endOList(); ++it ) for( const auto& o: olist )
{ {
try try
{ {
SimpleInfo_var si = (*it)->getInfo(userparam); SimpleInfo_var si = o->getInfo(userparam);
(*seq)[ind] = si; (*seq)[ind] = si;
ind++; ind++;
...@@ -624,7 +625,7 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S ...@@ -624,7 +625,7 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
catch(...) catch(...)
{ {
uwarn << myname << "(getObjectsInfo): не смог получить у объекта " uwarn << myname << "(getObjectsInfo): не смог получить у объекта "
<< uniset_conf()->oind->getNameById( (*it)->getId() ) << " информацию" << endl; << uniset_conf()->oind->getNameById( o->getId() ) << " информацию" << endl;
} }
} }
...@@ -632,9 +633,9 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S ...@@ -632,9 +633,9 @@ int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, S
return ind; return ind;
// а далее у его менеджеров (рекурсивно) // а далее у его менеджеров (рекурсивно)
for( auto& i : mlist ) for( const auto& m: mlist )
{ {
ind = getObjectsInfo(i, seq, ind, uplimit, userparam ); ind = getObjectsInfo(m, seq, ind, uplimit, userparam );
if( ind > uplimit ) if( ind > uplimit )
break; break;
...@@ -664,24 +665,16 @@ SimpleInfoSeq* UniSetManager::getObjectsInfo(CORBA::Long maxlength, const char* ...@@ -664,24 +665,16 @@ SimpleInfoSeq* UniSetManager::getObjectsInfo(CORBA::Long maxlength, const char*
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniSetManagerList::const_iterator UniSetManager::beginMList() void UniSetManager::apply_for_objects( OFunction f )
{ {
return mlist.begin(); for( const auto& o: olist )
f(o);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniSetManagerList::const_iterator UniSetManager::endMList() void UniSetManager::apply_for_managers(UniSetManager::MFunction f)
{ {
return mlist.end(); for( const auto& m: mlist )
} f(m);
// ------------------------------------------------------------------------------------------
ObjectsList::const_iterator UniSetManager::beginOList()
{
return olist.begin();
}
// ------------------------------------------------------------------------------------------
ObjectsList::const_iterator UniSetManager::endOList()
{
return olist.end();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
size_t UniSetManager::objectsCount() const size_t UniSetManager::objectsCount() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment