/* -*- C++ -*- */
/******************************************************************************
*                                                                             *
*  File: DependencySpecification.h                                            *
*                                                                             *
*  Description: Defines the DependencySpecification type,                     *
*               a pair (hookName, component).                                 *
*               It is used in two situations:                                 *
*                  1) to represent components attached to local hooks and     *
*                  2) to represent client hooks to which this component       *
*                     is attached.                                            *
*                                                                             *
*  Project: 2K - Automatic Configuration                                      *
*  Author: Fabio Kon (f-kon@cs.uiuc.edu)                                      *
*                                                                             *
*******************************************************************************

   Revision Control Information

   $Revision: $

   $Log: $

******************************************************************************/

#if !defined (HOOK_SPECIFICATION_H)
#define HOOK_SPECIFICATION_H

#include "ace/Containers.h"

class ComponentConfigurator;

class DependencySpecification
{
  // This friend declarations allow us to use this type in linked lists.
  friend class ACE_Double_Linked_List<DependencySpecification>;
  friend ACE_Double_Linked_List_Iterator<DependencySpecification>;

public:
  inline DependencySpecification (const char *name = 0, 
                            ComponentConfigurator *compConfig = 0)
    {
      if (name)
        name_ = ACE_OS::strdup(name);
      else
        name_ = 0;
      componentConfig_ = compConfig;
    }

  inline ~DependencySpecification ()
    {
      if(name_)
        ACE_OS::free (name_);
    }

  // accessor methods
  inline const char *name () { return name_;}
  inline ComponentConfigurator *componentConfig () { return componentConfig_; }
  inline void componentConfig (ComponentConfigurator *cc) 
    { componentConfig_ = cc; }

protected:
  DependencySpecification *next_;
  // Pointer to next element in the list of <DependencySpecification>s.

  DependencySpecification *prev_;
  // Pointer to previous element in the list of <DependencySpecificarion>s.

private:
  char *name_;
  ComponentConfigurator *componentConfig_;
};

typedef ACE_Double_Linked_List<DependencySpecification> DependencyList;
typedef ACE_Double_Linked_List_Iterator<DependencySpecification> DependencySpecIterator;
    
#endif
