2 * Automatic object graph externalization for XTL
4 * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
6 /* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
7 * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 * Id: graphio.h 1.8 Fri, 05 May 2000 18:57:58 +0100 jop
36 typedef std::map<void*,int> trans_type;
40 graph_refs(): label(1) {}
42 template <class Format, class Refs, class T>
43 void reference(obj_input<Format, Refs>& stream, T*& ptr) {
48 trans.insert(pair<void*,int>(label, (void*)ptr));
55 template <class Format, class Refs, class T>
56 void reference(obj_output<Format, Refs>& stream, T const* ptr) {
57 trans_type::iterator i=trans.find((void*)ptr);
59 stream.simple((*i).second);
62 trans.insert(std::pair<void*,int>((void*)ptr, label));