Commit 471b4ad7 authored by Pavel Vainerman's avatar Pavel Vainerman

Часто встречающуюся функцию проверки xml-узла на соответсвие фильтру, вынес в…

Часто встречающуюся функцию проверки xml-узла на соответсвие фильтру, вынес в UniSetTypes. Везде (где встретил) перевёл работу на неё.
parent 7d44c190
......@@ -1189,33 +1189,16 @@ void MBTCPMaster::readConfiguration()
for( ;it.getCurrent(); it.goNext() )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
}
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool MBTCPMaster::check_item( UniXML_iterator& it )
{
if( s_field.empty() )
return true;
// просто проверка на не пустой field
if( s_fvalue.empty() && it.getProp(s_field).empty() )
return false;
// просто проверка что field = value
if( !s_fvalue.empty() && it.getProp(s_field)!=s_fvalue )
return false;
return true;
}
// ------------------------------------------------------------------------------------------
bool MBTCPMaster::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
return true;
}
......
......@@ -399,7 +399,6 @@ class MBTCPMaster:
void rtuQueryOptimization( RTUDeviceMap& m );
void readConfiguration();
bool check_item( UniXML_iterator& it );
private:
......
......@@ -663,33 +663,16 @@ void MBSlave::readConfiguration()
for( ;it.getCurrent(); it.goNext() )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
}
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool MBSlave::check_item( UniXML_iterator& it )
{
if( s_field.empty() )
return true;
// просто проверка на не пустой field
if( s_fvalue.empty() && it.getProp(s_field).empty() )
return false;
// просто проверка что field = value
if( !s_fvalue.empty() && it.getProp(s_field)!=s_fvalue )
return false;
return true;
}
// ------------------------------------------------------------------------------------------
bool MBSlave::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
return true;
}
......
......@@ -983,33 +983,16 @@ void RTUExchange::readConfiguration()
for( ;it.getCurrent(); it.goNext() )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
}
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool RTUExchange::check_item( UniXML_iterator& it )
{
if( s_field.empty() )
return true;
// просто проверка на не пустой field
if( s_fvalue.empty() && it.getProp(s_field).empty() )
return false;
// просто проверка что field = value
if( !s_fvalue.empty() && it.getProp(s_field)!=s_fvalue )
return false;
return true;
}
// ------------------------------------------------------------------------------------------
bool RTUExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
return true;
}
......
......@@ -233,7 +233,6 @@ class RTUExchange:
void rtuQueryOptimization( RTUDeviceMap& m );
void readConfiguration();
bool check_item( UniXML_iterator& it );
private:
RTUExchange();
......
......@@ -67,8 +67,8 @@ sender(0)
continue;
}
// проверяем заданы ли фильтры для подсетей
if( !n_field.empty() && !check_filter(n_it,n_field,n_fvalue) )
// проверяем фильтры для подсетей
if( !UniSetTypes::check_filter(n_it,n_field,n_fvalue) )
continue;
// Если указано поле unet_broadcast_ip непосредственно у узла - берём его
......
......@@ -236,30 +236,14 @@ void UNetSender::readConfiguration()
for( ;it.getCurrent(); it.goNext() )
{
if( check_item(it) )
if( check_filter(it,s_field,s_fvalue) )
initItem(it);
}
}
// ------------------------------------------------------------------------------------------
bool UNetSender::check_item( UniXML_iterator& it )
{
if( s_field.empty() )
return true;
// просто проверка на не пустой field
if( s_fvalue.empty() && it.getProp(s_field).empty() )
return false;
// просто проверка что field = value
if( !s_fvalue.empty() && it.getProp(s_field)!=s_fvalue )
return false;
return true;
}
// ------------------------------------------------------------------------------------------
bool UNetSender::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{
if( check_item(it) )
if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it);
return true;
}
......
......@@ -76,7 +76,6 @@ class UNetSender
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec );
void readConfiguration();
bool check_item( UniXML_iterator& it );
private:
UNetSender();
......
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