#ifndef morpheo_behavioural_generic_sort_Types_h
#define morpheo_behavioural_generic_sort_Types_h

/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Types.h"

namespace morpheo {
namespace behavioural {
namespace generic {
namespace sort {

  typedef uint32_t Taddress_t;
  typedef uint32_t Tdata_t;

  class sort_t
  {
  public : Tcontrol_t val  ;
  public : Tdata_t    data ;
  public : Taddress_t index;
    
    bool operator<(const sort_t & x) const
    {
      int  test = (((val)?1:0)<<1) + ((x.val)?1:0);
      bool res;
      switch (test)
	{
	case 1  : {res = false;         break;} /* 01 - a not valid, b     valid */
	case 2  : {res = true ;         break;} /* 10 - a     valid, b not valid */
	default : {res = data < x.data; break;} /* 00 - a not valid, b not valid */
	                                        /* 11 - a     valid, b     valid */
	}
//       cout << *this << "\t" << x << "\ttest : " << test << " - res : " << res << endl;
      
      return res;
    }

//     bool operator>(const sort_t & x) const
//     {
//       int test = (((val)?1:0)<<1) + ((x.val)?1:0);
      
//       switch (test)
// 	{
// 	case 1  : {return true ; }        /* 01 - a not valid, b     valid */
// 	case 2  : {return false; }        /* 10 - a     valid, b not valid */
// 	default : {return data > x.data;} /* 00 - a not valid, b not valid */
// 	                                  /* 11 - a     valid, b     valid */
// 	}
//     }

    friend std::ostream& operator<< (std::ostream& output_stream, const sort_t & x)
    {
      output_stream << "[" << x.index << "] " << x.val << " - " << x.data;
      
      return output_stream;
    }
  };

}; // end namespace sort
}; // end namespace generic
}; // end namespace behavioural
}; // end namespace morpheo              

#endif
