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

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

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