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

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

#ifndef CT_QUEUE_PUT_TO_1
#define CT_QUEUE_PUT_TO_1 1

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

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

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

concrete_template <
	concrete_instance class Item,
	/*!
	    implements
		abstract_instance General_Put_To <Item>
	!*/
	concrete_instance class Queue_Base
	/*!
	    implements
		abstract_instance Queue_Kernel <Item>
	!*/
    >
class Queue_Put_To_1 :
    extends
	concrete_instance Queue_Base,
    implements
	abstract_instance General_Put_To <Queue_Base>
{
public:
    
    procedure_body Put_To (
	    alters Character_OStream& outs
	)
    {
	object catalyst Integer items_remaining = self.Length ();

	// Open scope of string

	outs.Open_Scope ("<");

	// Put contents of self

	while (items_remaining > 0)
	/*!
	    alters self, items_remaining
	    maintains
		there exists a, b: string of Item
		    (#self = a * b  and
		     self = b * a  and
		     items_remaining = |b|  and
		     [items in a have been output already])
	    decreases
		items_remaining
	!*/
	{
	    object catalyst Item x;

	    self.Dequeue (x);
	    outs.New_Line ();
	    outs << x;
	    self.Enqueue (x);
	    items_remaining--;
	}

	// Close scope of string

	outs.Close_Scope (">");
    }

};

#endif // CT_QUEUE_PUT_TO_1

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