Resolve/C++ Catalog
CT/Partial_Map/Put_To_1.h
Copyright © 2010, Reusable Software Research Group, The Ohio State University

//  /*-------------------------------------------------------------------*\
//  |   Concrete Template : Partial_Map_Put_To_1
//  \*-------------------------------------------------------------------*/

#ifndef CT_PARTIAL_MAP_PUT_TO_1
#define CT_PARTIAL_MAP_PUT_TO_1 1

///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------

#include "AT/General/Put_To.h"
/*!
    #include "AT/Partial_Map/Kernel.h"
!*/

///------------------------------------------------------------------------
/// Interface -------------------------------------------------------------
///------------------------------------------------------------------------

concrete_template <
	concrete_instance class D_Item,
	/*!
	    implements
		abstract_instance General_Put_To <D_Item>
	!*/
	concrete_instance class R_Item,
	/*!
	    implements
		abstract_instance General_Put_To <R_Item>
	!*/
	concrete_instance class Partial_Map_Base
	/*!
	    implements
		abstract_instance Partial_Map_Kernel <
                        D_Item, 
                        R_Item
                    >
	!*/
    >
class Partial_Map_Put_To_1 :
    implements
	abstract_instance General_Put_To <Partial_Map_Base>,
    extends
	concrete_instance Partial_Map_Base
{
public:
    
    procedure_body Put_To (
	    alters Character_OStream& outs
	)
    {
	object catalyst Partial_Map_Put_To_1 temp;
	object catalyst D_Item d;
	object catalyst R_Item r;

	temp &= self;

	outs.Open_Scope ("{");

	// Display contents as ordered pairs

	while (temp.Size () > 0)
	/*!
	    alters self, temp
	    maintains
		temp union self = #temp union #self  and
		temp intersection self = {}  and
		[pairs  in self have been output already]
	    decreases
		|temp|
	!*/
	{
	    temp.Undefine_Any (d, r);

	    outs.New_Line ();
	    outs << "(" << d << ',' << r << ")";
	    if (temp.Size () > 0)
	    {
		outs << ',';
	    }

	    self.Define (d, r);
	}

	outs.Close_Scope ("}");
    }

};

#endif // CT_PARTIAL_MAP_PUT_TO_1

Last modified: Thu Jan 11 17:05:57 EST 2007