/***************************** LICENSE START ***********************************

 Copyright 2012 ECMWF and INPE. This software is distributed under the terms
 of the Apache License version 2.0. In applying this license, ECMWF does not
 waive the privileges and immunities granted to it by virtue of its status as
 an Intergovernmental Organization or submit itself to any jurisdiction.

 ***************************** LICENSE END *************************************/

//
// .NAME:	
//  MacroVisitor
//
// .AUTHOR:
//  Gilberto Camara and Fernando Ii
//
// .SUMMARY:
//  Defines a class for generating macro programs
//  from a display window.
//
// .CLIENTS:
//  SuperPage, Page
//
//
// .RESPONSABILITIES:
//  - For the caller (superpage or page), save its name and
//    requests which was used to create it.
//  - For the caller and all its children, save the drop
//    actions associated with data units and visual definitions
//  
// .COLLABORATORS:
//  MvIconDataBase (stores the relations between presentables,
//  data units and visdefs)
//
// .BASE CLASS:
//  Device
//
// .DERIVED CLASSES:
//  (none)
//
// .REFERENCES:
//   The implementation of this class is based on the "visitor"
//   pattern (See "Design Patterns" book, page 331).
// 
//
#ifndef MacroVisitor_H
#define MacroVisitor_H

#include <stdio.h>
#include "ObjectInfo.h"
#include "Types.hpp"
#include "Visitor.h"

typedef map<int, string> MacroVisDefMap;

class MacroVisitor: public Visitor {

public:
	// -- Constructor
	MacroVisitor ( string& fileName );

	// -- Destructor
	~MacroVisitor();

	// -- Creates a new fileName
	static string CreateFileName ( const MvRequest& superpageRequest );

	// --  Visitor methods
	virtual void Visit ( SuperPage& );
	virtual void Visit ( Page& );
	virtual void Visit ( SubPage& );
//	virtual void Visit ( MagnifyPage& ) {}
//	virtual void Visit ( EditMapPage& ) {}

private:
	void WriteProlog();
	void WriteTrailer();

	// No copy allowed
	MacroVisitor(const MacroVisitor&);
	MacroVisitor& operator=(const MacroVisitor&){return *this;}

//	MacroType        type_;
	string           macroName_;

	FILE * filePtr_;    // pointer to the temporary file 

	string tmpFileName_; // name of the temporary file
	string outFileName_; // name of the output file

//	int              pageId_;

	ObjectInfo       deviceInfo_;
	ObjectInfo       superpageInfo_;
	ObjectInfo       superpageDrops_;
    	ObjectInfo       pageInfo_;
	ObjectInfo       pageDrops_;

        MacroVisDefMap vdMap_;
};

#endif
