/* 
    channel for Bt848 frame grabber driver

    Copyright (C) 1996,97 Marcus Metzler (mocm@thp.uni-koeln.de)

    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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _channel_h
#define _channel_h


#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <strstream.h>


/*
 * channel.h
 */

class channel
{
  static int cnt;
  
 public:
  channel *prev;
  channel *next;
  int number;
  int head;
  
  int frequency;
  char *name;
  int color;
  int brightness;
  int hue;
  int contrast;
  int norm;
  int input;
  
  channel(){
    prev=NULL;
    next=NULL;
    number=0;
    head=1;
    cnt=0;
  }
  
  channel(channel *h,int freq,char *n,int c,int b,int hu,int co,int no,int in,int num=-1);
  ~channel();
  friend ostream &operator<<(ostream &stream, channel &x);
  friend istream &operator>>(istream &stream, channel &x);
  int count(){return cnt;}
};



class interval
{

 public:

  double fmax_;
  int cmax_;
  int cmin_;
  double fmin_;
  double chanstep_;

  
  interval()
    {
      fmin_=0;
      fmax_=0;
      cmin_=0;
      cmax_=0;
      chanstep_=0;
    };

  interval(double fmin, double fmax, int cmin, int cmax, double cstep)
    {
      fmin_=fmin;
      fmax_=fmax;
      cmin_=cmin;
      cmax_=cmax;
      chanstep_=cstep;
    };

  set(double fmin, double fmax, int cmin, int cmax, double cstep)
    {
      fmin_=fmin;
      fmax_=fmax;
      cmin_=cmin;
      cmax_=cmax;
      chanstep_=cstep;
    };
  
  int infreq(double freq);
  int inchan(int chan);

  friend ostream &operator<<(ostream &stream, interval &x);
  friend istream &operator>>(istream &stream, interval &x);

};

class country
{
  int nb_;
  
 public:
  interval *iv;
  char *name;
 
  
  country()
    {
      nb_=0;
      iv= NULL;
      name=NULL;
    };

  country(int nb,char *nam);
  country(char *filename);

  ~country()
    {
      if (iv) delete(iv);
      if (name) delete(name);
    }

  void init(int nb,char *nam);
  void init(char *filename);

  double smax();
  double fmax();
  double fmin();
  int cmax();
  int cmin();
   
  int freqtochan(int freq);    
  int freqtofine(int freq);
  int cftofreq(int chan, int fine);
  
  friend ostream &operator<<(ostream &stream, country &x);
  friend istream &operator>>(istream &stream, country &x);

};


#endif /* _channel_h */
/* DON'T ADD STUFF AFTER THIS #endif */











