/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DataField.h                                                   */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _DATAFIELD_H
#define _DATAFIELD_H

#include <stdio.h>

class ExternalData;

/*
CLASS 
DataField

DESCRIPTION
Wrapper interface class for primitive data types. Also contains
useful conversion and utility methods.

To subclass DataField, do the following:

* Override pure virtual functions

* Add code to DataFieldFactory::create() to handle your new subclass


AUTHOR
Tom O'Reilly
*/

class DataField {

public:

  DataField(const char *name);

  virtual ~DataField();

  ///////////////////////////////////////////////////////////////////
  // Data type mnemonic. THIS NAME MUST BE UNIQUE TO SUBCLASS. Used
  // by DataFieldFactory.
  virtual const char *typeMnemonic() = 0;

  ///////////////////////////////////////////////////////////////////
  // Data item name
  const char *name();

  ///////////////////////////////////////////////////////////////////
  // Set name of the data item
  void setName(const char *name);

  ///////////////////////////////////////////////////////////////////
  // Set format for printing      
  void setAsciiFormat(const char *format);

  ///////////////////////////////////////////////////////////////////
  // Format for printing      
  virtual const char *asciiFormat();

  ///////////////////////////////////////////////////////////////////
  // Set value of ExternalData object
  virtual void write(ExternalData *externalData) = 0;

  ///////////////////////////////////////////////////////////////////
  // Get value from ExternalData object
  virtual void read(ExternalData *externalData) = 0;

  ///////////////////////////////////////////////////////////////////
  // Print ascii representation of value into buffer
  virtual const char *ascii() = 0;

  ///////////////////////////////////////////////////////////////////
  // Set value, given string representation
  virtual void parseValue(const char *stringRep) = 0;


private:

  char _name[32];
  char _asciiFormat[16];
};


#endif

