home *** CD-ROM | disk | FTP | other *** search
- /*
- * This is a semi-generic List class.
- * This was written for FolkScan v2.2
- * Copyright (C) 1992 Cory West
- * corywest@rice.edu ; List.h ; Fri Nov 13 17:34:46 CST 1992
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 1, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #include <String.h>
- #include <bool.h>
- #include <curses.h>
- #include <string.h>
-
- // These are list links
- struct ListLink
- {
- ListLink* next = NULL;
- ListLink* prev = NULL;
- String name;
- int alive = 3;
-
- // These are used when FolkScan runs in the background.
- // This is yet another adaption to the interface.
- // I should separate all of these special cases into a
- // set of inherited classes.
- bool seen = FALSE;
- bool clean = TRUE;
- };
-
- // This controls access to the list
- class List
- {
- private:
-
- ListLink* head = NULL;
- int length = 0;
-
- public:
-
- // Constructor and Destructor
- List() { ; }
-
- // Useful interface functions
-
- int GetSize() { return length; }
- // Return the number of elements in the
- // list. Index starts at 1.
-
- void AddElement(String);
- // Add something to the list.
-
- String GetElement(int location);
- // Get the element in the specified in zero based
- // location.
-
- void MarkDead(String);
- // Decrement the named hosts grace failures.
-
- void RemoveDead(WINDOW*);
- // Remove dead hosts and report to the given WINDOW.
-
- bool unify(char*);
- // This is a semi-robust function to allow
- // us to use this list as a cache. If the
- // provided char* already exists in the
- // List, then this returns false. Otherwise
- // it returns true and remembers that we've
- // seen the entry. Report problems to errs.
-
- void dump(void);
- // Totally clean out the structure.
-
- void printall(void);
- // Print the representation of the structure
- // out to standard error for debugging usage.
-
- void Seen(int);
- // We've seen this node (user in the case that we use
- // it) logged in.
-
- void UnSee(int);
- // Unmark the seen bit.
-
- bool Saw(int);
- // Predicate for Seen();
-
- void CleanAll(void);
- // Mark all the the clean booleans to TRUE;
-
- void MakeDirty(int);
- // Mark the kth node as dirty.
-
- bool isClean(int);
- // Is the kth node clean?
- };
-
-
-
-