/*
   b_float.cpp   Generated by the Ballista(tm) Project data object compiler
   Copyright (C) 1998-2001  Carnegie Mellon University

   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.

   File generated Wednesday, May 23 at 02:48 AM EDT

TITLE
   b_float.cpp
*/

//--------------------------------------------------------------------

#include <errno.h>
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <stream.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "b_float.h"

//--------------------------------------------------------------------


 //--------------------------------------------------------------------

CLASSNAME::CLASSNAME()
{
  //DIAL DECLARATIONS HERE

  //generated

   strcpy(_b_floatTYPENAME,CLASS_STRING);
strcpy(_b_floatZERO,"b_float_ZERO");
strcpy(_b_floatONE,"b_float_ONE");
strcpy(_b_floatNEGONE,"b_float_NEGONE");
strcpy(_b_floatFMINEXP,"b_float_FMINEXP");
strcpy(_b_floatMLN2,"b_float_MLN2");
strcpy(_b_floatMPI,"b_float_MPI");
strcpy(_b_floatHALF_PI,"b_float_HALF_PI");
strcpy(_b_floatQUARTER_PI,"b_float_QUARTER_PI");
strcpy(_b_floatTWO_PI,"b_float_TWO_PI");
strcpy(_b_floatMSQRT2,"b_float_MSQRT2");
strcpy(_b_floatE,"b_float_E");
strcpy(_b_floatMAXFLOAT,"b_float_MAXFLOAT");
strcpy(_b_floatMINFLOAT,"b_float_MINFLOAT");
strcpy(_b_floatNEGMAXFLOAT,"b_float_NEGMAXFLOAT");
strcpy(_b_floatNEGMINFLOAT,"b_float_NEGMINFLOAT");
}

//--------------------------------------------------------------------
b_param *b_float::b_floatZERO()
{
   return &_b_floatZERO;
}

b_param *b_float::b_floatONE()
{
   return &_b_floatONE;
}

b_param *b_float::b_floatNEGONE()
{
   return &_b_floatNEGONE;
}

b_param *b_float::b_floatFMINEXP()
{
   return &_b_floatFMINEXP;
}

b_param *b_float::b_floatMLN2()
{
   return &_b_floatMLN2;
}

b_param *b_float::b_floatMPI()
{
   return &_b_floatMPI;
}

b_param *b_float::b_floatHALF_PI()
{
   return &_b_floatHALF_PI;
}

b_param *b_float::b_floatQUARTER_PI()
{
   return &_b_floatQUARTER_PI;
}

b_param *b_float::b_floatTWO_PI()
{
   return &_b_floatTWO_PI;
}

b_param *b_float::b_floatMSQRT2()
{
   return &_b_floatMSQRT2;
}

b_param *b_float::b_floatE()
{
   return &_b_floatE;
}

b_param *b_float::b_floatMAXFLOAT()
{
   return &_b_floatMAXFLOAT;
}

b_param *b_float::b_floatMINFLOAT()
{
   return &_b_floatMINFLOAT;
}

b_param *b_float::b_floatNEGMAXFLOAT()
{
   return &_b_floatNEGMAXFLOAT;
}

b_param *b_float::b_floatNEGMINFLOAT()
{
   return &_b_floatNEGMINFLOAT;
}

//--------------------------------------------------------------------
//---------------------------------------------------------------------------
//type name return method

b_param *CLASSNAME::typeName()
{
  return &_b_floatTYPENAME;
}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int CLASSNAME::distanceFromBase()
{
  return CLASSPARENT::distanceFromBase() +1;
}


//---------------------------------------------------------------------------
void CLASSNAME::typeList(b_param list[], int num)
{
  strcpy(list[num],(char *) typeName());
  CLASSPARENT::typeList(list,num+1);
}
//--------------------------------------------------------------------
  void *CLASSNAME::access(b_param data[])
{
  if (strcmp(data[0],(char *)typeName())!=0)
    return CLASSPARENT::access(data);

  //ACCESS CODE
b_float_zero = 0;
b_float_one = 0;
b_float_negone = 0;
b_float_fminexp = 0;
b_float_mln2 = 0;
b_float_mpi = 0;
b_float_half_pi = 0;
b_float_quarter_pi = 0;
b_float_two_pi = 0;
b_float_msqrt2 = 0;
b_float_e = 0;
b_float_maxfloat = 0;
b_float_minfloat = 0;
b_float_negmaxfloat = 0;
b_float_negminfloat = 0;
   int dataPTR =0;


   dataPTR++;
if (strcmp(data[dataPTR],_b_floatZERO)==0)
      b_float_zero = 1;
   else if (strcmp(data[dataPTR],_b_floatONE)==0)
      b_float_one = 1;
   else if (strcmp(data[dataPTR],_b_floatNEGONE)==0)
      b_float_negone = 1;
   else if (strcmp(data[dataPTR],_b_floatFMINEXP)==0)
      b_float_fminexp = 1;
   else if (strcmp(data[dataPTR],_b_floatMLN2)==0)
      b_float_mln2 = 1;
   else if (strcmp(data[dataPTR],_b_floatMPI)==0)
      b_float_mpi = 1;
   else if (strcmp(data[dataPTR],_b_floatHALF_PI)==0)
      b_float_half_pi = 1;
   else if (strcmp(data[dataPTR],_b_floatQUARTER_PI)==0)
      b_float_quarter_pi = 1;
   else if (strcmp(data[dataPTR],_b_floatTWO_PI)==0)
      b_float_two_pi = 1;
   else if (strcmp(data[dataPTR],_b_floatMSQRT2)==0)
      b_float_msqrt2 = 1;
   else if (strcmp(data[dataPTR],_b_floatE)==0)
      b_float_e = 1;
   else if (strcmp(data[dataPTR],_b_floatMAXFLOAT)==0)
      b_float_maxfloat = 1;
   else if (strcmp(data[dataPTR],_b_floatMINFLOAT)==0)
      b_float_minfloat = 1;
   else if (strcmp(data[dataPTR],_b_floatNEGMAXFLOAT)==0)
      b_float_negmaxfloat = 1;
   else if (strcmp(data[dataPTR],_b_floatNEGMINFLOAT)==0)
      b_float_negminfloat = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"HVAL"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

if (b_float_zero==1)
{

 _theVariable=0.0;
 
}

if (b_float_one==1)
{

 _theVariable=1.0;
 
}

if (b_float_negone==1)
{

 _theVariable=-1.0;
 
}

if (b_float_fminexp==1)
{

 _theVariable=FMINEXP; 
 
}

if (b_float_mln2==1)
{

 _theVariable=M_LN2; 
 
}

if (b_float_mpi==1)
{

 _theVariable=M_PI;
 
}

if (b_float_half_pi==1)
{

 _theVariable = M_PI/2;
 
}

if (b_float_quarter_pi==1)
{

 _theVariable = M_PI/4;
 
}

if (b_float_two_pi==1)
{

 _theVariable = M_PI * 2.0;
 
}

if (b_float_msqrt2==1)
{

 _theVariable=M_SQRT2;
 
}

if (b_float_e==1)
{

 _theVariable= M_E; 
 
}

if (b_float_maxfloat==1)
{

 _theVariable=MAXFLOAT;
 
}

if (b_float_minfloat==1)
{

 _theVariable=MINFLOAT;
 
}

if (b_float_negmaxfloat==1)
{

 _theVariable=-MAXFLOAT;
 
}

if (b_float_negminfloat==1)
{

 _theVariable=-MINFLOAT;
 
}
   return &_theVariable;
}

//--------------------------------------------------------------------
  int CLASSNAME::commit(b_param tname)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::commit(tname);
  //COMMIT CODE HERE
//generated
   return 0;
}

//--------------------------------------------------------------------
  int CLASSNAME::cleanup(b_param tname)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::cleanup(tname);
      
  //CLEANUP CODE
//generated
   return 0;
}

//--------------------------------------------------------------------
int CLASSNAME::numDials(b_param tname)
{
  if (!strcmp(tname,(char *)typeName()))
    return NUMBER_OF_DIALS;
  else return CLASSPARENT::numDials(tname);
      
}


//---------------------------------------------------------------------------
int CLASSNAME::numItems(b_param tname,int dialNumber)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::numItems(tname,dialNumber);
  switch (dialNumber)
    {
      //NUMITEMS SWITCH CASES HERE
      //generated

   case 1:
      return 15;
      break;
//---------------------------------------------------------------------------
      //end generated

    default:
      cerr<<"Error, invalid dial number passed to "
          <<CLASS_STRING<<"::numItems\n"
          <<"Please check declaration files.  Dial number passed was "
          <<dialNumber<<endl;
      exit(1);
    }
  return 0;
}

//---------------------------------------------------------------------------
b_param *CLASSNAME::paramName(b_param tname,
                                   int dialNumber,
                                   int position)

{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::paramName(tname,dialNumber,position);
  
  switch (dialNumber)
    {
      //PARAMNAME SWITCH CASES HERE
      //generated

case 1:
 switch (position)
   {
      case 1:
         return b_floatZERO();
         break;
      case 2:
         return b_floatONE();
         break;
      case 3:
         return b_floatNEGONE();
         break;
      case 4:
         return b_floatFMINEXP();
         break;
      case 5:
         return b_floatMLN2();
         break;
      case 6:
         return b_floatMPI();
         break;
      case 7:
         return b_floatHALF_PI();
         break;
      case 8:
         return b_floatQUARTER_PI();
         break;
      case 9:
         return b_floatTWO_PI();
         break;
      case 10:
         return b_floatMSQRT2();
         break;
      case 11:
         return b_floatE();
         break;
      case 12:
         return b_floatMAXFLOAT();
         break;
      case 13:
         return b_floatMINFLOAT();
         break;
      case 14:
         return b_floatNEGMAXFLOAT();
         break;
      case 15:
         return b_floatNEGMINFLOAT();
         break;

      default:
          cerr<<"Error, invalid position number passed to "
              <<CLASS_STRING<<"::paramName\n"
              <<"Please check declaration files.  Dial number passed was"
              <<dialNumber<<" position "<<position<<".\n";
          exit(1);
   }
   break;
    default:
      cerr<<"Error, invalid dial number passed to "
          <<CLASS_STRING<<"::paramName\n"
          <<"Please check declaration files.  Dial number passed was "
          <<dialNumber<<endl;
      exit(1);

    }
  return NULL;
}

//---------------------------------------------------------------------------
