UniSet 2.32.1
IOConfig_XML.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// --------------------------------------------------------------------------
21// --------------------------------------------------------------------------
22#ifndef IOConfig_XML_H_
23#define IOConfig_XML_H_
24// ------------------------------------------------------------------------------------------
25#include <memory>
26#include <sigc++/sigc++.h>
27#include <string>
28#include "UniXML.h"
29#include "UniSetTypes.h"
30#include "IOConfig.h"
31// ------------------------------------------------------------------------------------------
32namespace uniset
33{
34 // ------------------------------------------------------------------------------------------
37 public IOConfig
38 {
39 public:
40 virtual ~IOConfig_XML();
41
42 // реализация интерфейса IOConfig
43 virtual IOController::IOStateList read() override;
44
49 IOConfig_XML( const std::string& fname, const std::shared_ptr<Configuration>& conf );
50
56 IOConfig_XML( const std::shared_ptr<UniXML>& _xml, const std::shared_ptr<Configuration>& conf, xmlNode* root = nullptr );
57
58
65 typedef sigc::slot<bool, const std::shared_ptr<UniXML>&, UniXML::iterator&, xmlNode*> ReaderSlot;
66
78 void setReadItem( ReaderSlot sl );
79
80
93
97 void setItemFilter( const std::string& filterField, const std::string& filterValue = "" );
98
102 void setConsumerFilter( const std::string& filterField, const std::string& filterValue = "" );
103
104
110 uniset::ObjectId& cid, uniset::ObjectId& cnode ) const;
111
113 void setThresholdsFilter( const std::string& filterField, const std::string& filterValue = "" );
114
125
126
127 typedef sigc::slot<bool, const std::shared_ptr<UniXML>&, UniXML::iterator&, xmlNode*, std::shared_ptr<IOController::USensorInfo>&> NCReaderSlot;
128
130 void setNCReadItem( NCReaderSlot sl );
131
132 protected:
133 IOConfig_XML();
134
135 bool check_list_item( UniXML::iterator& it ) const;
136 bool check_consumer_item( UniXML::iterator& it ) const;
137 bool check_thresholds_item( UniXML::iterator& it ) const;
138 void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, std::shared_ptr<IOController::USensorInfo>& inf );
139 IOController::IOStateList read_list( xmlNode* node );
140 void init_thresholds( xmlNode* node, IOController::IOStateList& iolist );
141 void init_depends_signals( IOController::IOStateList& lst );
142
143 bool getBaseInfo( xmlNode* it, IOController_i::SensorInfo& si ) const;
144 bool getSensorInfo( xmlNode* snode, std::shared_ptr<IOController::USensorInfo>& si ) const;
145 bool getThresholdInfo(xmlNode* tnode, std::shared_ptr<IOController::UThresholdInfo>& ti) const;
146 // bool getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController::ConsumerListInfo& lst) const;
147
148 static void set_dumptime( const std::shared_ptr<UniXML>& xml, xmlNode* node );
149 static xmlNode* bind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
150 static xmlNode* rebind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
151
152 std::string s_filterField = { "" };
153 std::string s_filterValue = { "" };
154 std::string t_filterField = { "" };
155 std::string t_filterValue = { "" };
156
157 std::string i_filterField = { "" };
158 std::string i_filterValue = { "" };
159 std::string c_filterField = { "" };
160 std::string c_filterValue = { "" };
161
162 std::string fname = { "" };
163 std::shared_ptr<Configuration> conf;
164 std::shared_ptr<UniXML> uxml;
165 xmlNode* root = { nullptr };
166 ReaderSlot rtslot;
167 ReaderSlot rslot;
168 ReaderSlot cslot;
169 NCReaderSlot ncrslot;
170
171 private:
172 };
173 // -------------------------------------------------------------------------
174} // end of uniset namespace
175// -----------------------------------------------------------------------------
176#endif // IOConfig_XML_H_
Definition IOConfig_XML.h:38
void setThresholdsFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:458
void setReadThresholdItem(ReaderSlot sl)
Definition IOConfig_XML.cc:448
void setNCReadItem(NCReaderSlot sl)
Definition IOConfig_XML.cc:453
bool getConsumerInfo(UniXML::iterator &it, uniset::ObjectId &cid, uniset::ObjectId &cnode) const
Definition IOConfig_XML.cc:476
void setConsumerFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:470
void setReadItem(ReaderSlot sl)
Definition IOConfig_XML.cc:542
void setReadConsumerItem(ReaderSlot sl)
Definition IOConfig_XML.cc:547
virtual IOController::IOStateList read() override
Definition IOConfig_XML.cc:53
void setItemFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:464
sigc::slot< bool, const std::shared_ptr< UniXML > &, UniXML::iterator &, xmlNode * > ReaderSlot
Definition IOConfig_XML.h:65
Definition IOConfig.h:27
Definition UniXML.h:44
Definition Calibration.h:27
long ObjectId
Definition UniSetTypes_i.idl:30
Definition IOController_i.idl:58