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

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

#ifndef CT_ID_NAME_TABLE_PUT_TO_1
#define CT_ID_NAME_TABLE_PUT_TO_1 1

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

#include "AT/General/Put_To.h"

/*!
    #include "AI/Id_Name_Table/Kernel.h"
!*/

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

concrete_template <
	concrete_instance class Id_Name_Table_Base
	/*!
	    implements
		abstract_instance Id_Name_Table_Kernel
	!*/
    >
class Id_Name_Table_Put_To_1 :
    implements
	abstract_instance General_Put_To <Id_Name_Table_Base>,
    extends
	concrete_instance Id_Name_Table_Base
{
public:
    
    procedure_body Put_To (
	    alters Character_OStream& outs
	)
    {
	object catalyst Id_Name_Table_Base temp;
	object catalyst Integer id;
	object catalyst Text name;

	self &= temp;

	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.Remove_Any_Pair (id, name);

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

	    self.Add_Id_Name_Pair (id, name);
	}

	outs.Close_Scope ("}");
    }

};

//-------------------------------------------------------------------------

#endif // CT_ID_NAME_TABLE_PUT_TO_1


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