//
//   COMPONENT_NAME: somx
//
//   ORIGINS: 27
//
//
//   25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//

//   @(#) 1.1 src/somples.os2/somk/c/tp/ll.idl, somples.somk, som3.0 12/2/96 13:56:00 [12/4/96 15:12:17]

/*
 *
 * DISCLAIMER OF WARRANTIES.
 * The following [enclosed] code is sample code created by IBM
 * Corporation. This sample code is not part of any standard or IBM
 * product and is provided to you solely for the purpose of assisting
 * you in the development of your applications.  The code is provided
 * "AS IS". IBM MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF
 * THIS CODE.  IBM shall not be liable for any damages arising out of
 * your use of the sample code, even if they have been advised of the
 * possibility of such damages.
 *
 * DISTRIBUTION.
 * This sample code can be freely distributed, copied, altered, and
 * incorporated into other software, provided that it bears the above
 * Copyright notice and DISCLAIMER intact.
 */


//  This class is adapted from the book
//    Class Construction in C and C++, Object Oriented Fundamentals
//    by Roger Sessions, Copyright (c) 1992 Prentice Hall.
//  Reprinted with permission.

#ifndef ll_idl
#define ll_idl

#include "bt.idl"

interface link;

interface linkedList : baseType
{
  baseType llHead();
  // Make the head of the list the current link, and return its contents.

  baseType llTail();
  // Make the tail of the list the current link, and returns its contents.

  long llLength();
  // Return the number of links is the list.

  void llSetMax(in long newMax);
  // Set the maximum number of links the list can contain.

  long llLeft();
  // Return the number of links that can still be added to the list.

  baseType llNext();
  // Make the link after current the new current link, and
  // return its contents.

  baseType llPrevious();
  // Make the link before current the new current link, and
  // return its contents.

  baseType llRetrieve();
  // Return the contents of the current link.

  baseType llReplace(in baseType newElement);
  // Replace the contents of the current list but this new
  // element, and return a pointer to the new contents.

  baseType llPromoteTail();
  // Move the tail link to the head of the list, and return
  // its contents.

  baseType llAddHead(in baseType newElement);
  // Add a link containing this new Element to the head of the
  // list, and return a pointer to the new Element.

  baseType llAddTail(in baseType newElement);
  // Add a link containing this new Element to the tail of the
  // list, and return a pointer to the new Element.

  baseType llRemoveHead();
  // Delete the link at the head of the list.

  long llIsTail();
  // Returns TRUE if the current link is the head of the list,
  // FALSE otherwise.

  void llFreeContents();
  // Frees the entire list, including the contents of each link.

  void llTrace(inout FILE output);
  // Trace the linkedList, useful for debugging.

#ifdef __SOMIDL__
  implementation {

    releaseorder: llHead,llTail,llLength,llSetMax,llLeft,llNext,llPrevious, 
                  llRetrieve,llReplace,llPromoteTail,llAddHead,llAddTail, 
                  llRemoveHead,llIsTail,llFreeContents,llTrace;

    //# Class Modifiers
    callstyle = oidl;
    filestem = ll;

    passthru C_h =
	"#include \"bt.h\""
        "#include <stdio.h>";

    //# Internal Instance Variables
    long max;                      
    long nlinks;                   
    link currentLink;             
    link headLink;                
    link tailLink;                

    //# Method Modifiers
    print: override;
    somInit: override;
    somUninit: override;
    somDumpSelfInt: override;

  };
#endif /* __SOMIDL__ */
};

#endif  /* ll_idl */
