UniSet @VERSION@
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#include "AccessConfig.h"
32// ------------------------------------------------------------------------------------------
33namespace uniset
34{
35 // ------------------------------------------------------------------------------------------
37 class IOConfig_XML final:
38 public IOConfig
39 {
40 public:
41 virtual ~IOConfig_XML();
42
43 // реализация интерфейса IOConfig
44 virtual IOController::IOStateList read() override;
45
46 // читать список датчиков
47 static ACLInfoMap readACLInfo( const std::shared_ptr<Configuration>& conf, const std::shared_ptr<UniXML>& _xml );
48
53 IOConfig_XML( const std::string& fname, const std::shared_ptr<Configuration>& conf );
54
60 IOConfig_XML( const std::shared_ptr<UniXML>& _xml, const std::shared_ptr<Configuration>& conf, xmlNode* root = nullptr );
61
62 void setAclConfig( const std::string& name, const std::string& section="ACLConfig");
63 void setAclIgnoreError( bool st );
64
71 typedef sigc::slot<bool, const std::shared_ptr<UniXML>&, UniXML::iterator&, xmlNode*> ReaderSlot;
72
84 void setReadItem( ReaderSlot sl );
85
86
99
103 void setItemFilter( const std::string& filterField, const std::string& filterValue = "" );
104
108 void setConsumerFilter( const std::string& filterField, const std::string& filterValue = "" );
109
110
116 uniset::ObjectId& cid, uniset::ObjectId& cnode ) const;
117
119 void setThresholdsFilter( const std::string& filterField, const std::string& filterValue = "" );
120
131
132
133 typedef sigc::slot<bool, const std::shared_ptr<UniXML>&, UniXML::iterator&, xmlNode*, std::shared_ptr<IOController::USensorInfo>&> NCReaderSlot;
134
136 void setNCReadItem( NCReaderSlot sl );
137
138 protected:
139 IOConfig_XML();
140
141 bool check_list_item( UniXML::iterator& it ) const;
142 bool check_consumer_item( UniXML::iterator& it ) const;
143 bool check_thresholds_item( UniXML::iterator& it ) const;
144 void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, std::shared_ptr<IOController::USensorInfo>& inf );
145 IOController::IOStateList read_list( xmlNode* node );
146 void init_thresholds( xmlNode* node, IOController::IOStateList& iolist );
147 void init_depends_signals( IOController::IOStateList& lst );
148
149 bool getBaseInfo( xmlNode* it, IOController_i::SensorInfo& si ) const;
150 bool getSensorInfo( xmlNode* snode, std::shared_ptr<IOController::USensorInfo>& si ) const;
151 bool getThresholdInfo(xmlNode* tnode, std::shared_ptr<IOController::UThresholdInfo>& ti) const;
152 // bool getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController::ConsumerListInfo& lst) const;
153
154 static void set_dumptime( const std::shared_ptr<UniXML>& xml, xmlNode* node );
155 static xmlNode* bind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
156 static xmlNode* rebind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
157
158 std::string s_filterField = { "" };
159 std::string s_filterValue = { "" };
160 std::string t_filterField = { "" };
161 std::string t_filterValue = { "" };
162
163 std::string i_filterField = { "" };
164 std::string i_filterValue = { "" };
165 std::string c_filterField = { "" };
166 std::string c_filterValue = { "" };
167
168 std::string fname = { "" };
169 std::shared_ptr<Configuration> conf;
170 std::shared_ptr<UniXML> uxml;
171 uniset::ACLMap acls;
172 std::string aclConfigName;
173 std::string aclConfigSectionName;
174 bool aclIgnoreErrors = { false };
175 xmlNode* root = { nullptr };
176 ReaderSlot rtslot;
177 ReaderSlot rslot;
178 ReaderSlot cslot;
179 NCReaderSlot ncrslot;
180
181 private:
182 };
183 // -------------------------------------------------------------------------
184} // end of uniset namespace
185// -----------------------------------------------------------------------------
186#endif // IOConfig_XML_H_
Definition IOConfig_XML.h:39
void setThresholdsFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:555
void setReadThresholdItem(ReaderSlot sl)
Definition IOConfig_XML.cc:545
void setNCReadItem(NCReaderSlot sl)
Definition IOConfig_XML.cc:550
bool getConsumerInfo(UniXML::iterator &it, uniset::ObjectId &cid, uniset::ObjectId &cnode) const
Definition IOConfig_XML.cc:573
void setConsumerFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:567
void setReadItem(ReaderSlot sl)
Definition IOConfig_XML.cc:639
void setReadConsumerItem(ReaderSlot sl)
Definition IOConfig_XML.cc:644
virtual IOController::IOStateList read() override
Definition IOConfig_XML.cc:116
void setItemFilter(const std::string &filterField, const std::string &filterValue="")
Definition IOConfig_XML.cc:561
sigc::slot< bool, const std::shared_ptr< UniXML > &, UniXML::iterator &, xmlNode * > ReaderSlot
Definition IOConfig_XML.h:71
Definition IOConfig.h:27
Definition UniXML.h:44
Definition AccessConfig.h:30
long ObjectId
Definition UniSetTypes_i.idl:30
Definition IOController_i.idl:64