//---------------------------------------------------------------------------
#pragma hdrstop
#include "data.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
///Funktionen skifter slot focusset således at det er en anden variabel
///som sandhedsoperatorene arbejder på,.
void data::SkiftSlotFocus(int SlotNr)
{
    if(SlotNr >= 0 && SlotNr <= 11)
      SlotFocus = SlotNr;
}//
//---------------------------------Sandhedsoperatorer-------------------------//
bool data::operator >(data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5: return(StringSlot[SlotFocus-1] > a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9:return(IntSlot[SlotFocus-6] > a.IntSlot[SlotFocus-6]);
      case 10:
      case 11:return(DoubleSlot[SlotFocus-10] > a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
bool data::operator <(const data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5: return(StringSlot[SlotFocus-1] < a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9: return(IntSlot[SlotFocus-6] < a.IntSlot[SlotFocus-6]);
      case 10:
      case 11: return(DoubleSlot[SlotFocus-10] < a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
bool data::operator ==(const data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5: return(StringSlot[SlotFocus-1] == a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9: return(IntSlot[SlotFocus-6] == a.IntSlot[SlotFocus-6]);
      case 10:
      case 11: return(DoubleSlot[SlotFocus-10] == a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
bool data::operator !=(const data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5: return(StringSlot[SlotFocus-1] != a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9: return(IntSlot[SlotFocus-6] != a.IntSlot[SlotFocus-6]);
      case 10:
      case 11: return(DoubleSlot[SlotFocus-10] != a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
bool data::operator <=(const data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5:return(StringSlot[SlotFocus-1] <= a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9:return(IntSlot[SlotFocus-6] <= a.IntSlot[SlotFocus-6]);
      case 10:
      case 11:return(DoubleSlot[SlotFocus-10] <= a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
bool data::operator >=(const data a)
{
    switch(SlotFocus)
    {
      case 1: case 2: case 3: case 4:
      case 5:return(StringSlot[SlotFocus-1] >= a.StringSlot[SlotFocus-1]);
      case 6: case 7: case 8:
      case 9:return(IntSlot[SlotFocus-6] >= a.IntSlot[SlotFocus-6]);
      case 10:
      case 11:return(DoubleSlot[SlotFocus-10] >= a.DoubleSlot[SlotFocus-10]);
    }
    return false;
}
//---------------------------------ligmed operator----------------------------//
void data::operator =(const data a)
{
    int i;
    for(i = 0; i < AntalStringSlots; i++)
      StringSlot[i] = a.StringSlot[i];

    for(i = 0; i < AntalIntSlots; i++)
      IntSlot[i] = a.IntSlot[i];

    for(i = 0; i < AntalDoubleSlots; i++)
      DoubleSlot[i] = a.DoubleSlot[i];

    for(i = 0; i < 5; i++)
      d[i] = a.d[i];
}
//---------------------------------udskrivs operatorer------------------------//
ostream& operator <<(ostream& ud, const data a)
{
    int i;
    switch(SlotFocus)
    {

      case 0:
              for(i = 0; i < a.AntalStringSlots; i++)
                 if(a.StringSlot[i] != "tom")
                 {ud << a.StringSlot[i]; cout << " ";}

              for(i = 0; i < a.AntalIntSlots; i++)
                 if(a.IntSlot[i] != -1)
                 {ud << a.IntSlot[i]; cout << " ";}

              for(i = 0; i < a.AntalDoubleSlots; i++)
                 if(a.DoubleSlot[i] != -1)
                 {ud << a.DoubleSlot[i]; cout << " ";}

             for(i = 0; i < 5; i++)
              {
                if(a.d[i] != NULL)
                {
                  SlotFocus = 1;
                  cout << " | " <<  *a.d[i];
                }
                SlotFocus = 0;
              }
              break;
      case 1:
      case 2:
      case 3:
      case 4:
      case 5: ud << a.StringSlot[SlotFocus-1];
              break;
      case 6:
      case 7:
      case 8:
      case 9: ud << a.IntSlot[SlotFocus-6];
              break;
      case 10:
      case 11:ud << a.DoubleSlot[SlotFocus-10];
              break;
    }
    return ud;
}
void data::slet()
{
    int i;
    for(i = 0; i < AntalStringSlots; i++)
      StringSlot[i] = "tom";
    for(i = 0; i < AntalIntSlots; i++)
      IntSlot[i] = -1;
    for(i = 0; i < AntalDoubleSlots; i++)
      DoubleSlot[i] = -1;
    for(i = 0; i < 5; i++)
      d[i] = NULL;
}
//----------------------------------------------------------------------------//
///Konstruktor
data::data()
{
    MaxSlots = 11;
    AntalStringSlots = 5;
    AntalIntSlots = 4;
    AntalDoubleSlots = 2;

    int i;
    for(i = 0; i < AntalStringSlots; i++)
      StringSlot[i] = "tom";
    for(i = 0; i < AntalIntSlots; i++)
      IntSlot[i] = -1;
    for(i = 0; i < AntalDoubleSlots; i++)
      DoubleSlot[i] = -1;
    for(i = 0; i < 5; i++)
      d[i] = NULL;
}//
