//------------------------------------------------------------------------------
Index::Index(GtkTreeIter* it, const bec::NodeId& node)
      : _raw_data((char *)it)
      , _ext(0)
{
  //memset(_raw_data, 0xff, sizeof(*it));
  //*_raw_data = 0;
  reset_iter(it);

  const int depth = node.depth();

  const Mode m = (depth < MaxDepth) ? (depth == 1 ? ListNode : Internal) : External;
  mode(m);

  if (m == External)
  {
    const std::string nrepr = node.toString();
    std::pair<ExternalMap::iterator, bool> res = _ext_map.insert(nrepr);
    _ext = const_cast<std::string*>(&(*(res.first)));
    it->user_data = (void*)_ext;
  }
  else if (m == Internal)
  {
    for (int i = 0; i < depth; ++i)
      word(i, node[i]);
  }
  else if (m == ListNode)
  {
    it->user_data = (void*)(intptr_t)(node[0]);
  }
}
//------------------------------------------------------------------------------
void TreeModelWrapper::update_root_node(const bec::NodeId& root_node) {
  _root_node_path = root_node.toString();
  _root_node_path_dot = root_node.toString() + ".";

  _stamp++;
}