void grapher::add(const processed_object& po) { require_not_generated(); if (po.connection()) { process_connections(po); return; } const auto v(vertex_for_id(po.id())); graph_[v] = po; process_child_node(v, po); }
void grapher::process_connections(const processed_object& o) { BOOST_LOG_SEV(lg, debug) << "Processing connections for object: '" << o.id() << "' of type: '" << o.dia_object_type() << "'"; const auto parent_id(o.connection()->first); const auto child_id(o.connection()->second); const auto parent_vertex(vertex_for_id(parent_id)); const auto child_vertex(vertex_for_id(child_id)); connected_ids_.insert(parent_id); boost::add_edge(child_vertex, parent_vertex, graph_); BOOST_LOG_SEV(lg, debug) << "Created edge between '" << child_id << "' and: '" << parent_id << "'"; auto i(child_id_to_parent_ids_.find(child_id)); if (i == child_id_to_parent_ids_.end()) { std::list<std::string> l = { parent_id }; child_id_to_parent_ids_.insert(std::make_pair(child_id, l)); BOOST_LOG_SEV(lg, debug) << "First parent for Child: " << child_id; } else { i->second.push_back(parent_id); BOOST_LOG_SEV(lg, debug) << "Child has more than one parent: " << child_id; } if (connected_ids_.find(child_id) == connected_ids_.end()) { orphanage_.insert(std::make_pair(child_id, child_vertex)); BOOST_LOG_SEV(lg, debug) << "Vertex for object joined orphanage: " << child_id; } const auto k(orphanage_.find(parent_id)); if (k != orphanage_.end()) { BOOST_LOG_SEV(lg, debug) << "Object is no longer orphan: " << k->first << "'"; orphanage_.erase(k); } }