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

#include "ourTypes.h"
#include "DynamicArray.h"

/*
CLASS 
Attribute

DESCRIPTION
An attribute is specified by a name/value pair.

AUTHOR
Tom O'Reilly
*/
class Attribute {

public:

  Attribute(const char *name, const char *description);

  virtual ~Attribute();

  ///////////////////////////////////////////////////////////////////
  // Mnemonic for Attribute subclass
  virtual const char *typeMnem() = 0;

  ///////////////////////////////////////////////////////////////////
  // Set Attribute's value, given string representation
  virtual void setValue(const char *stringRep) = 0;

  ///////////////////////////////////////////////////////////////////
  // String representation of value
  virtual const char *valueString() = 0;

  ///////////////////////////////////////////////////////////////////
  // Attribute name
  const char *name();

  ///////////////////////////////////////////////////////////////////
  // Attribute description
  const char *description();

  ///////////////////////////////////////////////////////////////////
  // Return True if Attribute has default value, else return False
  Boolean hasDefault();

  ///////////////////////////////////////////////////////////////////
  // Call after setValue()
  void markAsSet();

  ///////////////////////////////////////////////////////////////////
  // Return True if markAsSet() has been called, else return False
  Boolean valueHasBeenSet();

  ///////////////////////////////////////////////////////////////////
  // Return True is the value is appropriate
  virtual Boolean verify()
       { return True; };

  ///////////////////////////////////////////////////////////////////
  // Print description
  void printDescription();

  ///////////////////////////////////////////////////////////////////
  // Attribute name-value input. 
  struct Input {

    Input(const char *name, const char *value);
    ~Input();

    ///////////////////////////////////////////////////////////////////
    // Attribute name
    const char *name;

    ///////////////////////////////////////////////////////////////////
    // String representation of attribute value
    const char *valueString;
  };

  
protected:
  
  const char *_name;

  const char *_description;

  Boolean _hasDefault;

  Boolean _valueHasBeenSet;
};

typedef DynamicArray<Attribute::Input *> AttributeInputs;

#endif

