// rpimpl_oplist.h
// Copyright (c) Menno Rubingh 2016.  Web: [http://rubinghsoftware.de]
// 
// MR Mar 2016.
//
// ParsedOperationList:
// List of OperationXxx instances.
// Contains a *parsed* RP expression.
// These are the operations to be executed one after the other.
// Used internally by the RPInterpreter implementation.
//
//---
// Implementation note:
//   - ParsedOperationList is a list of pointers to CONST OperationXxx objects.  
//     Const because, after creation, these objects are never changed.
//     These OperationXxx objects are created by code that uses ParsedOperationList, 
//     and are destroyed (in the ParsedOperationList destructor) when the
//     ParsedOperationList object goes out of scope.  (Although CONST OperationXxx
//     objects can not be changed, destroying them is of course an allowed 
//     operation... even CONST objects have to be destroyed at some point.)
//

#ifndef _RPIMPL_OPLIST_H_
#define _RPIMPL_OPLIST_H_


#include "rpimpl_oper.h"  //OperationBase.

#include <stdio.h>        //FILE.



class ParsedOperationList
{
	static int const       NMAX = 64;

	int                    m_n;
	OperationBase const *  m_arr[NMAX];

public:
	void init( void );
	void zap ( void );

	void reinit( void )
	{
		zap();
		init();
	}

	ParsedOperationList( void )
	{
		init();
	}
	~ParsedOperationList( void )
	{
		zap();
	}
	
	int getN( void ) const { return m_n; }

	OperationBase const * getElem( int i ) const;

	void appendElem( 
		SContext const *        iCxt,
		OperationBase const *   iOp );

	void dump( FILE * oF ) const;
};



#endif //_RPIMPL_OPLIST_H_