9 #include <pugixml/pugixml.hpp>
18 pair<NodeParseMap::iterator, bool> result =
19 node_map_.insert(make_pair(node, parser));
20 assert(result.second);
29 const char *name = node.attribute(
"type").value();
39 node_parse_errors_[msg_type]++;
44 NodeParseMap::const_iterator loc = node_map_.find(name);
45 if (loc == node_map_.end()) {
46 node_parse_errors_[msg_type]++;
56 obj = loc->second(node, db_, &req_key->
id_name);
58 node_parse_errors_[msg_type]++;
66 unique_ptr<DBRequest> request(
new DBRequest);
68 request->data.reset(req_data);
69 request->key.reset(req_key);
96 first_node = link.first_child();
98 link_parse_errors_[msg_type]++;
102 second_node = first_node.next_sibling();
104 link_parse_errors_[msg_type]++;
108 name1 = first_node.attribute(
"type").value();
111 link_parse_errors_[msg_type]++;
115 name2 = second_node.attribute(
"type").value();
118 link_parse_errors_[msg_type]++;
123 name_node1 = first_node.first_child();
125 link_parse_errors_[msg_type]++;
129 if (strcmp(name_node1.name(),
"name") != 0) {
130 link_parse_errors_[msg_type]++;
134 name_node2 = second_node.first_child();
136 link_parse_errors_[msg_type]++;
140 if (strcmp(name_node2.name(),
"name") != 0) {
141 link_parse_errors_[msg_type]++;
147 req_key->left_key.id_name = name_node1.child_value();
148 req_key->left_key.id_type = name1;
149 req_key->left_key.id_seq_num = seq;
151 req_key->right_key.id_name = name_node2.child_value();
152 req_key->right_key.id_type = name2;
153 req_key->right_key.id_seq_num = seq;
155 xml_node metadata = link.child(
"metadata");
157 req_key->metadata = metadata.attribute(
"type").value();
160 unique_ptr <DBRequest> req (
new DBRequest);
162 req->key = std::move(req_key);
164 link_table->
Enqueue(req.get());
171 for (xml_node node = config.first_child(); node;
172 node = node.next_sibling()) {
175 if (strcmp(node.name(),
"update") == 0) {
178 }
else if (strcmp(node.name(),
"delete") == 0) {
185 for(xml_node chld = node.first_child(); chld; chld = chld.next_sibling()) {
188 if (strcmp(chld.name(),
"link") == 0) {
189 links_processed_[msg_type]++;
190 LinkParse(chld, oper, seq);
194 if (strcmp(chld.name(),
"node") == 0) {
195 nodes_processed_[msg_type]++;
196 NodeParse(chld, oper, seq);
bool Enqueue(DBRequest *req)
boost::function< IFMapObject *(const pugi::xml_node, DB *, std::string *id_name) > NodeParseFn
void NodeParse(pugi::xml_node &node, DBRequest::DBOperation oper, uint64_t seq)
void LinkParse(pugi::xml_node &node, DBRequest::DBOperation oper, uint64_t seq)
void ConfigParse(const pugi::xml_node config, uint64_t seq)
void NodeRegister(const std::string &node, NodeParseFn parser)
static IFMapTable * FindTable(DB *db, const std::string &element_type)
#define IFMAP_AGENT_LINK_DB_NAME
std::unique_ptr< IFMapObject > content