8 #include <pugixml/pugixml.hpp>
17 pair<NodeParseMap::iterator, bool> result =
18 node_map_.insert(make_pair(node, parser));
19 assert(result.second);
28 const char *name = node.attribute(
"type").value();
38 node_parse_errors_[msg_type]++;
43 NodeParseMap::const_iterator loc = node_map_.find(name);
44 if (loc == node_map_.end()) {
45 node_parse_errors_[msg_type]++;
55 obj = loc->second(node, db_, &req_key->
id_name);
57 node_parse_errors_[msg_type]++;
65 unique_ptr<DBRequest> request(
new DBRequest);
67 request->data.reset(req_data);
68 request->key.reset(req_key);
95 first_node = link.first_child();
97 link_parse_errors_[msg_type]++;
101 second_node = first_node.next_sibling();
103 link_parse_errors_[msg_type]++;
107 name1 = first_node.attribute(
"type").value();
110 link_parse_errors_[msg_type]++;
114 name2 = second_node.attribute(
"type").value();
117 link_parse_errors_[msg_type]++;
122 name_node1 = first_node.first_child();
124 link_parse_errors_[msg_type]++;
128 if (strcmp(name_node1.name(),
"name") != 0) {
129 link_parse_errors_[msg_type]++;
133 name_node2 = second_node.first_child();
135 link_parse_errors_[msg_type]++;
139 if (strcmp(name_node2.name(),
"name") != 0) {
140 link_parse_errors_[msg_type]++;
146 req_key->left_key.id_name = name_node1.child_value();
147 req_key->left_key.id_type = name1;
148 req_key->left_key.id_seq_num = seq;
150 req_key->right_key.id_name = name_node2.child_value();
151 req_key->right_key.id_type = name2;
152 req_key->right_key.id_seq_num = seq;
154 xml_node metadata = link.child(
"metadata");
156 req_key->metadata = metadata.attribute(
"type").value();
159 unique_ptr <DBRequest> req (
new DBRequest);
161 req->key = std::move(req_key);
163 link_table->
Enqueue(req.get());
170 for (xml_node node = config.first_child(); node;
171 node = node.next_sibling()) {
174 if (strcmp(node.name(),
"update") == 0) {
177 }
else if (strcmp(node.name(),
"delete") == 0) {
184 for(xml_node chld = node.first_child(); chld; chld = chld.next_sibling()) {
187 if (strcmp(chld.name(),
"link") == 0) {
188 links_processed_[msg_type]++;
189 LinkParse(chld, oper, seq);
193 if (strcmp(chld.name(),
"node") == 0) {
194 nodes_processed_[msg_type]++;
195 NodeParse(chld, oper, seq);
void LinkParse(pugi::xml_node &node, DBRequest::DBOperation oper, uint64_t seq)
bool Enqueue(DBRequest *req)
void NodeRegister(const std::string &node, NodeParseFn parser)
void ConfigParse(const pugi::xml_node config, uint64_t seq)
void NodeParse(pugi::xml_node &node, DBRequest::DBOperation oper, uint64_t seq)
static IFMapTable * FindTable(DB *db, const std::string &element_type)
std::unique_ptr< IFMapObject > content
#define IFMAP_AGENT_LINK_DB_NAME
boost::function< IFMapObject *(const pugi::xml_node, DB *, std::string *id_name) > NodeParseFn