/*
* $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/ltcs/src/lbto/LbtoIIFInterface2.cc 14975 2017-12-15 13:50:00Z mathar $
*/

#include <iostream>
#include "LbtoIIFInterface2.h"

namespace lbto
{
	/*!*******************************
	* @brief print the most important parameters of a result structure.
	* @param os The stream to print this to.
	* @param res The structure as defined in the ICE interface
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	std::ostream & operator << (std::ostream & os , const result & res)
	{
		os << res.rescode ;
		for( int i=0 ; i < (int) res.resmsg.size() ; i++)
			os << " " << res.resmsg[i] ;
		return os;
	}
	
	/*!*******************************
	* @brief get the rescode from an input stream
	* @param is The stream to get this from
	* @param res The structure as defined in the ICE interface
	* @warning This is not compatible with the output streamoperation because
	*  we cannot know how many strings will be in the input stream.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	std::istream & operator >> (std::istream & is , result & res)
	{
		is >> res.rescode ;
		return is;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a DDstruct structure.
	* @param os The stream to print this to.
	* @param DD The structure as defined in the ICE interface
	* @since 2017-01-30
	* @author R. J. Mathar
	*/
	std::ostream & operator << (std::ostream & os , const DDstruct & DD)
	{
		os << DD.DDname << " " 
			<< DD.DDkey << " "
			<< DD.dataType ;
		return os;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a DDstruct structure.
	* @param is
	* @param DD The structure as defined in the ICE interface
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	std::istream & operator >> (std::istream & is , DDstruct & DD)
	{
		is >> DD.DDname 
			>> DD.DDkey 
			>> DD.dataType ;
		return is;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a position structure.
	* @param os The stream to print this to.
	* @param pos The structure as defined in the ICE interface
	* @since 2017-01-30
	* @author R. J. Mathar
	*/
	std::ostream & operator << (std::ostream & os , const position & pos)
	{
		os << pos.coord1 << " " 
			<< pos.coord2 << " " 
			<< pos.system << " " 
			<< pos.epoch << " " 
			<< pos.equinox << " " 
			<< pos.pmcoord1 << " " 
			<< pos.pmcoord2 << " " 
			<< pos.apparentMagnitude << " " 
			<< pos.filter << " " 
			<< pos.color << " " 
			<< pos.colorType << " " 
			<< pos.wavelength << " " 
			<< pos.targname ;
		return os;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a position structure.
	* @param is The stream to print this to.
	* @param pos The structure as defined in the ICE interface
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	std::istream & operator >> (std::istream & is , position & pos)
	{
		is >> pos.coord1
			>> pos.coord2 
			>> pos.system 
			>> pos.epoch 
			>> pos.equinox
			>> pos.pmcoord1 
			>> pos.pmcoord2 
			>> pos.apparentMagnitude 
			>> pos.filter 
			>> pos.color 
			>> pos.colorType 
			>> pos.wavelength 
			>> pos.targname;
		return is;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a position2 structure.
	* @param os The stream to print this to.
	* @param pos2 The structure as defined in the ICE interface
	* @since 2017-01-30
	* @author R. J. Mathar
	*/
	std::ostream & operator << (std::ostream & os , const position2 & pos2)
	{
		os << "("
			<< pos2.coord1 << "," 
			<< pos2.coord2 << "," 
			<< pos2.system << "," 
			<< pos2.epoch << "," 
			<< pos2.equinox << "," 
			// << pos2.pmcoord1 << "," 
			// << pos2.pmcoord2 << "," 
			<< pos2.apparentMagnitude << "," 
			<< pos2.filter << "," 
			<< pos2.color << "," 
			<< pos2.colorType << "," 
			<< pos2.wavelength << "," 
			// << pos2.file << "," 
			<< pos2.time << "," 
			<< pos2.RARate << "," 
			<< pos2.DECRate << ")"  ;
		return os;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a position2 structure.
	* @param is The streamto get this from
	* @param pos2 The structure as defined in the ICE interface
	* @since 2017-05-27
	* @author R. J. Mathar
	*/
	std::istream & operator >> (std::istream & is , position2 & pos2)
	{
		is >> pos2.type >> pos2.coord1 
			>> pos2.coord2
			>> pos2.system 
			>> pos2.epoch 
			>> pos2.equinox
			>> pos2.pmcoord1 
			>> pos2.pmcoord2 
			>> pos2.apparentMagnitude 
			>> pos2.filter 
			>> pos2.color 
			>> pos2.colorType 
			>> pos2.wavelength
			>> pos2.time 
			>> pos2.RARate 
			>> pos2.DECRate ;
		return is;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a nonsidereal structure.
	* @param target The structure as defined in the ICE interface
	* @since 2017-01-30
	* @author R. J. Mathar
	*/
	std::ostream & operator << (std::ostream & os , const nonsidereal & target)
	{
		os << target.type << " " 
			<< target.wavelength << " " 
			<< target.value0 << " " 
			<< target.value1 << " " 
			<< target.value2 << " " 
			<< target.value3 << " " 
			<< target.value4 ;
		return os;
	}
	
	/*!*******************************
	* @brief print the most important parameters of a nonsidereal structure.
	* @param target The structure as defined in the ICE interface
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	std::istream & operator >> (std::istream & is , nonsidereal & target)
	{
		is >> target.type >> target.wavelength
			>> target.file
			>> target.value0 
			>> target.value1 
			>> target.value2 
			>> target.value3 
			>> target.value4 ; 
		return is;
	}
	
	/*!*******************************
	* @brief Compare two result types
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator < ( const lbto::result & left , const lbto::result & right)
	{
		return left.rescode < right.rescode ;
	}
	
	/*!*******************************
	* @brief Compare two result types
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator == ( const lbto::result & left , const lbto::result & right)
	{
		return left.rescode == right.rescode ;
	}
	
	/*!*******************************
	* @brief Compare two result types
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator != ( const lbto::result & left , const lbto::result & right)
	{
		return !operator==(left,right) ;
	}
	
	/*!*******************************
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator < ( const lbto::nonsidereal & left , const lbto::nonsidereal & right)
	{
		if ( left.value0 < right.value0)
			return true ;
		else if ( left.value0 > right.value0)
			return false ;
		else if ( left.value1 < right.value1)
			return true ;
		else if ( left.value1 > right.value1)
			return false ;
		else if ( left.value2 < right.value2)
			return true ;
		else if ( left.value2 > right.value2)
			return false ;
		else if ( left.value3 < right.value3)
			return true ;
		else if ( left.value3 > right.value3)
			return false ;
		else if ( left.value4 < right.value4)
			return true ;
		else
			return false ;
	}
	
	/*!*******************************
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator == ( const lbto::nonsidereal & left , const lbto::nonsidereal & right)
	{
		if ( left.value0 != right.value0
			|| left.value1 != right.value1
			|| left.value2 != right.value2
			|| left.value3 != right.value3
			|| left.value4 != right.value4)
			return false ;
		else
			return true ;
	}
	
	/*!*******************************
	* @param left Parameter left to the less-sign.
	* @param right Parameter right to the less-sign.
	* @return A flat (useless) comparison of the two integer codes.
	* @since 2017-12-15
	* @author R. J. Mathar
	*/
	bool operator != ( const lbto::nonsidereal & left , const lbto::nonsidereal & right)
	{
		return !operator==(left,right) ;
	}

} /* namespace lbto */
