#ifndef H_CORAL_MODELCOPY
#define H_CORAL_MODELCOPY
// This file is part of the Coral project.
// Please read the copyright notice in the LICENSE file.

/*
 * Implements the modelcopy algorithm described in
 * TUCS Technical Report 486
 *
 */

#include <map>
#include <coral/coral.h>
#include <coral/lib/ref_counted.h>

namespace coral {

	/*
	 * Modification bits for modelcopy functionality
	 * The default is the _opposite_ of the list below.
	 */
#ifndef SWIG
	enum modelcopy_params {
		MODELCOPY_DONT_CREATE_NEW_UUIDS = 1,
		MODELCOPY_DONT_ATTACH_TO_PARENTS = 2,
		MODELCOPY_DONT_SKIP_PYOBJECTS = 4,
		MODELCOPY_DONT_KEEP_ASSOCIATIONS_OUTSIDE_SUBTREE = 8,
	};
#endif

	class EXPORTFWD_coral Collection;
	class EXPORTFWD_coral Set;
	class EXPORTFWD_coral Sequence;
	class EXPORTFWD_coral Atom;
	class EXPORTFWD_coral Element;

	typedef std::map<const coral::Element*, 
	     const coral::Element*> modelcopy_map_t;

	/*
	 * The modelcopy routines fill the two maps
	 * original_to_copy and copy_to_original.
	 * A copy C of an element O has entries
	 * original_to_copy[O] == C and
	 * copy_to_original[C] == O.
	 */

	EXPORT_coral
	     coral::autounref<coral::Sequence>
	     ModelCopy(const coral::Collection*,
		       int params = 0,
		       modelcopy_map_t* original_to_copy = NULL,
		       modelcopy_map_t* copy_to_original = NULL);
	
	EXPORT_coral
	     coral::autounref<coral::Atom>
	     ModelCopy_One(const coral::Atom*,
			   int params = 0,
			   modelcopy_map_t* original_to_copy = NULL,
			   modelcopy_map_t* copy_to_original = NULL);
}


#endif
