/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_XML_INFO_H_
#define __GDAM_XML_INFO_H_

#include <glib.h>

typedef struct _GdamXmlInfo GdamXmlInfo;
struct _GdamXmlInfo {
	GHashTable*		object_to_id;
	GPtrArray*		id_to_object;
};


/* Public interface. 
 *
 * The purpose of this class is to provide
 * random, general structure that is needed for
 * xml parsing/building.
 *
 * Because xml is rich except for references,
 * we implement a trivial scheme to help us
 * handle crossreferencing, c-style.
 *
 * When parsing use `gdam_xml_info_alloc_id' for each
 * object you will need to reference or `gdam_xml_info_lookup_by_object'
 * if you have already referenced it.
 *
 * When rebuilding your object use `gdam_xml_info_assoc'
 * and `gdam_xml_info_lookup_by_id' to reassociate that object.
 *
 * ANNOYANCE: we cannot conveniently handle circular references --
 *            you must manually store the node_id around in a fixup
 *            table.
 *
 *            (but in many contexts just avoiding circular references
 *             is possible... eg mininetwork)
 */
GdamXmlInfo* gdam_xml_info_new             ();
void         gdam_xml_info_destroy         (GdamXmlInfo* xml_info);
int          gdam_xml_info_lookup_by_object(GdamXmlInfo* xml_info,
                                            gpointer     object);
gpointer     gdam_xml_info_lookup_by_id    (GdamXmlInfo* xml_info,
                                            int          id);
int          gdam_xml_info_alloc_id        (GdamXmlInfo* xml_info,
					    gpointer     ptr);
void         gdam_xml_info_assoc           (GdamXmlInfo* xml_info,
                                            int          id,
					    gpointer     ptr);


#endif
