// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 

// Copyright 2003 Liam Girdwood  

#ifndef _POLLUX_IMPORT_HH
#define _POLLUX_IMPORT_HH

#include <string>
#include <gtkmm/progressbar.h>
#include <libxml++/libxml++.h>
#include "catalog.hh"
#include "astro_object.hh"

#define MAX_LINE_SIZE	1024

namespace Pollux
{
	
/*! \class Import
* \brief Object Catalog Import Engine
*
* This class imports raw ASCII astronomy catalogs into Nova.
*/	
class Import
{
	public:
		/*! \fn Import();
		* \brief Constructor
		*/
		Import();
	
		/*! \fn ~Import();
		* \brief Destructor
		*/
		~Import();
	
		// public methods
		
		/*! \fn void set_name (std::string& name);
		* \brief Set catalog name
		*/
		void set_name (std::string& name);
		
		/*! \fn void set_path (std::string& path);
		* \brief Set catalog path
		*/
		void set_path (std::string& path);
		
		/*! \fn Catalog* import_catalog ();	
		* \brief Import raw ASCII catalog
		*/
		Catalog* import_catalog ();							
		
		/*! \fn int scan(std::list<std::string*>& names, 
				std::list<std::string*>& description);
		* \brief Scan filesystem for catalog
		*/
		int scan(std::list<std::string*>& names, 
				std::list<std::string*>& description);		// scan for available catalogs
		
		/*! \fn void reg_progress (Gtk::ProgressBar* progress);
		* \brief Register progress bar with importer
		*/
		void reg_progress (Gtk::ProgressBar* progress);
	
	private:
		
		/*! \enum cat
		* \brief catalog types
		*/
		enum cat
		{
			SKYMAP,
			STAR,
			GALAXY,
			NEBULA,
			DEEP_OTHER,
			ASTEROID,
			COMET,
			NEAR_OTHER
		};
		
		/*! \struct import_item
		* \brief import item
		*/
		struct import_item
		{
			int pos;				/*!< Item position */
			int len;				/*!< Item length */
			std::string name;		/*!< Item name */
			std::string units;		/*!< Item units */
			std::string desc;		/*!< Item description */
			Castor::AstroObject::element_type type;	/*!< Item type */
			bool extra;				/*!< Is item an Unknown extra ? */
		};
	
		// private methods
		/*! \fn bool parse_descriptor ();
		* \brief Parse XML catalog description 
		*/
		bool parse_descriptor ();
		
		/*! \fn bool build_import_table (ImportSaxParser* parser);
		* \brief Create a parse table from the XML description data
		*/
		bool build_import_table ();
		
		void parse_node(const xmlpp::Node* node);
		
		/*! \fb bool create_object (Catalog* catalog, const char* line);
		* \brief Create and add catalog object
		*/
		bool create_object (Catalog* catalog, const char* line);
		
		/*! \fn bool get_element (import_item* item, std::string& value, const char* line);
		* \brief Get element data from ASCII catalog
		*/
		bool get_element (import_item* item, std::string& value, const char* line);
		
		// private members
		std::list<std::string*> m_files;			/*!< catalog files to import */
		std::string m_description;					/*!< catalog description */
		cat m_type;									/*!< catalog type */
		std::string m_type_str;						/*!< catalog type string */
		std::string m_maintainer;					/*!< catalog maintainer */
		std::string m_created;						/*!< catalog creation date */
		int m_size;									/*!< number of records in catalog */
		std::string m_name;							/*!< catalog name */
		std::string m_path;							/*!< catalog path */
		std::string m_version;						/*!< catalog version */
		std::string m_history;						/*!< catalog history */
		std::string m_acknowledge;					/*!< catalog acknowledgements */
		
		// import list
		std::list<import_item*> m_import_table;		/*!< Import table */
		bool m_first_pass;							/*!< Extra element first pass */
};

}

#endif


syntax highlighted by Code2HTML, v. 0.9.1