Coda Distributed File System
olist.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2025 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 *
21 * olist.h -- Specification of singly-linked list type where list elements
22 * can be on only one list at a time.
23 *
24 */
25
26#ifndef _UTIL_LIST_H_
27#define _UTIL_LIST_H_ 1
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdio.h>
34
35#ifdef __cplusplus
36}
37#endif
38
39class olist;
40class olist_iterator;
41class olink;
42
43/* function to examine tag value in object derived from olink;
44 returns 1 on match and 0 on mismatch (Satya, May04) */
45typedef int (*otagcompare_t)(void *tag, void *object);
46
47class olist {
48 friend class olist_iterator;
49 olink *tail; // tail->next is head of list
50 int cnt;
51
52public:
53 olist();
54 olist(olist &); // not supported!
55 int operator=(olist &); // not supported!
56 virtual ~olist();
57 void insert(olink *); // add at head of list
58 void append(olink *); // add at tail of list
59 olink *remove(olink *); // remove specified entry
60 olink *first(); // return head of list
61 olink *last(); // return tail of list
62 olink *get(); // return and remove head of list
63 void clear(); // remove all entries
64 int count();
65 int IsMember(olink *);
66 virtual void print();
67 virtual void print(FILE *);
68 virtual void print(int);
69
70 /* find object with matching tag in olist of objects derived from olink;
71 return NULL if no such object; cmpfn() knows field to examine in object */
72 olink *FindObject(void *tag, otagcompare_t cmpfn);
73};
74
76 olist *clist; // current olist
77public:
78 olink *clink; // current olink
80 olink *operator()(); // return next object or 0
81 // Does NOT support safe deletion of currently
82 // returned entry.
83 void reset(); // allow re-use of iterator (Satya, 5/04)
84};
85
86class olink { // objects are derived from this class
87 friend class olist;
88 friend class olist_iterator;
89 olink *next;
90
91public:
92 olink();
93 olink(olink &); // not supported!
94 int operator=(olink &); // not supported!
95 virtual ~olink();
96 virtual void print();
97 virtual void print(FILE *);
98 virtual void print(int);
99
100 /* Tag matching function for classes derviced from olink;
101 Given pointer to a tag and a compare function, otagmatch() returns 0 or 1
102 Allows generalization of classes olist and ohash to test for
103 presence of object with an arbitrary tag, rather than just
104 match on object pointer */
105 int otagmatch(void *otag, otagcompare_t cmpfn);
106};
107
108#endif /* _UTIL_LIST_H_ */
Definition: olist.h:75
olink * clink
Definition: olist.h:78
olink * operator()()
Definition: olist.cc:230
olist_iterator(olist &)
Definition: olist.cc:224
void reset()
Definition: olist.cc:246
Definition: olist.h:47
olist()
Definition: olist.cc:47
olink * first()
Definition: olist.cc:140
void insert(olink *)
Definition: olist.cc:72
void append(olink *)
Definition: olist.cc:89
int IsMember(olink *)
Definition: olist.cc:175
int operator=(olist &)
Definition: olist.cc:58
olink * get()
Definition: olist.cc:153
virtual ~olist()
Definition: olist.cc:64
olink * remove(olink *)
Definition: olist.cc:107
int count()
Definition: olist.cc:170
virtual void print()
Definition: olist.cc:185
olink * last()
Definition: olist.cc:148
void clear()
Definition: olist.cc:160
olink * FindObject(void *tag, otagcompare_t cmpfn)
Definition: olist.cc:213
PROC * tail
Definition: util.c:74
int(* otagcompare_t)(void *tag, void *object)
Definition: olist.h:45
TYPE_TAG tag
Definition: symtab.c:72