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

#include "Attribute.h"
#include "DynamicArray.h"
#include "ourTypes.h"
#include "Exception.h"

typedef DynamicArray<Attribute::Input *> AttributeInputList;

/*
CLASS 
Attributes

DESCRIPTION
Collection of Attribute objects, with utilities

AUTHOR
Tom O'Reilly
*/
class Attributes {

public:

  Attributes(const char *objectName);
  ~Attributes();

  ///////////////////////////////////////////////////////////////////
  // Name of object with which attributes are associated
  const char *objectName();

  ///////////////////////////////////////////////////////////////////
  // Add Attribute to collection
  void add(Attribute *attribute) {
    list.add(&attribute);
  }

  ///////////////////////////////////////////////////////////////////
  // Parse an Attribute::Input, which must correspond to an Attribute
  // in the collection
  int parse(Attribute::Input *input);

  ///////////////////////////////////////////////////////////////////
  // Parse Attribute::Input list; each must correspond to an object
  // in the collection
  int parse(AttributeInputList *inputs);

  ///////////////////////////////////////////////////////////////////
  // Check that all mandatory Attribute objects have been specified
  // via one of the parse() methods. A "mandatory" Attribute is one
  // for which there is no default value.
  int verify();

  ///////////////////////////////////////////////////////////////////
  // Print descriptions of contained Attribute objects
  void printDescriptions();

  DynamicArray<Attribute *> list;

protected:

  const char *_objectName;
};


// Parse function prototype
void parseAttributes(FILE *fp, 
		     Attributes *attributes,
		     Boolean *error, 
		     char *errorMsg);

#endif
