summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/Array.cc79
-rw-r--r--utils/Array.h41
-rw-r--r--utils/Automaton.cc85
-rw-r--r--utils/Automaton.h132
-rw-r--r--utils/BitField.cc13
-rw-r--r--utils/BitField.h17
-rw-r--r--utils/Chain.cc123
-rw-r--r--utils/Chain.h95
-rw-r--r--utils/DList.cc247
-rw-r--r--utils/DList.h156
-rw-r--r--utils/DirPath.cc59
-rw-r--r--utils/DirPath.h13
-rw-r--r--utils/HashTable.cc291
-rw-r--r--utils/HashTable.h191
-rw-r--r--utils/IdTable.cc88
-rw-r--r--utils/IdTable.h82
-rw-r--r--utils/Imakefile91
-rw-r--r--utils/Initializer.h4
-rw-r--r--utils/List.cc320
-rw-r--r--utils/List.h205
-rwxr-xr-xutils/Makefile179
-rw-r--r--utils/RegExp.cc31
-rw-r--r--utils/RegExp.h20
-rw-r--r--utils/Signal.cc68
-rw-r--r--utils/Signal.h22
-rw-r--r--utils/SmartPointer.cc290
-rw-r--r--utils/SmartPointer.h122
-rw-r--r--utils/String.cc73
-rw-r--r--utils/String.h40
-rw-r--r--utils/Time.cc36
-rw-r--r--utils/Time.h12
-rw-r--r--utils/Timer.cc169
-rw-r--r--utils/Timer.h54
-rw-r--r--utils/cplus_bugs.h6
-rw-r--r--utils/doc.main124
-rw-r--r--utils/metaclass.h5
-rw-r--r--utils/testchain.cc14
-rw-r--r--utils/testdirpath.cc3
-rw-r--r--utils/testdlist.cc14
-rw-r--r--utils/testhash.cc7
-rw-r--r--utils/testid.cc8
-rw-r--r--utils/testlist.cc16
-rw-r--r--utils/testregexp.cc2
-rw-r--r--utils/testsignal.cc10
-rw-r--r--utils/testtimer.cc16
-rw-r--r--utils/version.h9
46 files changed, 1634 insertions, 2048 deletions
diff --git a/utils/Array.cc b/utils/Array.cc
index e51e7ae..26bafbe 100644
--- a/utils/Array.cc
+++ b/utils/Array.cc
@@ -17,24 +17,24 @@
#include <memory.h>
#include <stdio.h>
-/*?class CcuArray
-\typ{CcuArray}s are dynamic arrays whose lower bound is 0. For a
-\typ{CcuArray} with size \var{size}, the valid indices are \var{0, \ldots, size -- 1.}
-Their elements are of type \typ{CcuArrayItem*}. Methods are provided for
+/*?class IvlArray
+\typ{IvlArray}s are dynamic arrays whose lower bound is 0. For a
+\typ{IvlArray} with size \var{size}, the valid indices are \var{0, \ldots, size -- 1.}
+Their elements are of type \typ{IvlArrayItem*}. Methods are provided for
initialization, data storage and retrieval, and a few other utilities.
?*/
-CcuArrayItem* CcuArray::InvalidCell = 0;
+IvlArrayItem* IvlArray::InvalidCell = 0;
/*?
-Initialize a \typ{CcuArray} with size \var{size}.
+Initialize a \typ{IvlArray} with size \var{size}.
Entries are initialized to \var{value}.
?*/
-CcuArray :: CcuArray (int size, CcuArrayItem* value)
+IvlArray :: IvlArray (int size, IvlArrayItem* value)
{
if (size > 0) {
- Data = new CcuArrayItem* [size];
- register CcuArrayItem** p = Data;
+ Data = new IvlArrayItem* [size];
+ register IvlArrayItem** p = Data;
for (register int i = 0; i < size; ++i, ++p)
*p = value;
} else {
@@ -47,15 +47,15 @@ CcuArray :: CcuArray (int size, CcuArrayItem* value)
}
/*?nodoc?*/
-CcuArray :: CcuArray (const CcuArray& a)
+IvlArray :: IvlArray (const IvlArray& a)
: Length (a.Length)
{
if (Length == 0) {
Data = 0;
} else {
- Data = new CcuArrayItem* [Length];
- register CcuArrayItem** p;
- register CcuArrayItem** q;
+ Data = new IvlArrayItem* [Length];
+ register IvlArrayItem** p;
+ register IvlArrayItem** q;
register int i;
for (p = Data, q = a.Data, i = Length ; i--; ++p, ++q)
*p = *q;
@@ -63,7 +63,7 @@ CcuArray :: CcuArray (const CcuArray& a)
}
/*?nodoc?*/
-CcuArray :: ~CcuArray ()
+IvlArray :: ~IvlArray ()
{
/* Free the data */
Clean ();
@@ -74,7 +74,7 @@ CcuArray :: ~CcuArray ()
*/
/*?hidden?*/
void
-CcuArray :: Clean ()
+IvlArray :: Clean ()
{
if (Data)
#ifndef CPLUS_BUG4
@@ -87,14 +87,13 @@ CcuArray :: Clean ()
Length = 0;
}
-
/*?
Set all entries to \var{value}.
?*/
void
-CcuArray :: Reset (CcuArrayItem* value)
+IvlArray :: Reset (IvlArrayItem* value)
{
- register CcuArrayItem** p;
+ register IvlArrayItem** p;
register int i;
for (p = Data, i = Length ; i--; ++p)
*p = value;
@@ -104,15 +103,15 @@ CcuArray :: Reset (CcuArrayItem* value)
Copy the contents of the array \var{from} into this array.
The old contents, if any, are freed, and new memory is allocated for the copy.
?*/
-CcuArray&
-CcuArray :: operator = (const CcuArray& from)
+IvlArray&
+IvlArray :: operator = (const IvlArray& from)
{
if (this != &from) {
Clean ();
Length = from.Length;
if (Length > 0 && from.Data) {
- Data = new CcuArrayItem* [Length];
- memcpy (Data, from.Data, Length * sizeof (CcuArrayItem*));
+ Data = new IvlArrayItem* [Length];
+ memcpy (Data, from.Data, Length * sizeof (IvlArrayItem*));
} else
Data = 0;
}
@@ -125,25 +124,25 @@ are set to \var{value}.
This function reallocates the contents of the array.
?*/
void
-CcuArray :: Resize (int size, CcuArrayItem* value)
+IvlArray :: Resize (int size, IvlArrayItem* value)
{
if (size <= 0) {
Clean ();
return;
}
- CcuArrayItem** NewData = new CcuArrayItem* [size];
+ IvlArrayItem** NewData = new IvlArrayItem* [size];
/* if the new sequence is longer, copy and fill end, else just copy */
if (size > Length) {
if (Length)
- memcpy (NewData, Data, Length * sizeof (CcuArrayItem*));
+ memcpy (NewData, Data, Length * sizeof (IvlArrayItem*));
- register CcuArrayItem** pfil = NewData + Length;
+ register IvlArrayItem** pfil = NewData + Length;
for (register int i = size - Length; i--; *pfil++ = value)
;
} else
- memcpy (NewData, Data, size * sizeof (CcuArrayItem*));
+ memcpy (NewData, Data, size * sizeof (IvlArrayItem*));
/* free old data and set new array */
@@ -152,12 +151,11 @@ CcuArray :: Resize (int size, CcuArrayItem* value)
Length = size;
}
-
/*?
Return the address of the \var{i}th element.
?*/
-CcuArrayItem**
-CcuArray :: operator + (register int i) const
+IvlArrayItem**
+IvlArray :: operator + (register int i) const
{
if (Check (i))
return Data+i;
@@ -167,14 +165,13 @@ CcuArray :: operator + (register int i) const
}
}
-
/*?
Get a reference to the \var{i}-th entry, so that this entry can be read or written.
If \var{i} is outside the bounds,
the operator returns a reference to a static variable which initially contains 0.
?*/
-CcuArrayItem*&
-CcuArray :: operator [] (register int i) const
+IvlArrayItem*&
+IvlArray :: operator [] (register int i) const
{
if (Check (i))
return Data [i];
@@ -185,42 +182,42 @@ CcuArray :: operator [] (register int i) const
}
#ifdef DOC
-/*?class CcuArrayOf
-The generic class \typ{CcuArrayOf} is a derived class of \typ{CcuArray} that provides
+/*?class IvlArrayOf
+The generic class \typ{IvlArrayOf} is a derived class of \typ{IvlArray} that provides
arrays of pointers to class objects. When parameterized by the class \typ{ITEM},
the following functions are redefined:
?*/
/*?nextdoc?*/
-CcuArrayOf :: CcuArrayOf (int size, ITEM* value = 0)
+IvlArrayOf :: IvlArrayOf (int size, ITEM* value = 0)
{
}
/*?nextdoc?*/
void
-CcuArrayOf :: Reset (ITEM* value = 0)
+IvlArrayOf :: Reset (ITEM* value = 0)
{
}
/*?nextdoc?*/
void
-CcuArrayOf :: Resize (int size, ITEM* value = 0)
+IvlArrayOf :: Resize (int size, ITEM* value = 0)
{
}
/*?nextdoc?*/
ITEM*&
-CcuArrayOf :: operator [] (int i) const
+IvlArrayOf :: operator [] (int i) const
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuArray},
+These functions are equivalent to their homonyms in the class \typ{IvlArray},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
ITEM**
-CcuArrayOf :: operator + (int i) const
+IvlArrayOf :: operator + (int i) const
{
}
diff --git a/utils/Array.h b/utils/Array.h
index a36ed36..2a5da6a 100644
--- a/utils/Array.h
+++ b/utils/Array.h
@@ -13,45 +13,44 @@
* $CurLog$
*/
-
#ifndef Array_H_
#define Array_H_
#include "cplus_bugs.h"
-typedef void CcuArrayItem;
+typedef void IvlArrayItem;
-class CcuArray {
+class IvlArray {
protected:
-static CcuArrayItem* InvalidCell;
+static IvlArrayItem* InvalidCell;
int Length;
- CcuArrayItem** Data;
+ IvlArrayItem** Data;
void Clean ();
public:
- CcuArray (int size, CcuArrayItem* = 0);
- CcuArray (const CcuArray&);
- ~CcuArray ();
- void Reset (CcuArrayItem* = 0);
- CcuArrayItem*& operator [] (int i) const;
- CcuArrayItem** operator + (int) const;
- CcuArray& operator = (const CcuArray&);
+ IvlArray (int size, IvlArrayItem* = 0);
+ IvlArray (const IvlArray&);
+ ~IvlArray ();
+ void Reset (IvlArrayItem* = 0);
+ IvlArrayItem*& operator [] (int i) const;
+ IvlArrayItem** operator + (int) const;
+ IvlArray& operator = (const IvlArray&);
inline int Check (int i) const { return (i >= 0 && i < Length); }
inline int GetSize () const { return Length; }
- void Resize (int, CcuArrayItem* = 0);
+ void Resize (int, IvlArrayItem* = 0);
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuArrayOf : public CcuArray {
+template <class ITEM> class IvlArrayOf : public IvlArray {
public:
-inline CcuArrayOf (int size, ITEM* value = 0) : CcuArray (size, value) {}
-inline CcuArrayOf (const CcuArrayOf<ITEM>& a) : CcuArray (a) {}
-inline ~CcuArrayOf () {}
-inline void Reset (ITEM* value = 0) { CcuArray::Reset (value); }
-inline void Resize (int size, ITEM* value = 0) { CcuArray::Resize (size, value); }
-inline ITEM*& operator [] (int i) const { return (ITEM*&) ((* (CcuArray*) this)[i]); }
-inline ITEM** operator + (int i) const { return (ITEM**) ((*(CcuArray*) this) + i); }
+inline IvlArrayOf (int size, ITEM* value = 0) : IvlArray (size, value) {}
+inline IvlArrayOf (const IvlArrayOf<ITEM>& a) : IvlArray (a) {}
+inline ~IvlArrayOf () {}
+inline void Reset (ITEM* value = 0) { IvlArray::Reset (value); }
+inline void Resize (int size, ITEM* value = 0) { IvlArray::Resize (size, value); }
+inline ITEM*& operator [] (int i) const { return (ITEM*&) ((* (IvlArray*) this)[i]); }
+inline ITEM** operator + (int i) const { return (ITEM**) ((*(IvlArray*) this) + i); }
};
#endif
diff --git a/utils/Automaton.cc b/utils/Automaton.cc
index 9643bdb..930edc8 100644
--- a/utils/Automaton.cc
+++ b/utils/Automaton.cc
@@ -14,56 +14,56 @@
#include "Automaton.h"
-CcuBaseLink :: CcuBaseLink (CcuBaseState* s)
+IvlBaseLink :: IvlBaseLink (IvlBaseState* s)
: To (s)
{
}
-CcuBaseLink :: ~CcuBaseLink ()
+IvlBaseLink :: ~IvlBaseLink ()
{
}
-CcuBaseState :: CcuBaseState (const char* name, CcuBaseAutomaton& a)
+IvlBaseState :: IvlBaseState (const char* name, IvlBaseAutomaton& a)
: Name (name),
Links (a.Size, a.Hash, a.Copy, a.Delete, a.Compare),
TheAutomaton (&a)
{
}
-CcuBaseState :: ~CcuBaseState ()
+IvlBaseState :: ~IvlBaseState ()
{
- CcuHashIterOf <CcuBaseLink> l = Links;
+ IvlHashIterOf <IvlBaseLink> l = Links;
while (++l)
delete *l;
}
#if 0
void
-CcuBaseState :: CreateLink (CcuBaseState* to, CcuKey* k)
+IvlBaseState :: CreateLink (IvlBaseState* to, IvlKey* k)
{
- CcuHashCellOf <CcuBaseLink>* c = Links.Add (k);
- c->SetInfo (new CcuBaseLink (to));
+ IvlHashCellOf <IvlBaseLink>* c = Links.Add (k);
+ c->SetInfo (new IvlBaseLink (to));
}
#endif
#if 0
void
-CcuBaseState :: Add (CcuKey* key, CcuBaseLink* l)
+IvlBaseState :: Add (IvlKey* key, IvlBaseLink* l)
{
- CcuHashCellOf <CcuLink>* c = Links.Add (key);
+ IvlHashCellOf <IvlLink>* c = Links.Add (key);
c->SetInfo (l);
}
#endif
-CcuBaseState*
-CcuBaseState :: Next (CcuToken* tk, bool peek)
+IvlBaseState*
+IvlBaseState :: Next (IvlToken* tk, bool peek)
{
- CcuKey* k = TheAutomaton->GetKey ? (TheAutomaton->GetKey) (tk) : tk;
- CcuHashCellOf <CcuBaseLink>* c = Links.Get (k);
+ IvlKey* k = TheAutomaton->GetKey ? (TheAutomaton->GetKey) (tk) : tk;
+ IvlHashCellOf <IvlBaseLink>* c = Links.Get (k);
if (!c)
return 0;
- CcuBaseLink* l = c->GetInfo ();
- CcuBaseState* to = l->GetDestination ();
+ IvlBaseLink* l = c->GetInfo ();
+ IvlBaseState* to = l->GetDestination ();
if (!peek) {
Out ();
@@ -73,7 +73,7 @@ CcuBaseState :: Next (CcuToken* tk, bool peek)
return to;
}
-CcuBaseAutomaton :: CcuBaseAutomaton (AKEY_F gk, HASH_F hash, HCP_F cp, HDEL_F del, HCMP_F cmp, int sz)
+IvlBaseAutomaton :: IvlBaseAutomaton (AKEY_F gk, HASH_F hash, HCP_F cp, HDEL_F del, HCMP_F cmp, int sz)
: Size (sz),
Hash (hash),
Copy (cp),
@@ -85,95 +85,94 @@ CcuBaseAutomaton :: CcuBaseAutomaton (AKEY_F gk, HASH_F hash, HCP_F cp, HDEL_F d
{
}
-CcuBaseAutomaton :: ~CcuBaseAutomaton ()
+IvlBaseAutomaton :: ~IvlBaseAutomaton ()
{
- CcuListIterOf <CcuBaseState> s = AllStates;
+ IvlListIterOf <IvlBaseState> s = AllStates;
while (++s)
delete *s;
}
#if 0
-CcuBaseState*
-CcuBaseAutomaton :: CreateState (const char* n);
+IvlBaseState*
+IvlBaseAutomaton :: CreateState (const char* n);
{
- CcuBaseState* s = new CcuBaseState (n, *this);
+ IvlBaseState* s = new IvlBaseState (n, *this);
AllStates.Append (s);
return s;
}
#endif
-
-CcuLink :: CcuLink (CcuState* s, CcuLinkFun fn)
-: CcuBaseLink (s),
+IvlLink :: IvlLink (IvlState* s, IvlLinkFun fn)
+: IvlBaseLink (s),
Fun (fn)
{
}
-CcuLink :: ~CcuLink ()
+IvlLink :: ~IvlLink ()
{
}
void
-CcuLink :: Fire (CcuBaseState* from, CcuBaseState* to, CcuToken* data)
+IvlLink :: Fire (IvlBaseState* from, IvlBaseState* to, IvlToken* data)
{
if (Fun)
- (*Fun) ((CcuState*) from, (CcuState*) to, data);
+ (*Fun) ((IvlState*) from, (IvlState*) to, data);
}
-CcuState :: CcuState (const char* name, CcuAutomaton& a, CcuStateFun* in, CcuStateFun* out)
-: CcuBaseState (name, a),
+IvlState :: IvlState (const char* name, IvlAutomaton& a, IvlStateFun* in, IvlStateFun* out)
+: IvlBaseState (name, a),
InFun (in),
OutFun (out)
{
}
-CcuState :: ~CcuState ()
+IvlState :: ~IvlState ()
{
}
void
-CcuState :: In ()
+IvlState :: In ()
{
if (InFun) (*InFun) (this);
}
void
-CcuState :: Out ()
+IvlState :: Out ()
{
if (OutFun) (*OutFun) (this);
}
void
-CcuState :: CreateLink (CcuState* to, CcuKey* k, CcuLinkFun fn)
+IvlState :: CreateLink (IvlState* to, IvlKey* k, IvlLinkFun fn)
{
- CcuHashCellOf <CcuBaseLink>* c = Links.Add (k);
- c->SetInfo (new CcuLink (to, fn));
+ IvlHashCellOf <IvlBaseLink>* c = Links.Add (k);
+ c->SetInfo (new IvlLink (to, fn));
}
-CcuState*
-CcuAutomaton :: CreateState (const char* n, CcuStateFun in, CcuStateFun out)
+IvlState*
+IvlAutomaton :: CreateState (const char* n, IvlStateFun in, IvlStateFun out)
{
- CcuState* s = new CcuState (n, *this, in, out);
+ IvlState* s = new IvlState (n, *this, in, out);
AllStates.Append (s);
return s;
}
-CcuAutomIter :: CcuAutomIter (CcuBaseAutomaton& a)
+IvlAutomIter :: IvlAutomIter (IvlBaseAutomaton& a)
: TheAutomaton (&a),
CurState (a.GetInitial ())
{
}
-CcuAutomIter :: ~CcuAutomIter ()
+IvlAutomIter :: ~IvlAutomIter ()
{
}
bool
-CcuAutomIter :: Step (CcuToken* tk)
+IvlAutomIter :: Step (IvlToken* tk)
{
if (!CurState && !(CurState = TheAutomaton->GetInitial ()))
return false;
- CcuBaseState* n = CurState->Next (tk);
+ IvlBaseState* n = CurState->Next (tk);
if (!n)
return false;
CurState = n;
diff --git a/utils/Automaton.h b/utils/Automaton.h
index a85d911..c865b76 100644
--- a/utils/Automaton.h
+++ b/utils/Automaton.h
@@ -12,8 +12,8 @@
* $CurLog$
*/
-#ifndef CcuAutomaton_H_
-#define CcuAutomaton_H_
+#ifndef IvlAutomaton_H_
+#define IvlAutomaton_H_
#include "cplus_bugs.h"
#include "List.h"
@@ -21,52 +21,50 @@
#include "String.h"
#include "bool.h"
-typedef void CcuToken;
-typedef void CcuKey;
-class CcuBaseState;
-class CcuBaseAutomaton;
+typedef void IvlToken;
+typedef void IvlKey;
+class IvlBaseState;
+class IvlBaseAutomaton;
-class CcuBaseLink {
+class IvlBaseLink {
protected:
- CcuBaseState* To;
+ IvlBaseState* To;
public:
- CcuBaseLink (CcuBaseState*);
-virtual ~CcuBaseLink ();
-virtual void Fire (CcuBaseState*, CcuBaseState*, CcuToken*) = 0;
-inline CcuBaseState* GetDestination () const { return To;}
+ IvlBaseLink (IvlBaseState*);
+virtual ~IvlBaseLink ();
+virtual void Fire (IvlBaseState*, IvlBaseState*, IvlToken*) = 0;
+inline IvlBaseState* GetDestination () const { return To;}
};
-class CcuBaseState {
+class IvlBaseState {
protected:
- CcuString Name;
- CcuHashTableOf <CcuBaseLink> Links;
- CcuBaseAutomaton* TheAutomaton;
+ IvlString Name;
+ IvlHashTableOf <IvlBaseLink> Links;
+ IvlBaseAutomaton* TheAutomaton;
virtual void In () = 0;
virtual void Out () = 0;
public:
- CcuBaseState (const char*, CcuBaseAutomaton&);
-virtual ~CcuBaseState ();
- void Add (CcuBaseLink*);
- void CreateLink (CcuBaseState*, CcuKey*);
- void RemoveLink (CcuBaseLink*);
- CcuBaseState* Next (CcuToken*, bool = false);
+ IvlBaseState (const char*, IvlBaseAutomaton&);
+virtual ~IvlBaseState ();
+ void Add (IvlBaseLink*);
+ void CreateLink (IvlBaseState*, IvlKey*);
+ void RemoveLink (IvlBaseLink*);
+ IvlBaseState* Next (IvlToken*, bool = false);
};
-
#if 0
-typedef unsigned int (*HASH_F) (const CcuKey*, int);
-typedef int (*HCMP_F) (const CcuKey*, const CcuKey*);
-typedef CcuKey* (*HCP_F) (const CcuKey*);
-typedef void (*HDEL_F) (const CcuKey*);
+typedef unsigned int (*HASH_F) (const IvlKey*, int);
+typedef int (*HCMP_F) (const IvlKey*, const IvlKey*);
+typedef IvlKey* (*HCP_F) (const IvlKey*);
+typedef void (*HDEL_F) (const IvlKey*);
#endif
-typedef CcuKey* (*AKEY_F) (CcuToken*);
-
+typedef IvlKey* (*AKEY_F) (IvlToken*);
-class CcuBaseAutomaton {
-friend class CcuBaseState;
-friend class CcuAutomIter;
+class IvlBaseAutomaton {
+friend class IvlBaseState;
+friend class IvlAutomIter;
protected:
int Size;
HASH_F Hash;
@@ -74,64 +72,60 @@ protected:
HDEL_F Delete;
HCMP_F Compare;
AKEY_F GetKey;
- CcuBaseState* Initial;
- CcuListOf <CcuBaseState> AllStates;
+ IvlBaseState* Initial;
+ IvlListOf <IvlBaseState> AllStates;
public:
- CcuBaseAutomaton (AKEY_F = 0, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0, int sz = 4);
- ~CcuBaseAutomaton ();
-inline CcuBaseState* GetInitial () { return Initial; }
-inline void SetInitial (CcuBaseState* s) { Initial = s; }
- CcuBaseState* CreateState (const char* = 0);
+ IvlBaseAutomaton (AKEY_F = 0, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0, int sz = 4);
+ ~IvlBaseAutomaton ();
+inline IvlBaseState* GetInitial () { return Initial; }
+inline void SetInitial (IvlBaseState* s) { Initial = s; }
+ IvlBaseState* CreateState (const char* = 0);
};
+class IvlState;
+typedef void (IvlLinkFun) (IvlState*, IvlState*, IvlToken*);
-class CcuState;
-typedef void (CcuLinkFun) (CcuState*, CcuState*, CcuToken*);
-
-class CcuLink : public CcuBaseLink {
+class IvlLink : public IvlBaseLink {
protected:
- CcuLinkFun* Fun;
+ IvlLinkFun* Fun;
public:
- CcuLink (CcuState*, CcuLinkFun*);
- ~CcuLink ();
- void Fire (CcuBaseState*, CcuBaseState*, CcuToken*);
+ IvlLink (IvlState*, IvlLinkFun*);
+ ~IvlLink ();
+ void Fire (IvlBaseState*, IvlBaseState*, IvlToken*);
};
-typedef void (CcuStateFun) (CcuState*);
-class CcuAutomaton;
+typedef void (IvlStateFun) (IvlState*);
+class IvlAutomaton;
-class CcuState : public CcuBaseState {
+class IvlState : public IvlBaseState {
protected:
- CcuStateFun* InFun;
- CcuStateFun* OutFun;
+ IvlStateFun* InFun;
+ IvlStateFun* OutFun;
void In ();
void Out ();
public:
- CcuState (const char*, CcuAutomaton&, CcuStateFun* = 0, CcuStateFun* = 0);
- ~CcuState ();
- void CreateLink (CcuState*, CcuKey*, CcuLinkFun);
+ IvlState (const char*, IvlAutomaton&, IvlStateFun* = 0, IvlStateFun* = 0);
+ ~IvlState ();
+ void CreateLink (IvlState*, IvlKey*, IvlLinkFun);
};
-
-class CcuAutomaton : public CcuBaseAutomaton {
+class IvlAutomaton : public IvlBaseAutomaton {
public:
-inline CcuAutomaton () : CcuBaseAutomaton () {}
-inline ~CcuAutomaton () {}
- CcuState* CreateState (const char* = 0, CcuStateFun = 0, CcuStateFun = 0);
+inline IvlAutomaton () : IvlBaseAutomaton () {}
+inline ~IvlAutomaton () {}
+ IvlState* CreateState (const char* = 0, IvlStateFun = 0, IvlStateFun = 0);
};
-class CcuAutomIter {
+class IvlAutomIter {
protected:
- CcuBaseAutomaton* TheAutomaton;
- CcuBaseState* CurState;
+ IvlBaseAutomaton* TheAutomaton;
+ IvlBaseState* CurState;
public:
- CcuAutomIter (CcuBaseAutomaton&);
- ~CcuAutomIter ();
- bool Step (CcuToken*);
+ IvlAutomIter (IvlBaseAutomaton&);
+ ~IvlAutomIter ();
+ bool Step (IvlToken*);
};
-
-
-#endif /* CcuAutomaton_H_ */
+#endif /* IvlAutomaton_H_ */
diff --git a/utils/BitField.cc b/utils/BitField.cc
index ad9532a..d1fabc4 100644
--- a/utils/BitField.cc
+++ b/utils/BitField.cc
@@ -12,18 +12,17 @@
* $CurLog$
*/
-
#include "BitField.h"
#include <memory.h>
#include <stdio.h>
-CcuBitField :: CcuBitField ()
+IvlBitField :: IvlBitField ()
{
memset ((char*) Chunks, 0, 8 * sizeof (long));
}
-CcuBitRef
-CcuBitField :: operator [] (int i)
+IvlBitRef
+IvlBitField :: operator [] (int i)
{
if (i < 0 || i >= 8 * sizeof (long)) {
fprintf (stderr, "Bad access to bitfield: index %d\n", i);
@@ -31,16 +30,16 @@ CcuBitField :: operator [] (int i)
}
short q = i / sizeof (long);
short r = i - q * sizeof (long);
- return CcuBitRef (*this, q, r);
+ return IvlBitRef (*this, q, r);
}
-CcuBitRef :: operator bool () const
+IvlBitRef :: operator bool () const
{
return bool (Field.Chunks [Chunk] & (1L << Offset));
}
bool
-CcuBitRef :: operator = (bool b) const
+IvlBitRef :: operator = (bool b) const
{
long* l = Field.Chunks + Chunk;
long m = (1L << Offset);
diff --git a/utils/BitField.h b/utils/BitField.h
index 8377d29..26908ef 100644
--- a/utils/BitField.h
+++ b/utils/BitField.h
@@ -18,29 +18,28 @@
#include "cplus_bugs.h"
#include "bool.h"
-class CcuBitRef {
-friend class CcuBitField;
+class IvlBitRef {
+friend class IvlBitField;
protected:
short Chunk;
short Offset;
- CcuBitField& Field;
-inline CcuBitRef (CcuBitField& f, short c, short o) : Field (f), Chunk (c), Offset (o) {}
+ IvlBitField& Field;
+inline IvlBitRef (IvlBitField& f, short c, short o) : Field (f), Chunk (c), Offset (o) {}
public:
operator bool () const;
bool operator = (bool) const;
};
-class CcuBitField {
-friend class CcuBitRef;
+class IvlBitField {
+friend class IvlBitRef;
protected:
long Chunks [8];
public:
- CcuBitField ();
- CcuBitRef operator [] (int);
+ IvlBitField ();
+ IvlBitRef operator [] (int);
};
-
#endif /* BitField_H_ */
diff --git a/utils/Chain.cc b/utils/Chain.cc
index e9cd14f..badc7fc 100644
--- a/utils/Chain.cc
+++ b/utils/Chain.cc
@@ -14,15 +14,15 @@
#include <stdlib.h>
#include <stdio.h>
-CcuChain :: ~CcuChain ()
+IvlChain :: ~IvlChain ()
{
}
-CcuChainItem*
-CcuChain :: GetPrevious (CcuChainItem* i)
+IvlChainItem*
+IvlChain :: GetPrevious (IvlChainItem* i)
{
- register CcuChainItem* c = LastLink;
- register CcuChainItem* n;
+ register IvlChainItem* c = LastLink;
+ register IvlChainItem* n;
while ((n = GetNext (c)) != i)
c = n;
return c;
@@ -32,11 +32,11 @@ CcuChain :: GetPrevious (CcuChainItem* i)
Empty a list.
?*/
void
-CcuChain :: Clear ()
+IvlChain :: Clear ()
{
- CcuChainItem* del = LastLink;
+ IvlChainItem* del = LastLink;
while (del) {
- CcuChainItem* next = GetNext (del);
+ IvlChainItem* next = GetNext (del);
if (next == LastLink)
next = 0;
Delete (del);
@@ -45,10 +45,9 @@ CcuChain :: Clear ()
LastLink = 0;
}
-
/*?nextdoc?*/
-CcuChainItem*
-CcuChain :: First ()
+IvlChainItem*
+IvlChain :: First ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -63,8 +62,8 @@ Return the first/last element in the list, or 0 if the list was empty.
The case of a null element can be distinguished from the case
when the list is empty with the function \fun{GetStatus}.
?*/
-CcuChainItem*
-CcuChain :: Last ()
+IvlChainItem*
+IvlChain :: Last ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -79,13 +78,13 @@ Get the \var{n}-th element of a list. If \var{n} is greater than the length of t
this function returns 0 and sets the status to \var{TooFar}. If \var{n} is negative,
this function returns 0 but sets the status to \var{NoError}.
?*/
-CcuChainItem*
-CcuChain :: Nth (int n)
+IvlChainItem*
+IvlChain :: Nth (int n)
{
StatusFlag = NoError;
if (n <= 0)
return 0;
- CcuChainIter li (*this);
+ IvlChainIter li (*this);
while (n > 0 && ++li)
--n;
if (n != 0)
@@ -97,10 +96,10 @@ CcuChain :: Nth (int n)
Compute the number of elements in a list.
?*/
int
-CcuChain :: Length () const
+IvlChain :: Length () const
{
int result = 0;
- CcuChainIter li (*this);
+ IvlChainIter li (*this);
while (++li)
++result;
return result;
@@ -110,9 +109,9 @@ CcuChain :: Length () const
Check whether an item is present in a list.
?*/
int
-CcuChain :: Find (CcuChainItem* e) const
+IvlChain :: Find (IvlChainItem* e) const
{
- CcuChainIter li (*this);
+ IvlChainIter li (*this);
while (++li)
if (*li == e)
return 1;
@@ -121,7 +120,7 @@ CcuChain :: Find (CcuChainItem* e) const
/*?nextdoc?*/
void
-CcuChain :: Prepend (CcuChainItem* e)
+IvlChain :: Prepend (IvlChainItem* e)
{
if (LastLink) {
/* remember that LastLink->Next is the first */
@@ -137,7 +136,7 @@ CcuChain :: Prepend (CcuChainItem* e)
Insert an element at the beginning/end of a list.
?*/
void
-CcuChain :: Append (CcuChainItem* e)
+IvlChain :: Append (IvlChainItem* e)
{
if (LastLink) {
SetNext (e, GetNext (LastLink));
@@ -152,8 +151,8 @@ CcuChain :: Append (CcuChainItem* e)
/*?
Remove the first element of a list and return it.
?*/
-CcuChainItem*
-CcuChain :: RemoveFirst ()
+IvlChainItem*
+IvlChain :: RemoveFirst ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -163,7 +162,7 @@ CcuChain :: RemoveFirst ()
StatusFlag = NoError;
/* Get the first element */
- CcuChainItem* first = GetNext (LastLink);
+ IvlChainItem* first = GetNext (LastLink);
/* Remove it from the chain */
if (LastLink == first)
@@ -173,13 +172,12 @@ CcuChain :: RemoveFirst ()
return first;
}
-
/*?
Remove the last element of a list and return it. This function has to locate the last
element, and hence has a linear cost.
?*/
-CcuChainItem*
-CcuChain :: RemoveLast ()
+IvlChainItem*
+IvlChain :: RemoveLast ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -189,10 +187,10 @@ CcuChain :: RemoveLast ()
StatusFlag = NoError;
/* Find the element that will be the new LastLink */
- register CcuChainItem* newlast = GetPrevious (LastLink);
+ register IvlChainItem* newlast = GetPrevious (LastLink);
/* Save the element to be deleted and its data */
- CcuChainItem* last = LastLink;
+ IvlChainItem* last = LastLink;
/* Remove it from the chain */
if (newlast == LastLink)
LastLink = 0;
@@ -207,19 +205,18 @@ CcuChain :: RemoveLast ()
Insert an element before the link \var{l}. This function has a linear cost.
?*/
void
-CcuChain :: InsertBefore (CcuChainItem* l, CcuChainItem* e)
+IvlChain :: InsertBefore (IvlChainItem* l, IvlChainItem* e)
{
- CcuChainItem* prev = GetPrevious (l);
+ IvlChainItem* prev = GetPrevious (l);
SetNext (prev, e);
SetNext (e, l);
}
-
/*?
Insert an element after the link \var{l}.
?*/
void
-CcuChain :: InsertAfter (CcuChainItem* l, CcuChainItem* e)
+IvlChain :: InsertAfter (IvlChainItem* l, IvlChainItem* e)
{
SetNext (e, GetNext (l));
SetNext (l, e);
@@ -231,10 +228,10 @@ CcuChain :: InsertAfter (CcuChainItem* l, CcuChainItem* e)
Remove the link which is after \var{l} and return its entry. If \var{l} is the last link of
the list, the first one is removed.
?*/
-CcuChainItem*
-CcuChain :: RemoveAfter (CcuChainItem* l)
+IvlChainItem*
+IvlChain :: RemoveAfter (IvlChainItem* l)
{
- CcuChainItem* del = GetNext (l);
+ IvlChainItem* del = GetNext (l);
if (del == l) {
LastLink = 0;
} else {
@@ -251,11 +248,11 @@ Remove an element from a list. This function iterates through the list until it
If \var{num} is \var{All} or is negative, all appearances of \var{entry} are deleted.
?*/
int
-CcuChain :: Remove (CcuChainItem* entry)
+IvlChain :: Remove (IvlChainItem* entry)
{
int removed = 0;
- CcuChainIter li (*this);
- CcuChainIter lj (*this);
+ IvlChainIter li (*this);
+ IvlChainIter lj (*this);
while (++li) {
if (*li == entry) {
RemoveAfter (lj);
@@ -273,11 +270,11 @@ The actual number of removals is returned.
If \var{num} is \var{All} or is negative, all matching elements are deleted.
?*/
int
-CcuChain :: Remove (int (*p) (CcuChainItem*))
+IvlChain :: Remove (int (*p) (IvlChainItem*))
{
int removed = 0;
- CcuChainIter li (*this);
- CcuChainIter lj (*this);
+ IvlChainIter li (*this);
+ IvlChainIter lj (*this);
while (++li) {
if ((*p) (*li)) {
RemoveAfter (lj);
@@ -288,10 +285,9 @@ CcuChain :: Remove (int (*p) (CcuChainItem*))
return 0;
}
-
/*?nextdoc?*/
void
-CcuChain :: InsertAfter (const CcuChainIter& li, CcuChainItem* e)
+IvlChain :: InsertAfter (const IvlChainIter& li, IvlChainItem* e)
{
if (li.TheChain != this) {
StatusFlag = BadIterator;
@@ -299,13 +295,13 @@ CcuChain :: InsertAfter (const CcuChainIter& li, CcuChainItem* e)
}
StatusFlag = NoError;
if (!li.CurLink) {
- if (li.StatusFlag == CcuChainIter::StartOfChain) {
+ if (li.StatusFlag == IvlChainIter::StartOfChain) {
Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuChain::InsertAfter\n");
+ fprintf (stderr, "abnormal status in IvlChain::InsertAfter\n");
abort ();
}
- } else if (li.StatusFlag == CcuChainIter::EndOfChain) {
+ } else if (li.StatusFlag == IvlChainIter::EndOfChain) {
Append (e);
} else {
InsertAfter (li.CurLink, e);
@@ -314,13 +310,13 @@ CcuChain :: InsertAfter (const CcuChainIter& li, CcuChainItem* e)
/*?
Insert an element before (resp. after) the current position of the iterator \var{li}.
-These functions are both equivalent to \fun{CcuChain::Prepend} if the iterator is at the
+These functions are both equivalent to \fun{IvlChain::Prepend} if the iterator is at the
beginning of the list (ie. before the first element)
\fun{InsertAfter} is performed in a constant time, while \fun{InsertBefore}
has a linear cost.
?*/
void
-CcuChain :: InsertBefore (const CcuChainIter& li, CcuChainItem* e)
+IvlChain :: InsertBefore (const IvlChainIter& li, IvlChainItem* e)
{
if (li.TheChain != this) {
StatusFlag = BadIterator;
@@ -328,13 +324,13 @@ CcuChain :: InsertBefore (const CcuChainIter& li, CcuChainItem* e)
}
StatusFlag = NoError;
if (!li.CurLink) {
- if (li.StatusFlag == CcuChainIter::StartOfChain) {
+ if (li.StatusFlag == IvlChainIter::StartOfChain) {
Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuChain::InsertBefore\n");
+ fprintf (stderr, "abnormal status in IvlChain::InsertBefore\n");
abort ();
}
- } else if (li.StatusFlag == CcuChainIter::EndOfChain) {
+ } else if (li.StatusFlag == IvlChainIter::EndOfChain) {
Append (e);
} else {
InsertBefore (li.CurLink, e);
@@ -349,8 +345,8 @@ If the list is empty, the flag is set to \var{EmptyChain}. In both cases, the
return value is null.
This function may be used
when one wants to iterate through a list and remove some elements:
- CcuChainIter li (l);
- CcuChainIter lj (l);
+ IvlChainIter li (l);
+ IvlChainIter lj (l);
while (++li)
if (do_remove (*li)) {
RemoveAfter (lj);
@@ -358,8 +354,8 @@ when one wants to iterate through a list and remove some elements:
} else
++lj;
?*/
-CcuChainItem*
-CcuChain :: RemoveAfter (const CcuChainIter& li)
+IvlChainItem*
+IvlChain :: RemoveAfter (const IvlChainIter& li)
{
if (li.TheChain != this) {
StatusFlag = BadIterator;
@@ -377,24 +373,22 @@ CcuChain :: RemoveAfter (const CcuChainIter& li)
}
}
-
/*?
Get the current entry pointed by an iterator. This operator returns 0 if the iterator is
at the beginning or the end of the list. To distinguish those cases from the
case when the entry is null, you can use the method \fun{GetStatus}.
?*/
-CcuChainItem*
-CcuChainIter :: operator * () const
+IvlChainItem*
+IvlChainIter :: operator * () const
{
return (CurLink && StatusFlag == Normal) ? CurLink : 0;
}
-
/*?
Take one step of iteration.
?*/
-CcuChainIter&
-CcuChainIter :: operator ++ ()
+IvlChainIter&
+IvlChainIter :: operator ++ ()
{
/* This test covers all the cases :
- the iteration has already begun, and is at its end.
@@ -409,7 +403,6 @@ CcuChainIter :: operator ++ ()
return *this;
}
-
/*?
Try and find the element \var{e} in the list, starting from the
current position of the iterator (this position not included).
@@ -417,7 +410,7 @@ If \var{e} is present, the iterator will
be correctly positionned. If not, it will have reached the end of the list.
?*/
int
-CcuChainIter :: Find (CcuChainItem* e)
+IvlChainIter :: Find (IvlChainItem* e)
{
while (++(*this))
if (**this == e)
diff --git a/utils/Chain.h b/utils/Chain.h
index b9ecf61..91d1315 100644
--- a/utils/Chain.h
+++ b/utils/Chain.h
@@ -17,92 +17,91 @@
#include "cplus_bugs.h"
-typedef void CcuChainItem;
+typedef void IvlChainItem;
-class CcuChainIter;
+class IvlChainIter;
-
-class CcuChain {
-friend class CcuChainIter;
+class IvlChain {
+friend class IvlChainIter;
public:
enum chain_status { NoError, WasEmpty, TooEarly, TooFar, BadIterator };
protected:
- CcuChainItem* LastLink;
+ IvlChainItem* LastLink;
chain_status StatusFlag;
-inline CcuChain () : LastLink (0), StatusFlag (NoError) { }
-inline CcuChain (CcuChainItem* e) : LastLink (e), StatusFlag (NoError) { }
-virtual ~CcuChain ();
+inline IvlChain () : LastLink (0), StatusFlag (NoError) { }
+inline IvlChain (IvlChainItem* e) : LastLink (e), StatusFlag (NoError) { }
+virtual ~IvlChain ();
-virtual CcuChainItem* GetNext (CcuChainItem*) const = 0;
-virtual void SetNext (CcuChainItem*, CcuChainItem*) const = 0;
-virtual void Delete (CcuChainItem*) const = 0;
- CcuChainItem* GetPrevious (CcuChainItem*) ;
+virtual IvlChainItem* GetNext (IvlChainItem*) const = 0;
+virtual void SetNext (IvlChainItem*, IvlChainItem*) const = 0;
+virtual void Delete (IvlChainItem*) const = 0;
+ IvlChainItem* GetPrevious (IvlChainItem*) ;
public:
inline chain_status GetStatus () const { return StatusFlag; }
inline int IsEmpty () const { return !LastLink; }
- CcuChainItem* First ();
- CcuChainItem* Last ();
- CcuChainItem* Nth (int n);
+ IvlChainItem* First ();
+ IvlChainItem* Last ();
+ IvlChainItem* Nth (int n);
int Length () const;
- int Find (CcuChainItem*) const;
+ int Find (IvlChainItem*) const;
- void Append (CcuChainItem*);
- void Prepend (CcuChainItem*);
-inline CcuChain& operator << (CcuChainItem* it) { Append (it); return *this; }
+ void Append (IvlChainItem*);
+ void Prepend (IvlChainItem*);
+inline IvlChain& operator << (IvlChainItem* it) { Append (it); return *this; }
- CcuChainItem* RemoveFirst ();
- CcuChainItem* RemoveLast ();
- int Remove (CcuChainItem*);
- int Remove (int (*) (CcuChainItem*));
+ IvlChainItem* RemoveFirst ();
+ IvlChainItem* RemoveLast ();
+ int Remove (IvlChainItem*);
+ int Remove (int (*) (IvlChainItem*));
void Clear ();
- void InsertAfter (const CcuChainIter&, CcuChainItem*);
- void InsertBefore (const CcuChainIter&, CcuChainItem*);
- CcuChainItem* RemoveAfter (const CcuChainIter&);
- void InsertAfter (CcuChainItem*, CcuChainItem*);
- void InsertBefore (CcuChainItem*, CcuChainItem*);
- CcuChainItem* RemoveAfter (CcuChainItem*);
+ void InsertAfter (const IvlChainIter&, IvlChainItem*);
+ void InsertBefore (const IvlChainIter&, IvlChainItem*);
+ IvlChainItem* RemoveAfter (const IvlChainIter&);
+ void InsertAfter (IvlChainItem*, IvlChainItem*);
+ void InsertBefore (IvlChainItem*, IvlChainItem*);
+ IvlChainItem* RemoveAfter (IvlChainItem*);
};
-class CcuChainIter {
-friend class CcuChain;
+class IvlChainIter {
+friend class IvlChain;
public:
enum chainiter_status { Normal, StartOfChain, EndOfChain };
private:
- const CcuChain* TheChain;
- CcuChainItem* CurLink;
+ const IvlChain* TheChain;
+ IvlChainItem* CurLink;
chainiter_status StatusFlag;
public:
-inline CcuChainIter (const CcuChain& l) : TheChain (&l), CurLink (0), StatusFlag (StartOfChain) { }
+inline IvlChainIter (const IvlChain& l) : TheChain (&l), CurLink (0), StatusFlag (StartOfChain) { }
inline void Reset () { CurLink = 0; StatusFlag = StartOfChain; }
- CcuChainIter& operator ++ ();
- CcuChainItem* operator * () const;
- int Find (CcuChainItem*);
+ IvlChainIter& operator ++ ();
+ IvlChainItem* operator * () const;
+ int Find (IvlChainItem*);
inline chainiter_status GetStatus () const { return StatusFlag; }
inline operator int () const { return StatusFlag == Normal; }
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuChainOf : public CcuChain {
+template <class ITEM> class IvlChainOf : public IvlChain {
protected:
- CcuChainItem* GetNext (CcuChainItem* i) const { return ((ITEM*) i)->GetNext (); }
- void SetNext (CcuChainItem* i, CcuChainItem* j) const { ((ITEM*) i)->SetNext ((ITEM*) j); }
- void Delete (CcuChainItem* i) const { delete (ITEM*) i; }
+ IvlChainItem* GetNext (IvlChainItem* i) const { return ((ITEM*) i)->GetNext (); }
+ void SetNext (IvlChainItem* i, IvlChainItem* j) const { ((ITEM*) i)->SetNext ((ITEM*) j); }
+ void Delete (IvlChainItem* i) const { delete (ITEM*) i; }
public:
-inline CcuChainOf () : CcuChain () { }
-inline CcuChainOf (ITEM* e) : CcuChain (e) { }
-inline ~CcuChainOf () {}
+inline IvlChainOf () : IvlChain () { }
+inline IvlChainOf (ITEM* e) : IvlChain (e) { }
+inline ~IvlChainOf () {}
};
-template <class ITEM> class CcuChainIterOf : public CcuChainIter {
+template <class ITEM> class IvlChainIterOf : public IvlChainIter {
public:
-inline CcuChainIterOf (const CcuChainOf <ITEM>& l) : CcuChainIter (l) { }
-inline ITEM* operator * () const { return (ITEM*) CcuChainIter::operator * (); }
+inline IvlChainIterOf (const IvlChainOf <ITEM>& l) : IvlChainIter (l) { }
+inline ITEM* operator * () const { return (ITEM*) IvlChainIter::operator * (); }
};
#endif /* CPLUS_BUG19 */
diff --git a/utils/DList.cc b/utils/DList.cc
index 9ccae7b..889087c 100644
--- a/utils/DList.cc
+++ b/utils/DList.cc
@@ -17,51 +17,50 @@
#include <stdlib.h>
#include <stdio.h>
-/*?class CcuDList
+/*?class IvlDList
\begin{figure}[hbtp]
\hfil
-\psfig{figure=FIGURES/CcuDList.epsf}\par \caption{Internal structure of \typ{CcuDList}s}
+\psfig{figure=FIGURES/IvlDList.epsf}\par \caption{Internal structure of \typ{IvlDList}s}
\hfil
\end{figure}
?*/
#ifdef CPLUS_BUG20
-class CcuDListLink {
-static CcuAllocator* DListLinkMem;
+class IvlDListLink {
+static IvlAllocator* DListLinkMem;
static void ClassInit ();
public:
- CcuDListItem* Entry;
- CcuDListLink* Previous;
- CcuDListLink* Next;
-inline CcuDListLink (CcuDListItem* e, CcuDListLink* p) : Entry (e), Previous (p), Next (p->Next) { Previous->Next = Next->Previous = this; }
-inline CcuDListLink (CcuDListItem* e) : Entry (e), Previous (this), Next (this) {}
+ IvlDListItem* Entry;
+ IvlDListLink* Previous;
+ IvlDListLink* Next;
+inline IvlDListLink (IvlDListItem* e, IvlDListLink* p) : Entry (e), Previous (p), Next (p->Next) { Previous->Next = Next->Previous = this; }
+inline IvlDListLink (IvlDListItem* e) : Entry (e), Previous (this), Next (this) {}
void* operator new (size_t);
void operator delete (void*);
};
#endif
-
#ifdef CPLUS_BUG20
-CcuAllocator* CcuDListLink::DListLinkMem = 0;
+IvlAllocator* IvlDListLink::DListLinkMem = 0;
#else
-CcuAllocator* CcuDList::CcuDListLink::DListLinkMem = 0;
+IvlAllocator* IvlDList::IvlDListLink::DListLinkMem = 0;
#endif
/*?nodoc?*/
void*
#ifdef CPLUS_BUG20
-CcuDListLink :: operator new (size_t)
+IvlDListLink :: operator new (size_t)
#else
-CcuDList::CcuDListLink :: operator new (size_t)
+IvlDList::IvlDListLink :: operator new (size_t)
#endif
{
if (!DListLinkMem)
#ifdef CPLUS_BUG20
- DListLinkMem = new CcuAllocator (sizeof (CcuDListLink));
+ DListLinkMem = new IvlAllocator (sizeof (IvlDListLink));
#else
- DListLinkMem = new CcuAllocator (sizeof (CcuDList::CcuDListLink));
+ DListLinkMem = new IvlAllocator (sizeof (IvlDList::IvlDListLink));
#endif
return DListLinkMem->Alloc ();
}
@@ -69,21 +68,19 @@ CcuDList::CcuDListLink :: operator new (size_t)
/*?nodoc?*/
void
#ifdef CPLUS_BUG20
-CcuDListLink :: operator delete (void* that)
+IvlDListLink :: operator delete (void* that)
#else
-CcuDList::CcuDListLink :: operator delete (void* that)
+IvlDList::IvlDListLink :: operator delete (void* that)
#endif
{
DListLinkMem->Free (that);
}
-
-
#ifdef DOC
/*?
Create an empty list.
?*/
-CcuDList :: CcuDList ()
+IvlDList :: IvlDList ()
{
}
#endif
@@ -91,27 +88,26 @@ CcuDList :: CcuDList ()
/*?
Create a list with one element \var{e}.
?*/
-CcuDList :: CcuDList (CcuDListItem* e)
-: LastLink (new CcuDListLink (e)),
+IvlDList :: IvlDList (IvlDListItem* e)
+: LastLink (new IvlDListLink (e)),
StatusFlag (NoError)
{
}
/*?nodoc?*/
-CcuDList :: CcuDList (const CcuDList& l)
+IvlDList :: IvlDList (const IvlDList& l)
: LastLink (0),
StatusFlag (NoError)
{
- CcuDListIter li (l);
+ IvlDListIter li (l);
while (++li)
Append (*li);
}
-
/*?
Destructor for lists. No operation is performed on the elements.
?*/
-CcuDList :: ~CcuDList ()
+IvlDList :: ~IvlDList ()
{
Clear ();
}
@@ -120,11 +116,11 @@ CcuDList :: ~CcuDList ()
Empty a list.
?*/
void
-CcuDList :: Clear ()
+IvlDList :: Clear ()
{
- CcuDListLink* del = LastLink;
+ IvlDListLink* del = LastLink;
while (del) {
- CcuDListLink* next = del->Next;
+ IvlDListLink* next = del->Next;
if (next == LastLink)
next = 0;
delete del;
@@ -134,22 +130,21 @@ CcuDList :: Clear ()
}
/*?nodoc?*/
-CcuDList&
-CcuDList :: operator = (const CcuDList& l)
+IvlDList&
+IvlDList :: operator = (const IvlDList& l)
{
if (this != &l) {
Clear ();
- CcuDListIter li (l);
+ IvlDListIter li (l);
while (++li)
Append (*li);
}
return *this;
}
-
/*?nextdoc?*/
-CcuDListItem*
-CcuDList :: First ()
+IvlDListItem*
+IvlDList :: First ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -164,8 +159,8 @@ Return the first (resp. last) element in the list, or 0 if the list was empty.
The case of a null element can be distinguished from the case
when the list is empty with the function \fun{GetStatus}.
?*/
-CcuDListItem*
-CcuDList :: Last ()
+IvlDListItem*
+IvlDList :: Last ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -180,13 +175,13 @@ Get the \var{n}-th element of a list. If \var{n} is greater than the length of t
this function returns 0 and sets the status to \var{TooFar}. If \var{n} is negative,
this function returns 0 but sets the status to \var{NoError}.
?*/
-CcuDListItem*
-CcuDList :: Nth (int n)
+IvlDListItem*
+IvlDList :: Nth (int n)
{
StatusFlag = NoError;
if (n <= 0)
return 0;
- CcuDListIter li (*this);
+ IvlDListIter li (*this);
while (n > 0 && ++li)
--n;
if (n != 0)
@@ -198,10 +193,10 @@ CcuDList :: Nth (int n)
Compute the number of elements in a list.
?*/
int
-CcuDList :: Length () const
+IvlDList :: Length () const
{
int result = 0;
- CcuDListIter li (*this);
+ IvlDListIter li (*this);
while (++li)
++result;
return result;
@@ -211,9 +206,9 @@ CcuDList :: Length () const
Check whether an item is present in a list.
?*/
int
-CcuDList :: Find (CcuDListItem* e) const
+IvlDList :: Find (IvlDListItem* e) const
{
- CcuDListIter li (*this);
+ IvlDListIter li (*this);
while (++li)
if (*li == e)
return 1;
@@ -222,31 +217,31 @@ CcuDList :: Find (CcuDListItem* e) const
/*?nextdoc?*/
void
-CcuDList :: Prepend (CcuDListItem* e)
+IvlDList :: Prepend (IvlDListItem* e)
{
if (LastLink)
- new CcuDListLink (e, LastLink);
+ new IvlDListLink (e, LastLink);
else
- LastLink = new CcuDListLink (e);
+ LastLink = new IvlDListLink (e);
}
/*?
Add an element at the beginning (resp. end) of a list.
?*/
void
-CcuDList :: Append (CcuDListItem* e)
+IvlDList :: Append (IvlDListItem* e)
{
if (LastLink) {
- LastLink = new CcuDListLink (e, LastLink);
+ LastLink = new IvlDListLink (e, LastLink);
} else
- LastLink = new CcuDListLink (e);
+ LastLink = new IvlDListLink (e);
}
/*?
Remove the first element of a list and return it.
?*/
-CcuDListItem*
-CcuDList :: RemoveFirst ()
+IvlDListItem*
+IvlDList :: RemoveFirst ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -258,13 +253,11 @@ CcuDList :: RemoveFirst ()
return RemoveLink (LastLink->Next);
}
-
-
/*?
Remove the last element of a list and return it.
?*/
-CcuDListItem*
-CcuDList :: RemoveLast ()
+IvlDListItem*
+IvlDList :: RemoveLast ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -276,14 +269,13 @@ CcuDList :: RemoveLast ()
return RemoveLink (LastLink);
}
-
/*?
Insert an element after the link \var{l}.
?*/
void
-CcuDList :: InsertAfterLink (CcuDListLink* l, CcuDListItem* e)
+IvlDList :: InsertAfterLink (IvlDListLink* l, IvlDListItem* e)
{
- CcuDListLink* newlink = new CcuDListLink (e, l);
+ IvlDListLink* newlink = new IvlDListLink (e, l);
if (LastLink == l)
LastLink = newlink;
}
@@ -291,11 +283,11 @@ CcuDList :: InsertAfterLink (CcuDListLink* l, CcuDListItem* e)
/*?
Remove a link.
?*/
-CcuDListItem*
-CcuDList :: RemoveLink (CcuDListLink* l)
+IvlDListItem*
+IvlDList :: RemoveLink (IvlDListLink* l)
{
/* store its data */
- CcuDListItem* data = l->Entry;
+ IvlDListItem* data = l->Entry;
if (l->Next == l)
LastLink = 0;
else {
@@ -310,17 +302,16 @@ CcuDList :: RemoveLink (CcuDListLink* l)
return data;
}
-
/*?
Remove an element from a list. This function iterates through the list until it deletes
\var{num} appearances of \var{entry}. The actual number of removals is returned.
If \var{num} is \var{All} or is negative, all appearances of \var{entry} are deleted.
?*/
int
-CcuDList :: Remove (CcuDListItem* entry, int num)
+IvlDList :: Remove (IvlDListItem* entry, int num)
{
int removed = 0;
- CcuDListIter li (*this);
+ IvlDListIter li (*this);
while ((num < 0 || removed < num) && ++li) {
if (*li == entry) {
RemoveLink (li.CurLink);
@@ -338,10 +329,10 @@ The actual number of removals is returned.
If \var{num} is \var{All} or is negative, all matching elements are deleted.
?*/
int
-CcuDList :: Remove (int (*p) (CcuDListItem*), int num)
+IvlDList :: Remove (int (*p) (IvlDListItem*), int num)
{
int removed = 0;
- CcuDListIter li (*this);
+ IvlDListIter li (*this);
while ((num < 0 || removed < num) && ++li) {
if ((*p) (*li)) {
RemoveAt (li);
@@ -353,20 +344,20 @@ CcuDList :: Remove (int (*p) (CcuDListItem*), int num)
/*?nextdoc?*/
void
-CcuDList :: InsertAfter (const CcuDListIter& li, CcuDListItem* e)
+IvlDList :: InsertAfter (const IvlDListIter& li, IvlDListItem* e)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
return;
}
if (!li.CurLink) {
- if (li.StatusFlag == CcuDListIter::StartOfList) {
+ if (li.StatusFlag == IvlDListIter::StartOfList) {
Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuDList::InsertAfter\n");
+ fprintf (stderr, "abnormal status in IvlDList::InsertAfter\n");
abort ();
}
- } else if (li.StatusFlag == CcuDListIter::EndOfList) {
+ } else if (li.StatusFlag == IvlDListIter::EndOfList) {
Append (e);
} else {
InsertAfterLink (li.CurLink, e);
@@ -375,28 +366,28 @@ CcuDList :: InsertAfter (const CcuDListIter& li, CcuDListItem* e)
/*?
Insert an element before (resp. after) the current position of the iterator \var{li}.
-These functions are both equivalent to \fun{CcuDList::Prepend} if the iterator is at the
+These functions are both equivalent to \fun{IvlDList::Prepend} if the iterator is at the
beginning of the list (ie. before the first element).
\fun{InsertAfter} and \fun{InsertAfter} are performed in a constant time.
?*/
void
-CcuDList :: InsertBefore (const CcuDListIter& li, CcuDListItem* e)
+IvlDList :: InsertBefore (const IvlDListIter& li, IvlDListItem* e)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
return;
}
if (!li.CurLink) {
- if (li.StatusFlag == CcuDListIter::StartOfList) {
+ if (li.StatusFlag == IvlDListIter::StartOfList) {
Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuDList::InsertAfter\n");
+ fprintf (stderr, "abnormal status in IvlDList::InsertAfter\n");
abort ();
}
- } else if (li.StatusFlag == CcuDListIter::EndOfList) {
+ } else if (li.StatusFlag == IvlDListIter::EndOfList) {
Append (e);
} else {
- new CcuDListLink (e, li.CurLink->Previous);
+ new IvlDListLink (e, li.CurLink->Previous);
}
}
@@ -407,8 +398,8 @@ If \var{li} points at the last element, the status flag is set to \var{TooFar}.
If the list is empty, the flag is set to \var{EmptyList}. In both cases, the
return value is null.
?*/
-CcuDListItem*
-CcuDList :: RemoveAfter (const CcuDListIter& li)
+IvlDListItem*
+IvlDList :: RemoveAfter (const IvlDListIter& li)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
@@ -433,14 +424,14 @@ its end, the return value is null, and the status flag is set to \var{TooEarly}
(resp. \var{TooFar}). In all other cases, \var{li} is rewinded by one step,
in order to allow such loops as:
\begin{ccode}
- CcuDListIter li (l);
+ IvlDListIter li (l);
while (++li)
if (do_remove (*li))
l.RemoveAt (l);
\end{ccode}
?*/
-CcuDListItem*
-CcuDList :: RemoveAt (CcuDListIter& li)
+IvlDListItem*
+IvlDList :: RemoveAt (IvlDListIter& li)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
@@ -450,20 +441,19 @@ CcuDList :: RemoveAt (CcuDListIter& li)
StatusFlag = TooEarly;
return 0;
}
- if (li.StatusFlag == CcuDListIter::EndOfList) {
+ if (li.StatusFlag == IvlDListIter::EndOfList) {
StatusFlag = TooFar;
return 0;
}
StatusFlag = NoError;
- CcuDListLink* del = li.CurLink;
+ IvlDListLink* del = li.CurLink;
--li;
return RemoveLink (del);
}
-
#ifdef DOC
-/*?class CcuDListIter
-The class \typ{CcuDListIter} allows iterations on lists.
+/*?class IvlDListIter
+The class \typ{IvlDListIter} allows iterations on lists.
Several iterators may be used at a time on the same list. It is dangerous to modify
a list that is being iterated.
?*/
@@ -472,7 +462,7 @@ a list that is being iterated.
Initialize an iterator associated to the list \var{l}. That iterator will point at the beginning
of the list, {\em before} the first element.
?*/
-CcuDListIter :: CcuDListIter (const CcuDList& l)
+IvlDListIter :: IvlDListIter (const IvlDList& l)
{
}
@@ -481,13 +471,13 @@ Get the status of an iterator. The status may be one of \var{Normal, StartOfList
\var{EndOfList}
?*/
dlistiter_status
-CcuDListIter :: GetStatus () const
+IvlDListIter :: GetStatus () const
{
}
/*?nextdoc?*/
void
-CcuDListIter :: Reset ()
+IvlDListIter :: Reset ()
{
}
@@ -495,19 +485,18 @@ CcuDListIter :: Reset ()
Reset an iterator to the beginning (resp. the end) of the list.
?*/
void
-CcuDListIter :: GotoEnd ()
+IvlDListIter :: GotoEnd ()
{
}
#endif /* DOC */
-
/*?
Get the current entry pointed by an iterator. This operator returns 0 if the iterator is
at the beginning or the end of the list. To distinguish those cases from the
case when the entry is null, you can use the method \fun{GetStatus}.
?*/
-CcuDListItem*
-CcuDListIter :: operator * () const
+IvlDListItem*
+IvlDListIter :: operator * () const
{
return (CurLink && StatusFlag == Normal) ? CurLink->Entry : 0;
}
@@ -517,17 +506,16 @@ CcuDListIter :: operator * () const
/*?
Check whether the status of an iterator is \var{Normal}.
?*/
-CcuDListIter :: operator int () const
+IvlDListIter :: operator int () const
{
}
#endif
-
/*?
Take one step of iteration.
?*/
-CcuDListIter&
-CcuDListIter :: operator ++ ()
+IvlDListIter&
+IvlDListIter :: operator ++ ()
{
/* This test covers all the cases :
- the iteration has already begun, and is at its end.
@@ -545,8 +533,8 @@ CcuDListIter :: operator ++ ()
/*?
Rewind iteration by one step.
?*/
-CcuDListIter&
-CcuDListIter :: operator -- ()
+IvlDListIter&
+IvlDListIter :: operator -- ()
{
if (StatusFlag == Normal) {
CurLink = CurLink->Previous;
@@ -565,7 +553,7 @@ If \var{e} is present in the list, the iterator will
be correctly positionned. If not, it will have reached the end of the list.
?*/
int
-CcuDListIter :: Find (CcuDListItem* e)
+IvlDListIter :: Find (IvlDListItem* e)
{
while (++(*this))
if (**this == e)
@@ -580,7 +568,7 @@ If \var{e} is present in the list, the iterator will
be correctly positionned. If not, it will have reached the end of the list.
?*/
int
-CcuDListIter :: FindBack (CcuDListItem* e)
+IvlDListIter :: FindBack (IvlDListItem* e)
{
while (--(*this))
if (**this == e)
@@ -590,137 +578,136 @@ CcuDListIter :: FindBack (CcuDListItem* e)
#ifdef DOC
-/*?class CcuDListOf
-The generic classes \typ{CcuDListOf} and \typ{CcuDListIterOf} are derived classes
-of \typ{CcuDList} and \typ{CcuDListIter} that provide lists of pointers to class objects.
+/*?class IvlDListOf
+The generic classes \typ{IvlDListOf} and \typ{IvlDListIterOf} are derived classes
+of \typ{IvlDList} and \typ{IvlDListIter} that provide lists of pointers to class objects.
When parameterized by the class \typ{ITEM}, the following functions are redefined:
?*/
/*?nextdoc?*/
-CcuDListOf :: CcuDListOf (ITEM* it)
+IvlDListOf :: IvlDListOf (ITEM* it)
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: First ()
+IvlDListOf :: First ()
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: Last ()
+IvlDListOf :: Last ()
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: Nth (int n)
+IvlDListOf :: Nth (int n)
{
}
/*?nextdoc?*/
int
-CcuDListOf :: Find (ITEM* it) const
+IvlDListOf :: Find (ITEM* it) const
{
}
/*?nextdoc?*/
void
-CcuDListOf :: Append (ITEM* it)
+IvlDListOf :: Append (ITEM* it)
{
}
/*?nextdoc?*/
void
-CcuDListOf :: Prepend (ITEM* it)
+IvlDListOf :: Prepend (ITEM* it)
{
}
/*?nextdoc?*/
-CcuDListOf&
-CcuDListOf :: operator << (ITEM* it)
+IvlDListOf&
+IvlDListOf :: operator << (ITEM* it)
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: RemoveFirst ()
+IvlDListOf :: RemoveFirst ()
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: RemoveLast ()
+IvlDListOf :: RemoveLast ()
{
}
/*?nextdoc?*/
int
-CcuDListOf :: Remove (ITEM* it, int nb = 1)
+IvlDListOf :: Remove (ITEM* it, int nb = 1)
{
}
/*?nextdoc?*/
int
-CcuDListOf :: Remove (int (*p) (ITEM*), int nb = 1)
+IvlDListOf :: Remove (int (*p) (ITEM*), int nb = 1)
{
}
/*?nextdoc?*/
void
-CcuDListOf :: InsertAfter (const CcuDListIterOf <ITEM>& li, ITEM*it)
+IvlDListOf :: InsertAfter (const IvlDListIterOf <ITEM>& li, ITEM*it)
{
}
/*?nextdoc?*/
void
-CcuDListOf :: InsertBefore (const CcuDListIterOf <ITEM>& li, ITEM* it)
+IvlDListOf :: InsertBefore (const IvlDListIterOf <ITEM>& li, ITEM* it)
{
}
/*?nextdoc?*/
ITEM*
-CcuDListOf :: RemoveAfter (const CcuDListIterOf <ITEM>& li)
+IvlDListOf :: RemoveAfter (const IvlDListIterOf <ITEM>& li)
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuDList},
+These functions are equivalent to their homonyms in the class \typ{IvlDList},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
ITEM*
-CcuDListOf :: RemoveAt (CcuDListIterOf <ITEM>& li)
+IvlDListOf :: RemoveAt (IvlDListIterOf <ITEM>& li)
{
}
/*?nextdoc?*/
-CcuDListIterOf :: CcuDListIterOf (const CcuDListOf <ITEM>& l)
+IvlDListIterOf :: IvlDListIterOf (const IvlDListOf <ITEM>& l)
{
}
/*?nextdoc?*/
ITEM*
-CcuDListIterOf :: operator * () const
+IvlDListIterOf :: operator * () const
{
}
/*?nextdoc?*/
int
-CcuDListIterOf :: Find (ITEM* it)
+IvlDListIterOf :: Find (ITEM* it)
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuDListIter},
+These functions are equivalent to their homonyms in the class \typ{IvlDListIter},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
int
-CcuDListIterOf :: FindBack (ITEM* it)
+IvlDListIterOf :: FindBack (ITEM* it)
{
}
-
#endif /* DOC */
diff --git a/utils/DList.h b/utils/DList.h
index cba72f1..8483db3 100644
--- a/utils/DList.h
+++ b/utils/DList.h
@@ -18,26 +18,26 @@
#include "cplus_bugs.h"
#include <sys/types.h>
-class CcuAllocator;
+class IvlAllocator;
-typedef void CcuDListItem;
+typedef void IvlDListItem;
#ifdef CPLUS_BUG20
-class CcuDListLink;
+class IvlDListLink;
#endif
-class CcuDList {
-friend class CcuDListIter;
+class IvlDList {
+friend class IvlDListIter;
#ifndef CPLUS_BUG20
- class CcuDListLink {
- static CcuAllocator* DListLinkMem;
+ class IvlDListLink {
+ static IvlAllocator* DListLinkMem;
public:
- CcuDListItem* Entry;
- CcuDListLink* Previous;
- CcuDListLink* Next;
- inline CcuDListLink (CcuDListItem* e, CcuDListLink* p) : Entry (e), Previous (p), Next (p->Next) { Previous->Next = Next->Previous = this; }
- inline CcuDListLink (CcuDListItem* e) : Entry (e), Previous (this), Next (this) {}
+ IvlDListItem* Entry;
+ IvlDListLink* Previous;
+ IvlDListLink* Next;
+ inline IvlDListLink (IvlDListItem* e, IvlDListLink* p) : Entry (e), Previous (p), Next (p->Next) { Previous->Next = Next->Previous = this; }
+ inline IvlDListLink (IvlDListItem* e) : Entry (e), Previous (this), Next (this) {}
void* operator new (size_t);
void operator delete (void*);
};
@@ -49,112 +49,110 @@ public:
private:
- CcuDListLink* LastLink;
+ IvlDListLink* LastLink;
dlist_status StatusFlag;
- void InsertAfterLink (CcuDListLink*, CcuDListItem*);
- CcuDListItem* RemoveLink (CcuDListLink*);
+ void InsertAfterLink (IvlDListLink*, IvlDListItem*);
+ IvlDListItem* RemoveLink (IvlDListLink*);
public:
-inline CcuDList () : LastLink (0), StatusFlag (NoError) { }
- CcuDList (CcuDListItem*);
- CcuDList (const CcuDList&);
- ~CcuDList ();
- CcuDList& operator = (const CcuDList&);
+inline IvlDList () : LastLink (0), StatusFlag (NoError) { }
+ IvlDList (IvlDListItem*);
+ IvlDList (const IvlDList&);
+ ~IvlDList ();
+ IvlDList& operator = (const IvlDList&);
inline dlist_status GetStatus () const { return StatusFlag; }
inline int IsEmpty () const { return !LastLink; }
- CcuDListItem* First ();
- CcuDListItem* Last ();
- CcuDListItem* Nth (int n);
+ IvlDListItem* First ();
+ IvlDListItem* Last ();
+ IvlDListItem* Nth (int n);
int Length () const;
- int Find (CcuDListItem*) const;
+ int Find (IvlDListItem*) const;
- void Append (CcuDListItem*);
- void Prepend (CcuDListItem*);
-inline CcuDList& operator << (CcuDListItem* it) { Append (it); return *this; }
+ void Append (IvlDListItem*);
+ void Prepend (IvlDListItem*);
+inline IvlDList& operator << (IvlDListItem* it) { Append (it); return *this; }
- CcuDListItem* RemoveFirst ();
- CcuDListItem* RemoveLast ();
- int Remove (CcuDListItem*, int = 1);
- int Remove (int (*) (CcuDListItem*), int = 1);
+ IvlDListItem* RemoveFirst ();
+ IvlDListItem* RemoveLast ();
+ int Remove (IvlDListItem*, int = 1);
+ int Remove (int (*) (IvlDListItem*), int = 1);
void Clear ();
- void InsertAfter (const CcuDListIter&, CcuDListItem*);
- void InsertBefore (const CcuDListIter&, CcuDListItem*);
- CcuDListItem* RemoveAfter (const CcuDListIter&);
- CcuDListItem* RemoveAt (CcuDListIter&);
+ void InsertAfter (const IvlDListIter&, IvlDListItem*);
+ void InsertBefore (const IvlDListIter&, IvlDListItem*);
+ IvlDListItem* RemoveAfter (const IvlDListIter&);
+ IvlDListItem* RemoveAt (IvlDListIter&);
};
-class CcuDListIter {
-friend class CcuDList;
+class IvlDListIter {
+friend class IvlDList;
public:
enum dlistiter_status { Normal, StartOfList, EndOfList };
private:
- const CcuDList* TheList;
+ const IvlDList* TheList;
#ifdef CPLUS_BUG20
- CcuDListLink* CurLink;
+ IvlDListLink* CurLink;
#else
- CcuDList::CcuDListLink* CurLink;
+ IvlDList::IvlDListLink* CurLink;
#endif
dlistiter_status StatusFlag;
public:
-inline CcuDListIter (const CcuDList& l) : TheList (&l), CurLink (0), StatusFlag (StartOfList) {}
+inline IvlDListIter (const IvlDList& l) : TheList (&l), CurLink (0), StatusFlag (StartOfList) {}
inline void Reset () { CurLink = 0; StatusFlag = StartOfList; }
inline void GotoEnd () { CurLink = TheList->LastLink; StatusFlag = CurLink ? EndOfList : StartOfList; }
-inline CcuDListIter& operator = (const CcuDList& l) { TheList = &l; CurLink = 0; StatusFlag = StartOfList; return *this; }
-inline CcuDListIter& operator = (const CcuDListIter& li) { TheList = li.TheList; CurLink = li.CurLink; StatusFlag = li.StatusFlag; return *this; }
- CcuDListIter& operator ++ ();
- CcuDListIter& operator -- ();
- int Find (CcuDListItem*);
- int FindBack (CcuDListItem*);
- CcuDListItem* operator * () const;
+inline IvlDListIter& operator = (const IvlDList& l) { TheList = &l; CurLink = 0; StatusFlag = StartOfList; return *this; }
+inline IvlDListIter& operator = (const IvlDListIter& li) { TheList = li.TheList; CurLink = li.CurLink; StatusFlag = li.StatusFlag; return *this; }
+ IvlDListIter& operator ++ ();
+ IvlDListIter& operator -- ();
+ int Find (IvlDListItem*);
+ int FindBack (IvlDListItem*);
+ IvlDListItem* operator * () const;
inline dlistiter_status GetStatus () const { return StatusFlag; }
inline operator int () const { return StatusFlag == Normal; }
};
-
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuDListIterOf;
+template <class ITEM> class IvlDListIterOf;
-template <class ITEM> class CcuDListOf : public CcuDList {
+template <class ITEM> class IvlDListOf : public IvlDList {
public:
-inline CcuDListOf () : CcuDList () {}
-inline CcuDListOf (ITEM* it) : CcuDList (it) {}
-inline ITEM* First () { return (ITEM*) (CcuDList::First ()); }
-inline ITEM* Last () { return (ITEM*) (CcuDList::Last ()); }
-inline ITEM* Nth (int n) { return (ITEM*) (CcuDList::Nth (n)); }
-inline int Find (ITEM* it) const { return CcuDList::Find (it); }
-
-inline void Append (ITEM* it) { CcuDList::Append (it); }
-inline void Prepend (ITEM* it) { CcuDList::Prepend (it); }
-inline CcuDListOf <ITEM>& operator << (ITEM* it) { CcuDList::Append (it); return *this; }
-
-inline ITEM* RemoveFirst () { return (ITEM*) (CcuDList::RemoveFirst ()); }
-inline ITEM* RemoveLast () { return (ITEM*) (CcuDList::RemoveLast ()); }
-inline int Remove (ITEM* it, int nb = 1) { return CcuDList::Remove (it, nb); }
-inline int Remove (int (*p) (ITEM*), int nb = 1) { return CcuDList::Remove ((int (*) (ITEM*)) p, nb); }
-
-inline void InsertAfter (const CcuDListIterOf <ITEM>& li, ITEM*it) { CcuDList::InsertAfter (li, it); }
-inline void InsertBefore (const CcuDListIterOf <ITEM>& li, ITEM* it) { CcuDList::InsertBefore (li, it); }
-inline ITEM* RemoveAfter (const CcuDListIterOf <ITEM>& li) { return (ITEM*) CcuDList::RemoveAfter (li); }
-inline ITEM* RemoveAt (CcuDListIterOf <ITEM>& li) { return (ITEM*) CcuDList::RemoveAfter (li); }
+inline IvlDListOf () : IvlDList () {}
+inline IvlDListOf (ITEM* it) : IvlDList (it) {}
+inline ITEM* First () { return (ITEM*) (IvlDList::First ()); }
+inline ITEM* Last () { return (ITEM*) (IvlDList::Last ()); }
+inline ITEM* Nth (int n) { return (ITEM*) (IvlDList::Nth (n)); }
+inline int Find (ITEM* it) const { return IvlDList::Find (it); }
+
+inline void Append (ITEM* it) { IvlDList::Append (it); }
+inline void Prepend (ITEM* it) { IvlDList::Prepend (it); }
+inline IvlDListOf <ITEM>& operator << (ITEM* it) { IvlDList::Append (it); return *this; }
+
+inline ITEM* RemoveFirst () { return (ITEM*) (IvlDList::RemoveFirst ()); }
+inline ITEM* RemoveLast () { return (ITEM*) (IvlDList::RemoveLast ()); }
+inline int Remove (ITEM* it, int nb = 1) { return IvlDList::Remove (it, nb); }
+inline int Remove (int (*p) (ITEM*), int nb = 1) { return IvlDList::Remove ((int (*) (ITEM*)) p, nb); }
+
+inline void InsertAfter (const IvlDListIterOf <ITEM>& li, ITEM*it) { IvlDList::InsertAfter (li, it); }
+inline void InsertBefore (const IvlDListIterOf <ITEM>& li, ITEM* it) { IvlDList::InsertBefore (li, it); }
+inline ITEM* RemoveAfter (const IvlDListIterOf <ITEM>& li) { return (ITEM*) IvlDList::RemoveAfter (li); }
+inline ITEM* RemoveAt (IvlDListIterOf <ITEM>& li) { return (ITEM*) IvlDList::RemoveAfter (li); }
};
-template <class ITEM> class CcuDListIterOf : public CcuDListIter {
+template <class ITEM> class IvlDListIterOf : public IvlDListIter {
public:
-inline CcuDListIterOf (const CcuDListOf <ITEM>& l) : CcuDListIter (l) { }
-inline CcuDListIterOf <ITEM>& operator = (const CcuDListOf <ITEM>& l) { return (CcuDListIterOf <ITEM>&) CcuDListIter::operator = (l); }
-inline CcuDListIterOf <ITEM>& operator = (const CcuDListIterOf <ITEM>& li) { return (CcuDListIterOf <ITEM>&) CcuDListIter::operator = (li); }
-inline ITEM* operator * () const { return (ITEM*) CcuDListIter::operator * (); }
-inline int Find (ITEM* it) { return CcuDListIter::Find (it); }
-inline int FindBack (ITEM* it) { return CcuDListIter::FindBack (it); }
+inline IvlDListIterOf (const IvlDListOf <ITEM>& l) : IvlDListIter (l) { }
+inline IvlDListIterOf <ITEM>& operator = (const IvlDListOf <ITEM>& l) { return (IvlDListIterOf <ITEM>&) IvlDListIter::operator = (l); }
+inline IvlDListIterOf <ITEM>& operator = (const IvlDListIterOf <ITEM>& li) { return (IvlDListIterOf <ITEM>&) IvlDListIter::operator = (li); }
+inline ITEM* operator * () const { return (ITEM*) IvlDListIter::operator * (); }
+inline int Find (ITEM* it) { return IvlDListIter::Find (it); }
+inline int FindBack (ITEM* it) { return IvlDListIter::FindBack (it); }
};
#endif /* CPLUS_BUG19 */
-
#endif /* DList_H_ */
diff --git a/utils/DirPath.cc b/utils/DirPath.cc
index 0536eb2..c8c3d3f 100644
--- a/utils/DirPath.cc
+++ b/utils/DirPath.cc
@@ -20,20 +20,19 @@
#include <unistd.h>
#include <stdarg.h>
-/*?class CcuDirPath
-\typ{CcuDirPath}s generalize the idea contained in the \com{PATH} environment variable
+/*?class IvlDirPath
+\typ{IvlDirPath}s generalize the idea contained in the \com{PATH} environment variable
of UNIX.
-A \typ{CcuDirPath} is a list of strings, which are thought of as directory names.
+A \typ{IvlDirPath} is a list of strings, which are thought of as directory names.
When looking for a file, each directory in the list is scanned, until the file is found or the
end of the list is reached.
?*/
-
/*?
Construct an empty directory path.
?*/
-CcuDirPath :: CcuDirPath ()
-: CcuList (),
+IvlDirPath :: IvlDirPath ()
+: IvlList (),
Alloc (DontAllocNames)
{
}
@@ -43,29 +42,29 @@ Construct an empty directory path.
The default allocation mode is set to \var{alloc} (see function \fun{FindFile}).
All other constructors initialize it to 0.
?*/
-CcuDirPath :: CcuDirPath (alloc_mode alloc)
-: CcuList (),
+IvlDirPath :: IvlDirPath (alloc_mode alloc)
+: IvlList (),
Alloc (alloc)
{
}
/*?
-Construct a \typ{CcuDirPath} which has one element \var{name}. The string \var{name}
+Construct a \typ{IvlDirPath} which has one element \var{name}. The string \var{name}
is copied.
?*/
-CcuDirPath :: CcuDirPath (const char* name)
-: CcuList (NewString (name)),
+IvlDirPath :: IvlDirPath (const char* name)
+: IvlList (NewString (name)),
Alloc (DontAllocNames)
{
}
/*?
-Construct a \typ{CcuDirPath} with two or more elements (\var{first}, \var{second},
+Construct a \typ{IvlDirPath} with two or more elements (\var{first}, \var{second},
and so on). All strings (\var{first} and the following ones) are copied.
{\bf The argument list must be null-terminated.}
?*/
-CcuDirPath :: CcuDirPath (const char* first, const char*, ...)
-: CcuList (),
+IvlDirPath :: IvlDirPath (const char* first, const char*, ...)
+: IvlList (),
Alloc (DontAllocNames)
{
@@ -83,18 +82,18 @@ CcuDirPath :: CcuDirPath (const char* first, const char*, ...)
}
/*?nodoc?*/
-CcuDirPath :: ~CcuDirPath ()
+IvlDirPath :: ~IvlDirPath ()
{
- CcuListIter li (*this);
+ IvlListIter li (*this);
while (++li)
FreeString ((char*) (*li));
}
/*?nextdoc?*/
void
-CcuDirPath :: Append (const char* dir)
+IvlDirPath :: Append (const char* dir)
{
- CcuList::Append (NewString (dir));
+ IvlList::Append (NewString (dir));
}
/*?
@@ -102,18 +101,18 @@ Append (resp. prepend) a directory name to a search path. A copy of the
string \var{dir} is created.
?*/
void
-CcuDirPath :: Prepend (const char* dir)
+IvlDirPath :: Prepend (const char* dir)
{
- CcuList::Prepend (NewString (dir));
+ IvlList::Prepend (NewString (dir));
}
/*?nodoc?*/
int
-CcuDirPath :: Remove (const char* d)
+IvlDirPath :: Remove (const char* d)
{
int removed = 0;
- CcuListIter li (*this);
- CcuListIter lj (*this);
+ IvlListIter li (*this);
+ IvlListIter lj (*this);
while (++li) {
int remove = (strcmp (d, (const char*) *li) == 0);
if (remove) {
@@ -138,7 +137,7 @@ A pathname is considered a full pathname (and hence is not looked up in
the search path) if it begins with ``\com{/}'', ``\com{./}'' or ``\com{../}''.
?*/
const char*
-CcuDirPath :: FindFile (const char* fn, alloc_mode alloc)
+IvlDirPath :: FindFile (const char* fn, alloc_mode alloc)
{
if (!fn)
return 0;
@@ -157,7 +156,7 @@ CcuDirPath :: FindFile (const char* fn, alloc_mode alloc)
/* Else, look through search path */
- CcuListIter it (*this) ;
+ IvlListIter it (*this) ;
while (++it) {
dir = (char*) (*it);
strcpy (absfn, dir);
@@ -177,11 +176,11 @@ CcuDirPath :: FindFile (const char* fn, alloc_mode alloc)
/*?
This function is similar to the previous one.
-It uses the allocation mode of this \typ{CcuDirPath} to decide whether to allocate
+It uses the allocation mode of this \typ{IvlDirPath} to decide whether to allocate
the returned string or not.
?*/
const char*
-CcuDirPath :: FindFile (const char* fn)
+IvlDirPath :: FindFile (const char* fn)
{
}
@@ -189,7 +188,7 @@ CcuDirPath :: FindFile (const char* fn)
Set the allocation mode of this dir path to \var{alloc}.
?*/
void
-CcuDirPath :: SetAlloc (alloc_mode alloc)
+IvlDirPath :: SetAlloc (alloc_mode alloc)
{
}
@@ -201,14 +200,14 @@ i.e. dir1:dir2:\ldots:dirN. \var{sep} is the character separating the different
Its default value is ``:''.
?*/
void
-CcuDirPath :: AppendEnvPath (const char* path, char sep)
+IvlDirPath :: AppendEnvPath (const char* path, char sep)
{
const char *dir, *next = path;
for (dir = path; next; dir = next+1) {
next = strchr (dir, sep);
if (next != dir)
- CcuList::Append (next ? NewString (dir, next-dir) : NewString (dir));
+ IvlList::Append (next ? NewString (dir, next-dir) : NewString (dir));
}
}
diff --git a/utils/DirPath.h b/utils/DirPath.h
index 3fe377e..538a4ff 100644
--- a/utils/DirPath.h
+++ b/utils/DirPath.h
@@ -13,24 +13,23 @@
* $CurLog$
*/
-
#ifndef DirPath_H_
#define DirPath_H_
#include "cplus_bugs.h"
#include "List.h"
-class CcuDirPath : public CcuList {
+class IvlDirPath : public IvlList {
public:
enum alloc_mode { DontAllocNames, DoAllocNames };
private:
alloc_mode Alloc;
public:
- CcuDirPath ();
- CcuDirPath (alloc_mode);
- CcuDirPath (const char*);
- CcuDirPath (const char*, const char*, ...);
- ~CcuDirPath ();
+ IvlDirPath ();
+ IvlDirPath (alloc_mode);
+ IvlDirPath (const char*);
+ IvlDirPath (const char*, const char*, ...);
+ ~IvlDirPath ();
void Append (const char*);
void Prepend (const char*);
void AppendEnvPath (const char*, char sep = ':');
diff --git a/utils/HashTable.cc b/utils/HashTable.cc
index 002efdd..59ac76d 100644
--- a/utils/HashTable.cc
+++ b/utils/HashTable.cc
@@ -22,15 +22,15 @@
#include <stdio.h>
#endif
-/*?class CcuHashTable
-The class \typ{CcuHashTable} implements association tables based on a hashing algorithm.
+/*?class IvlHashTable
+The class \typ{IvlHashTable} implements association tables based on a hashing algorithm.
Hash tables are useful to store information that needs to be retrieved
quickly, and which bears no efficient ordering. For instance, this is the
case for strings:
in a compiler, one may wish to maintain a hash table with identifiers
as hash keys and symbol table entries as information.
-A hash table is made of a set of hash entries (of class \typ{CcuHashCell}),
+A hash table is made of a set of hash entries (of class \typ{IvlHashCell}),
which can be modified during
the life of the table. An entry has two main fields: a hash key, and a user defined
information attached to that key. We will not give details about the structure of
@@ -40,13 +40,13 @@ here as a reminder.
The current implementation uses lists to store the synonyms so that entries can
be deleted efficiently.
-The class \typ{CcuHashTable} makes no assumption about the type of the keys, which it handles as
+The class \typ{IvlHashTable} makes no assumption about the type of the keys, which it handles as
\typ{const void *}.
The user can define several functions used when managing a hash table: the hash function, which
is determinant for the performances of the hash table, and the functions to copy, compare, and
destroy keys. Basic functions are provided by default.
-The following definitions are used by member functions of the class \typ{CcuHashTable},
+The following definitions are used by member functions of the class \typ{IvlHashTable},
and by them only:
\index{HASH_F}\index{HCP_F}\index{HCMP_F}\index{HENUM_F}\index{HDEL_F}
\begin{ccode}
@@ -59,35 +59,33 @@ and by them only:
?*/
-
-
-CcuAllocator* CcuHashCell::HashCellMem = 0;
+IvlAllocator* IvlHashCell::HashCellMem = 0;
/*?hidden?*/
void
-CcuHashCell :: ClassInit ()
+IvlHashCell :: ClassInit ()
{
if (!HashCellMem)
- HashCellMem = new CcuAllocator (sizeof (CcuHashCell));
+ HashCellMem = new IvlAllocator (sizeof (IvlHashCell));
}
/*?nodoc?*/
void*
-CcuHashCell :: operator new (size_t)
+IvlHashCell :: operator new (size_t)
{
return HashCellMem->Alloc ();
}
/*?nodoc?*/
void
-CcuHashCell :: operator delete (void* that)
+IvlHashCell :: operator delete (void* that)
{
HashCellMem->Free (that);
}
#if 0
unsigned int
-CcuHashTable :: HashPtr (const void* p, int max)
+IvlHashTable :: HashPtr (const void* p, int max)
{
/* stolen from Tcl */
/* this would be easier if max was a power of 2 */
@@ -96,13 +94,13 @@ CcuHashTable :: HashPtr (const void* p, int max)
#endif
/*?
-Constructor for \typ{CcuHashTable}s. Build a hash table based on an array of
+Constructor for \typ{IvlHashTable}s. Build a hash table based on an array of
size \var{size}.
You can optionally provide your own functions for copying, destroying
and comparing keys, and the hashing function. If no hashing function is
provided, the identity function is used.
?*/
-CcuHashTable :: CcuHashTable (unsigned int size, HASH_F hash_fun, HCP_F cp_fun, HDEL_F del_fun, HCMP_F cmp_fun)
+IvlHashTable :: IvlHashTable (unsigned int size, HASH_F hash_fun, HCP_F cp_fun, HDEL_F del_fun, HCMP_F cmp_fun)
: Size (size),
Hash (hash_fun),
Copy (cp_fun),
@@ -111,12 +109,12 @@ CcuHashTable :: CcuHashTable (unsigned int size, HASH_F hash_fun, HCP_F cp_fun,
{
if (Size <= 0)
Size = 1;
- Table = new CcuHashCell* [Size];
- memset (Table, 0, Size*sizeof (CcuHashCell*));
+ Table = new IvlHashCell* [Size];
+ memset (Table, 0, Size*sizeof (IvlHashCell*));
/* I know that HashCells can only be created from HashTables */
- if (!CcuHashCell::HashCellMem)
- CcuHashCell::ClassInit ();
+ if (!IvlHashCell::HashCellMem)
+ IvlHashCell::ClassInit ();
}
/*?
@@ -124,21 +122,21 @@ Copy constructor for hash tables. The table and the cells are copied. The keys a
copied only if \var{ht} had a copy function. The new hash table will contain the
same informations as \var{ht}, but the synonyms will not necessarily be in the same order.
?*/
-CcuHashTable :: CcuHashTable (const CcuHashTable& ht)
+IvlHashTable :: IvlHashTable (const IvlHashTable& ht)
: Size (ht.Size),
Hash (ht.Hash),
Copy (ht.Copy),
Delete (ht.Delete),
Compare (ht.Compare)
{
- Table = new CcuHashCell* [Size];
- register CcuHashCell** p = Table;
- register CcuHashCell** q = ht.Table;
+ Table = new IvlHashCell* [Size];
+ register IvlHashCell** p = Table;
+ register IvlHashCell** q = ht.Table;
while (p < Table + Size) {
*p = 0;
- register CcuHashCell* r = *q;
+ register IvlHashCell* r = *q;
while (r) {
- (*p) = new CcuHashCell (Copy ? (*Copy) (r->GetKey ()) : r->GetKey (), *p);
+ (*p) = new IvlHashCell (Copy ? (*Copy) (r->GetKey ()) : r->GetKey (), *p);
(*p)->SetInfo (r->Info);
r = r->Next;
}
@@ -150,7 +148,7 @@ CcuHashTable :: CcuHashTable (const CcuHashTable& ht)
/*?
Destructor for hash tables. All keys are destroyed if a destruction function was provided.
?*/
-CcuHashTable :: ~CcuHashTable ()
+IvlHashTable :: ~IvlHashTable ()
{
Clear ();
@@ -161,23 +159,22 @@ CcuHashTable :: ~CcuHashTable ()
#endif
}
-
/*?
Remove all data from the hash table. All keys are destroyed if a destruction function was provided.
?*/
void
-CcuHashTable :: Clear ()
+IvlHashTable :: Clear ()
{
/* destroy keys */
if (Delete) {
- CcuHashCellIter hi (*this);
+ IvlHashCellIter hi (*this);
while (++hi)
(*Delete) ((*hi)->Key);
}
/* destroy cells */
int s = Size;
- CcuHashCell** entry = Table;
+ IvlHashCell** entry = Table;
/* for each slot of the array ... */
for ( ; s--; ++entry ) {
@@ -185,8 +182,8 @@ CcuHashTable :: Clear ()
continue;
/* ... destroy all cells linked from that slot ...*/
- for (CcuHashCell* h = *entry; h;) {
- CcuHashCell* del = h;
+ for (IvlHashCell* h = *entry; h;) {
+ IvlHashCell* del = h;
h = h->Next;
delete del;
}
@@ -196,10 +193,9 @@ CcuHashTable :: Clear ()
}
}
-
/*?hidden?*/
-CcuHashCell**
-CcuHashTable :: HashKey (const void* key) const
+IvlHashCell**
+IvlHashTable :: HashKey (const void* key) const
{
register unsigned int h = (unsigned int) key;
@@ -213,10 +209,10 @@ CcuHashTable :: HashKey (const void* key) const
}
/*?hidden?*/
-CcuHashCell*
-CcuHashTable :: FindCell (CcuHashCell** entry, const void* key) const
+IvlHashCell*
+IvlHashTable :: FindCell (IvlHashCell** entry, const void* key) const
{
- CcuHashCell* h;
+ IvlHashCell* h;
for (h = *entry; h; h = h -> Next)
if (Compare ? (*Compare) (key, h->Key) : (key == h->Key))
break;
@@ -225,41 +221,40 @@ CcuHashTable :: FindCell (CcuHashCell** entry, const void* key) const
/*?hidden?*/
-CcuHashCell*
-CcuHashTable :: AddCell (CcuHashCell** entry, const void* key) const
+IvlHashCell*
+IvlHashTable :: AddCell (IvlHashCell** entry, const void* key) const
{
if (Copy)
key = (* Copy) (key);
- CcuHashCell* h = new CcuHashCell (key, *entry);
+ IvlHashCell* h = new IvlHashCell (key, *entry);
*entry = h;
return h;
}
-/*?class CcuHashCell
-\typ{CcuHashCell}s hold the entries of an hash table.
-A \typ{CcuHashCell} contains a key and a user defined information.
+/*?class IvlHashCell
+\typ{IvlHashCell}s hold the entries of an hash table.
+A \typ{IvlHashCell} contains a key and a user defined information.
?*/
-
#ifdef DOC
/*?hidden?*/
-CcuHashCellOf :: CcuHashCell (const void*, CcuHashCell*)
+IvlHashCellOf :: IvlHashCell (const void*, IvlHashCell*)
{
}
/*?nextdoc?*/
const void*
-CcuHashCell :: GetKey () const
+IvlHashCell :: GetKey () const
{
}
/*?
-Retrieve the key, or the information from a \typ{CcuHashCell}.
+Retrieve the key, or the information from a \typ{IvlHashCell}.
?*/
-CcuHashItem*
-CcuHashCell :: GetInfo () const
+IvlHashItem*
+IvlHashCell :: GetInfo () const
{
}
@@ -267,7 +262,7 @@ CcuHashCell :: GetInfo () const
Set the cell information to \var{p}.
?*/
void
-CcuHashCell :: SetInfo (CcuHashItem* p)
+IvlHashCell :: SetInfo (IvlHashItem* p)
{
}
@@ -281,12 +276,12 @@ function returns the address of the hash entry corresponding to the key.
\fun{Add} uses the hash function of the table.
If the key is new and a copy function was provided, the key is copied.
?*/
-CcuHashCell*
-CcuHashTable :: Add (const void* key, int* found)
+IvlHashCell*
+IvlHashTable :: Add (const void* key, int* found)
{
/* est-il dans la table ? */
- CcuHashCell** entry = HashKey (key);
- CcuHashCell* h = FindCell (entry, key);
+ IvlHashCell** entry = HashKey (key);
+ IvlHashCell* h = FindCell (entry, key);
if (found)
*found = (h != 0);
@@ -302,19 +297,19 @@ Retrieve the key \var{key} from the table. If it exists, return
the address of its hash entry, thus allowing to get its associated info. If the key
does not exist in the table, return 0.
?*/
-CcuHashCell*
-CcuHashTable :: Get (const void* key)
+IvlHashCell*
+IvlHashTable :: Get (const void* key)
{
- CcuHashCell **entry = HashKey (key);
+ IvlHashCell **entry = HashKey (key);
return FindCell (entry, key);
}
#if 0
-CcuHashItem*&
-CcuHashTable :: operator [] (const void* key)
+IvlHashItem*&
+IvlHashTable :: operator [] (const void* key)
{
- CcuHashCell **entry = HashKey (key);
- CcuHashCell *h = FindCell (entry, key);
+ IvlHashCell **entry = HashKey (key);
+ IvlHashCell *h = FindCell (entry, key);
if (!h)
h = AddCell (entry, key);
@@ -328,25 +323,24 @@ reference can be used for reading as for writing. If the key was not present
in the table, a new entry is created when writing, and a default (invalid) entry
is returned when reading.
?*/
-CcuHashCellRef
-CcuHashTable :: operator [] (const void* key) const
+IvlHashCellRef
+IvlHashTable :: operator [] (const void* key) const
{
- return CcuHashCellRef (*this, key);
+ return IvlHashCellRef (*this, key);
}
#endif
-
/*?
Remove the key \var{key} from the table. If it exists, return its
associated data. If the key does not exist, return 0. \var{found} may
be used to test whether the key was found.
?*/
-CcuHashItem*
-CcuHashTable :: Remove (const void* key, int* found)
+IvlHashItem*
+IvlHashTable :: Remove (const void* key, int* found)
{
- CcuHashCell **entry;
- register CcuHashCell *h, *hp = 0;
- CcuHashItem* info = 0;
+ IvlHashCell **entry;
+ register IvlHashCell *h, *hp = 0;
+ IvlHashItem* info = 0;
entry = HashKey (key);
@@ -372,32 +366,31 @@ CcuHashTable :: Remove (const void* key, int* found)
return info;
}
-
/*?
Change the size of the table, which is re-hashed.
?*/
void
-CcuHashTable :: Resize (int size)
+IvlHashTable :: Resize (int size)
{
int s = Size;
if (size <= 0)
size = 1;
Size = size;
- CcuHashCell** entry = Table;
- CcuHashCell** old_table = Table;
- Table = new CcuHashCell* [size];
- memset (Table, 0, size*sizeof (CcuHashCell*));
+ IvlHashCell** entry = Table;
+ IvlHashCell** old_table = Table;
+ Table = new IvlHashCell* [size];
+ memset (Table, 0, size*sizeof (IvlHashCell*));
/* rehash */
for (; s--; ++entry) {
/* scan the list */
- register CcuHashCell *cur, *next;
+ register IvlHashCell *cur, *next;
for (cur = *entry; cur; cur = next) {
next = cur->Next;
- register CcuHashCell** slot = HashKey (cur->Key);
+ register IvlHashCell** slot = HashKey (cur->Key);
/* prepend the cell to the corresponding list */
cur->Next = *slot;
@@ -411,14 +404,13 @@ CcuHashTable :: Resize (int size)
#endif
}
-
#ifdef TUNE
/*?nextdoc?*/
void
-CcuHashTable :: HashStats ()
+IvlHashTable :: HashStats ()
{
- CcuHashCell * h;
- CcuHashCell **entry;
+ IvlHashCell * h;
+ IvlHashCell **entry;
int s, coll = 0, empty = 0;
for (s = Size, entry = Table; s--; entry++) {
@@ -442,15 +434,15 @@ Print some statistics about this hash table on file descriptor \var{fd}
(default is stderr).
?*/
void
-CcuHashTable :: CollStats ()
+IvlHashTable :: CollStats ()
{
- CcuHashCell * h;
- CcuHashCell **entry;
+ IvlHashCell * h;
+ IvlHashCell **entry;
int s, lcoll, coll = 0, empty = 0;
int min = 999999, max = 0, moy = 0, moy2 = 0;
float fmoy, fvar;
- for (s = Size, entry = (CcuHashCell**) Table; s--; entry++) {
+ for (s = Size, entry = (IvlHashCell**) Table; s--; entry++) {
lcoll = 0;
if (h = *entry) {
while (h = h->Next) {
@@ -477,11 +469,11 @@ CcuHashTable :: CollStats ()
#endif /* TUNE */
-CcuHashItem*
-CcuHashCellRef :: operator = (CcuHashItem* info)
+IvlHashItem*
+IvlHashCellRef :: operator = (IvlHashItem* info)
{
- CcuHashCell **entry = Table.HashKey (Key);
- CcuHashCell *h = Table.FindCell (entry, Key);
+ IvlHashCell **entry = Table.HashKey (Key);
+ IvlHashCell *h = Table.FindCell (entry, Key);
if (!h)
h = Table.AddCell (entry, Key);
@@ -491,24 +483,23 @@ CcuHashCellRef :: operator = (CcuHashItem* info)
return info;
}
-CcuHashCellRef :: operator CcuHashItem* ()
+IvlHashCellRef :: operator IvlHashItem* ()
{
- CcuHashCell **entry = Table.HashKey (Key);
- CcuHashCell *h = Table.FindCell (entry, Key);
+ IvlHashCell **entry = Table.HashKey (Key);
+ IvlHashCell *h = Table.FindCell (entry, Key);
return h ? h->GetInfo () : 0;
}
-
-/*?class CcuDictionnary
+/*?class IvlDictionnary
For the common case when character strings are used as keys,
-the class \typ{CcuDictionnary} was derived from the class \typ{CcuHashTable}.
+the class \typ{IvlDictionnary} was derived from the class \typ{IvlHashTable}.
It is the class that should be used for dictionaries, symbol tables,~\ldots\,
For this special kind of hash tables, keys are compared as strings, and are copied with the
function \fun{NewString} (see page~\pageref{newstring}). If users do not provide a hash function,
a default one is used.
-All the functions of class \typ{CcuHashTable} are available in class \typ{CcuDictionnary}.
-\typ{CcuHashCellIter}s and \typ{CcuHashIter}s can be used on \typ{CcuDictionnary}s as well.
+All the functions of class \typ{IvlHashTable} are available in class \typ{IvlDictionnary}.
+\typ{IvlHashCellIter}s and \typ{IvlHashIter}s can be used on \typ{IvlDictionnary}s as well.
?*/
/*?
@@ -516,7 +507,7 @@ This function computes an integer key from a string. It is used by dictionaries
a hashing function, and is provided to users for a possible reuse.
?*/
unsigned int
-CcuDictionnary :: HashString (const void* key, int)
+IvlDictionnary :: HashString (const void* key, int)
{
register int h = 0;
register const char* p = (const char*) key;
@@ -531,7 +522,7 @@ CcuDictionnary :: HashString (const void* key, int)
/*?hidden?*/
int
-CcuDictionnary :: CompareString (const void* a, const void* b)
+IvlDictionnary :: CompareString (const void* a, const void* b)
{
register const char *p, *q;
/* on fait le strcmp a la main : ca va + vite */
@@ -543,36 +534,36 @@ CcuDictionnary :: CompareString (const void* a, const void* b)
/*?hidden?*/
void*
-CcuDictionnary :: CopyString (const void* k)
+IvlDictionnary :: CopyString (const void* k)
{
return NewString ((const char*) k);
}
/*?hidden?*/
void
-CcuDictionnary :: DeleteString (const void* k)
+IvlDictionnary :: DeleteString (const void* k)
{
FreeString ((char*) k);
}
/*?
-Constructor for \typ{CcuDictionnary}s. Initialize a \typ{CcuDictionnary} with an array of size \var{size},
+Constructor for \typ{IvlDictionnary}s. Initialize a \typ{IvlDictionnary} with an array of size \var{size},
and \var{hash\_fun} as the hash function. If \var{hash\_fun} is not provided, the default
function is used.
?*/
-CcuDictionnary :: CcuDictionnary (int size, HASH_F f)
-: CcuHashTable (size, (f ? f : HashString), (HCP_F) (CopyString), (HDEL_F) (DeleteString), (HCMP_F) (CompareString))
+IvlDictionnary :: IvlDictionnary (int size, HASH_F f)
+: IvlHashTable (size, (f ? f : HashString), (HCP_F) (CopyString), (HDEL_F) (DeleteString), (HCMP_F) (CompareString))
{
}
/*?nodoc?*/
-CcuDictionnary :: ~CcuDictionnary ()
+IvlDictionnary :: ~IvlDictionnary ()
{
}
/*?nodoc?*/
void
-CcuDictionnary :: KeyCopy (int flag)
+IvlDictionnary :: KeyCopy (int flag)
{
if (flag) {
Copy = (HCP_F) (&CopyString);
@@ -583,25 +574,25 @@ CcuDictionnary :: KeyCopy (int flag)
}
}
-/*?class CcuHashCellIter
-The class \typ{CcuHashCellIter} makes it possible to iterate through the entries of an hash table.
+/*?class IvlHashCellIter
+The class \typ{IvlHashCellIter} makes it possible to iterate through the entries of an hash table.
The order of iteration is not specified. These iterators yield pointers to cells, so that keys
-and entries are both accessible. To see only the entries, refer to the class \typ{CcuHashIter}.
+and entries are both accessible. To see only the entries, refer to the class \typ{IvlHashIter}.
?*/
#ifdef DOC
/*?
-Constructor for \typ{CcuHashCellIter}s. Initialize an iterator on the hash table \var{t}.
+Constructor for \typ{IvlHashCellIter}s. Initialize an iterator on the hash table \var{t}.
?*/
-CcuHashCellIter :: CcuHashCellIter (const CcuHashTable& t)
+IvlHashCellIter :: IvlHashCellIter (const IvlHashTable& t)
{
}
/*?
Get the current cell pointed by an iterator.
?*/
-CcuHashCell*
-CcuHashCellIter :: operator * () const
+IvlHashCell*
+IvlHashCellIter :: operator * () const
{
}
#endif
@@ -610,10 +601,10 @@ CcuHashCellIter :: operator * () const
Take one step of iteration. This operator returns a pointer on the next
hash entry of the table it is iterating on. When it is finished, it returns 0.
?*/
-CcuHashCellIter&
-CcuHashCellIter :: operator ++ ()
+IvlHashCellIter&
+IvlHashCellIter :: operator ++ ()
{
- register CcuHashCell* h = 0;
+ register IvlHashCell* h = 0;
register int size = TheTable.GetSize ();
@@ -629,10 +620,10 @@ CcuHashCellIter :: operator ++ ()
/*?
Post-increment equivalent of the previous operator.
?*/
-CcuHashCellIter
-CcuHashCellIter :: operator ++ (int)
+IvlHashCellIter
+IvlHashCellIter :: operator ++ (int)
{
- CcuHashCellIter result = *this;
+ IvlHashCellIter result = *this;
++(*this);
return result;
}
@@ -643,11 +634,11 @@ Get the status of an iterator. The status may be one of \var{Normal, StartOfTabl
\var{EndOfTable}
?*/
#ifndef CPLUS_BUG13
-CcuHashCellIter::hashiter_status
-CcuHashCellIter :: GetStatus () const
+IvlHashCellIter::hashiter_status
+IvlHashCellIter :: GetStatus () const
#else
hashiter_status
-CcuHashCellIter :: GetStatus () const
+IvlHashCellIter :: GetStatus () const
#endif
{
if (CurCell)
@@ -661,93 +652,93 @@ CcuHashCellIter :: GetStatus () const
/*?
Check whether the status of an iterator is \var{Normal}.
?*/
-CcuHashCellIter :: operator int () const
+IvlHashCellIter :: operator int () const
{
}
-/*?class CcuHashIter
-\typ{CcuHashIter}s are iterators that yield entries and not cells. They only differ
-from \typ{CcuHashCellIter}s by their operator \fun{*}.
+/*?class IvlHashIter
+\typ{IvlHashIter}s are iterators that yield entries and not cells. They only differ
+from \typ{IvlHashCellIter}s by their operator \fun{*}.
?*/
/*?
Get the current entry pointed by an iterator.
?*/
-CcuHashItem*
-CcuHashIter :: operator * () const
+IvlHashItem*
+IvlHashIter :: operator * () const
{
}
-/*?class CcuHashTableOf
-The generic classes \typ{CcuHashTableOf, CcuHashCellOf, CcuHashCellIterOf}
-and \typ{CcuHashIterOf} are derived classes of \typ{CcuHashTable, CcuHashCell, CcuHashCellIter}
-and \typ{CcuHashIter} that provide hash tables whose entries are
+/*?class IvlHashTableOf
+The generic classes \typ{IvlHashTableOf, IvlHashCellOf, IvlHashCellIterOf}
+and \typ{IvlHashIterOf} are derived classes of \typ{IvlHashTable, IvlHashCell, IvlHashCellIter}
+and \typ{IvlHashIter} that provide hash tables whose entries are
pointers to class objects.
When parameterized by the class \typ{ITEM}, the following functions are redefined:
?*/
/*?nextdoc?*/
-CcuHashCellOf<ITEM>*
-CcuHashTableOf :: Add (const void* key, int* found)
+IvlHashCellOf<ITEM>*
+IvlHashTableOf :: Add (const void* key, int* found)
{
}
/*?nextdoc?*/
-CcuHashCellOf<ITEM>*
-CcuHashTableOf :: Get (const void* key)
+IvlHashCellOf<ITEM>*
+IvlHashTableOf :: Get (const void* key)
{
}
/*?nextdoc?*/
ITEM*
-CcuHashTableOf :: Remove (const void* key, int* found)
+IvlHashTableOf :: Remove (const void* key, int* found)
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuHashTable},
+These functions are equivalent to their homonyms in the class \typ{IvlHashTable},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
-CcuHashCellRefOf<ITEM>
-CcuHashTableOf :: operator [] (const void* key) const
+IvlHashCellRefOf<ITEM>
+IvlHashTableOf :: operator [] (const void* key) const
{
}
/*?nextdoc?*/
void
-CcuHashCellOf :: SetInfo (ITEM* p)
+IvlHashCellOf :: SetInfo (ITEM* p)
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuHashCell},
+These functions are equivalent to their homonyms in the class \typ{IvlHashCell},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
ITEM*
-CcuHashCellOf :: GetInfo () const
+IvlHashCellOf :: GetInfo () const
{
}
/*?nextdoc?*/
-CcuHashIterOf :: CcuHashIterOf (const CcuHashTableOf<ITEM>& t)
+IvlHashIterOf :: IvlHashIterOf (const IvlHashTableOf<ITEM>& t)
{
}
/*?nextdoc?*/
-CcuHashIterOf<ITEM>&
-CcuHashIterOf :: operator ++ ()
+IvlHashIterOf<ITEM>&
+IvlHashIterOf :: operator ++ ()
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuHashIter},
+These functions are equivalent to their homonyms in the class \typ{IvlHashIter},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
ITEM*
-CcuHashIterOf :: operator * () const
+IvlHashIterOf :: operator * () const
{
}
diff --git a/utils/HashTable.h b/utils/HashTable.h
index 6cfda82..6586efe 100644
--- a/utils/HashTable.h
+++ b/utils/HashTable.h
@@ -17,86 +17,84 @@
#ifndef HashTable_H_
#define HashTable_H_
-
#include "cplus_bugs.h"
#include <sys/types.h>
-class CcuAllocator;
+class IvlAllocator;
-typedef void CcuHashItem;
+typedef void IvlHashItem;
-class CcuHashCell {
+class IvlHashCell {
protected:
-friend class CcuHashTable;
-friend class CcuHashCellIter;
-static CcuAllocator* HashCellMem;
+friend class IvlHashTable;
+friend class IvlHashCellIter;
+static IvlAllocator* HashCellMem;
static void ClassInit ();
const void* Key; /* hash key */
- CcuHashItem* Info; /* data */
- CcuHashCell* Next; /* synonyms */
+ IvlHashItem* Info; /* data */
+ IvlHashCell* Next; /* synonyms */
-inline CcuHashCell (const void* k, CcuHashCell* n) : Key (k), Info (0), Next (n) {}
+inline IvlHashCell (const void* k, IvlHashCell* n) : Key (k), Info (0), Next (n) {}
public:
-inline void SetInfo (CcuHashItem* p) { Info = p; }
-inline CcuHashItem* GetInfo () const { return Info; }
+inline void SetInfo (IvlHashItem* p) { Info = p; }
+inline IvlHashItem* GetInfo () const { return Info; }
inline const void* GetKey () const { return Key; }
void* operator new (size_t);
void operator delete (void*);
};
-class CcuHashCellRef {
-friend class CcuHashTable;
+class IvlHashCellRef {
+friend class IvlHashTable;
protected:
- const CcuHashTable& Table;
+ const IvlHashTable& Table;
const void* Key;
-inline CcuHashCellRef (const CcuHashTable& t, const void* key) : Table (t), Key (key) {}
+inline IvlHashCellRef (const IvlHashTable& t, const void* key) : Table (t), Key (key) {}
#ifdef CPLUS_BUG1
-inline CcuHashCellRef (const CcuHashCellRef& t) : Table (t.Table), Key (t.Key) {}
+inline IvlHashCellRef (const IvlHashCellRef& t) : Table (t.Table), Key (t.Key) {}
#endif
public:
- CcuHashItem* operator = (CcuHashItem*);
- operator CcuHashItem* ();
+ IvlHashItem* operator = (IvlHashItem*);
+ operator IvlHashItem* ();
};
-
typedef unsigned int (*HASH_F) (const void*, int);
typedef int (*HCMP_F) (const void*, const void*);
typedef void* (*HCP_F) (const void*);
typedef void (*HDEL_F) (const void*);
-class CcuHashTable {
+class IvlHashTable {
private:
-friend class CcuHashCellIter;
-friend class CcuHashCellRef;
+friend class IvlHashCellIter;
+friend class IvlHashCellRef;
protected :
- CcuHashCell** Table;
+ IvlHashCell** Table;
unsigned int Size;
HASH_F Hash;
HCP_F Copy;
HDEL_F Delete;
HCMP_F Compare;
- CcuHashCell** HashKey (const void*) const;
- CcuHashCell* FindCell (CcuHashCell**, const void*) const;
- CcuHashCell* AddCell (CcuHashCell**, const void*) const;
+ IvlHashCell** HashKey (const void*) const;
+ IvlHashCell* FindCell (IvlHashCell**, const void*) const;
+ IvlHashCell* AddCell (IvlHashCell**, const void*) const;
public:
static unsigned int HashPtr (const void*, int);
- CcuHashTable (unsigned int, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0);
- CcuHashTable (const CcuHashTable&);
- ~CcuHashTable ();
- CcuHashCell* Add (const void*, int* = 0);
- CcuHashCell* Get (const void*);
- CcuHashItem* Remove (const void*, int* = 0);
+ IvlHashTable (unsigned int, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0);
+ IvlHashTable (const IvlHashTable&);
+ ~IvlHashTable ();
+ IvlHashCell* Add (const void*, int* = 0);
+ IvlHashCell* Get (const void*);
+ IvlHashItem* Remove (const void*, int* = 0);
void Clear ();
void Resize (int);
inline int GetSize () const { return Size; }
- CcuHashCellRef operator [] (const void*) const;
+ IvlHashCellRef operator [] (const void*) const;
#ifdef TUNE
void HashStats ();
@@ -104,127 +102,124 @@ inline int GetSize () const { return Size; }
#endif
};
-class CcuDictionnary : public CcuHashTable {
+class IvlDictionnary : public IvlHashTable {
protected:
static void* CopyString (const void*);
static void DeleteString (const void*);
static int CompareString (const void*, const void*);
-
public:
- CcuDictionnary (int size, HASH_F = 0);
- ~CcuDictionnary ();
+ IvlDictionnary (int size, HASH_F = 0);
+ ~IvlDictionnary ();
void KeyCopy (int);
static unsigned int HashString (const void*, int);
};
-
-class CcuHashCellIter {
+class IvlHashCellIter {
public:
enum hashiter_status { Normal, StartOfTable, EndOfTable, BadTable };
protected:
- const CcuHashTable& TheTable;
+ const IvlHashTable& TheTable;
int CurIndex;
- CcuHashCell* CurCell;
+ IvlHashCell* CurCell;
public:
-inline CcuHashCellIter (const CcuHashTable& t) : TheTable (t) { CurIndex = -1; CurCell = 0; }
-inline ~CcuHashCellIter () {}
+inline IvlHashCellIter (const IvlHashTable& t) : TheTable (t) { CurIndex = -1; CurCell = 0; }
+inline ~IvlHashCellIter () {}
inline void Reset () { CurCell = 0; CurIndex = -1; }
- CcuHashCellIter& operator ++ ();
+ IvlHashCellIter& operator ++ ();
#ifndef CPLUS_BUG16
- CcuHashCellIter operator ++ (int);
+ IvlHashCellIter operator ++ (int);
#endif
-inline CcuHashCell* operator * () const { return CurCell; }
+inline IvlHashCell* operator * () const { return CurCell; }
hashiter_status GetStatus () const;
inline operator int () const { return CurCell != 0; }
};
-class CcuHashIter : public CcuHashCellIter {
+class IvlHashIter : public IvlHashCellIter {
public:
-inline CcuHashIter (const CcuHashTable& t) : CcuHashCellIter (t) { }
-inline ~CcuHashIter () {}
+inline IvlHashIter (const IvlHashTable& t) : IvlHashCellIter (t) { }
+inline ~IvlHashIter () {}
-inline CcuHashIter& operator ++ () { return (CcuHashIter&)(this->CcuHashCellIter::operator ++ ()); }
-inline CcuHashItem* operator * () const { return CurCell ? CurCell->GetInfo () : 0; }
+inline IvlHashIter& operator ++ () { return (IvlHashIter&)(this->IvlHashCellIter::operator ++ ()); }
+inline IvlHashItem* operator * () const { return CurCell ? CurCell->GetInfo () : 0; }
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuHashTableOf;
-template <class ITEM> class CcuDictionnaryOf;
+template <class ITEM> class IvlHashTableOf;
+template <class ITEM> class IvlDictionnaryOf;
-template <class ITEM> class CcuHashCellOf : public CcuHashCell {
+template <class ITEM> class IvlHashCellOf : public IvlHashCell {
protected:
-inline CcuHashCellOf (const void* k, CcuHashCellOf<ITEM>* n) : CcuHashCell (k, n) {}
+inline IvlHashCellOf (const void* k, IvlHashCellOf<ITEM>* n) : IvlHashCell (k, n) {}
public:
-inline void SetInfo (ITEM* p) { CcuHashCell::SetInfo (p); }
-inline ITEM* GetInfo () const { return (ITEM*) CcuHashCell::GetInfo (); }
+inline void SetInfo (ITEM* p) { IvlHashCell::SetInfo (p); }
+inline ITEM* GetInfo () const { return (ITEM*) IvlHashCell::GetInfo (); }
};
-template <class ITEM> class CcuHashCellRefOf : public CcuHashCellRef {
+template <class ITEM> class IvlHashCellRefOf : public IvlHashCellRef {
public:
-inline CcuHashCellRefOf (const CcuHashTableOf<ITEM>& t, const void* key) : CcuHashCellRef (t, key) {}
+inline IvlHashCellRefOf (const IvlHashTableOf<ITEM>& t, const void* key) : IvlHashCellRef (t, key) {}
#ifdef CPLUS_BUG1
-inline CcuHashCellRefOf (const CcuHashCellRefOf<ITEM>& t) : CcuHashCellRef (t) {}
+inline IvlHashCellRefOf (const IvlHashCellRefOf<ITEM>& t) : IvlHashCellRef (t) {}
#endif
-inline ITEM* operator = (ITEM* it) { return (ITEM*) (CcuHashCellRef::operator = (it)); }
-inline operator ITEM* () { return (ITEM*) (CcuHashCellRef::operator CcuHashItem* ()); }
+inline ITEM* operator = (ITEM* it) { return (ITEM*) (IvlHashCellRef::operator = (it)); }
+inline operator ITEM* () { return (ITEM*) (IvlHashCellRef::operator IvlHashItem* ()); }
};
-
-template <class ITEM> class CcuHashTableOf : public CcuHashTable {
+template <class ITEM> class IvlHashTableOf : public IvlHashTable {
public:
-inline CcuHashTableOf (unsigned int size, HASH_F hash = 0, HCP_F cp = 0, HDEL_F del = 0, HCMP_F cmp= 0) : CcuHashTable (size, hash, cp, del, cmp) {}
-inline ~CcuHashTableOf () {}
-inline CcuHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Add (key, found); }
-inline CcuHashCellOf<ITEM>* Get (const void* key) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Get (key); }
-inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuHashTable::Remove (key, found); }
-inline CcuHashCellRefOf<ITEM> operator [] (const void* key) const { return CcuHashCellRefOf<ITEM> (*this, key); }
+inline IvlHashTableOf (unsigned int size, HASH_F hash = 0, HCP_F cp = 0, HDEL_F del = 0, HCMP_F cmp= 0) : IvlHashTable (size, hash, cp, del, cmp) {}
+inline ~IvlHashTableOf () {}
+inline IvlHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Add (key, found); }
+inline IvlHashCellOf<ITEM>* Get (const void* key) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Get (key); }
+inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlHashTable::Remove (key, found); }
+inline IvlHashCellRefOf<ITEM> operator [] (const void* key) const { return IvlHashCellRefOf<ITEM> (*this, key); }
};
-template <class ITEM> class CcuDictionnaryOf : public CcuDictionnary {
+template <class ITEM> class IvlDictionnaryOf : public IvlDictionnary {
public:
-inline CcuDictionnaryOf (unsigned int size, HASH_F hash = 0) : CcuDictionnary (size, hash) {}
-inline ~CcuDictionnaryOf () {}
-inline CcuHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuDictionnary::Add (key, found); }
-inline CcuHashCellOf<ITEM>* Get (const void* key) { return (CcuHashCellOf<ITEM>*) CcuDictionnary::Get (key); }
-inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuDictionnary::Remove (key, found); }
-inline operator const CcuHashTableOf<ITEM>& () const { return *(const CcuHashTableOf<ITEM>*) this; }
-inline CcuHashCellRefOf<ITEM> operator [] (const char* key) const { return CcuHashCellRefOf<ITEM> (*(const CcuHashTableOf<ITEM>*)this, key); }
+inline IvlDictionnaryOf (unsigned int size, HASH_F hash = 0) : IvlDictionnary (size, hash) {}
+inline ~IvlDictionnaryOf () {}
+inline IvlHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlDictionnary::Add (key, found); }
+inline IvlHashCellOf<ITEM>* Get (const void* key) { return (IvlHashCellOf<ITEM>*) IvlDictionnary::Get (key); }
+inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlDictionnary::Remove (key, found); }
+inline operator const IvlHashTableOf<ITEM>& () const { return *(const IvlHashTableOf<ITEM>*) this; }
+inline IvlHashCellRefOf<ITEM> operator [] (const char* key) const { return IvlHashCellRefOf<ITEM> (*(const IvlHashTableOf<ITEM>*)this, key); }
};
-template <class ITEM> class CcuHashedArrayOf : public CcuHashTable {
+template <class ITEM> class IvlHashedArrayOf : public IvlHashTable {
public:
-inline CcuHashedArrayOf (unsigned int size, HASH_F hash = 0) : CcuHashTable (size, hash) {}
-inline ~CcuHashedArrayOf () {}
-inline CcuHashCellOf<ITEM>* Add (int key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Add ((void*)key, found); }
-inline CcuHashCellOf<ITEM>* Get (int key) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Get ((void*)key); }
-inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) CcuHashTable::Remove ((void*) key, found); }
-inline operator const CcuHashTableOf<ITEM>& () const { return *(const CcuHashTableOf<ITEM>*) this; }
-inline CcuHashCellRefOf<ITEM> operator [] (int key) const { return CcuHashCellRefOf<ITEM> (*(const CcuHashTableOf<ITEM>*)this, (void*)key); }
+inline IvlHashedArrayOf (unsigned int size, HASH_F hash = 0) : IvlHashTable (size, hash) {}
+inline ~IvlHashedArrayOf () {}
+inline IvlHashCellOf<ITEM>* Add (int key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Add ((void*)key, found); }
+inline IvlHashCellOf<ITEM>* Get (int key) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Get ((void*)key); }
+inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) IvlHashTable::Remove ((void*) key, found); }
+inline operator const IvlHashTableOf<ITEM>& () const { return *(const IvlHashTableOf<ITEM>*) this; }
+inline IvlHashCellRefOf<ITEM> operator [] (int key) const { return IvlHashCellRefOf<ITEM> (*(const IvlHashTableOf<ITEM>*)this, (void*)key); }
};
-template <class ITEM> class CcuHashIterOf : public CcuHashIter {
+template <class ITEM> class IvlHashIterOf : public IvlHashIter {
public:
-inline CcuHashIterOf (const CcuHashTableOf<ITEM>& t) : CcuHashIter (t) { }
-inline ~CcuHashIterOf () {}
-inline CcuHashIterOf<ITEM>& operator ++ () { return (CcuHashIterOf<ITEM>&)(this->CcuHashIter::operator ++ ()); }
-inline ITEM* operator * () const { return (ITEM*) (CcuHashIter::operator * ()); }
+inline IvlHashIterOf (const IvlHashTableOf<ITEM>& t) : IvlHashIter (t) { }
+inline ~IvlHashIterOf () {}
+inline IvlHashIterOf<ITEM>& operator ++ () { return (IvlHashIterOf<ITEM>&)(this->IvlHashIter::operator ++ ()); }
+inline ITEM* operator * () const { return (ITEM*) (IvlHashIter::operator * ()); }
};
-template <class ITEM> class CcuHashCellIterOf : public CcuHashCellIter {
+template <class ITEM> class IvlHashCellIterOf : public IvlHashCellIter {
public:
-inline CcuHashCellIterOf (const CcuHashTableOf<ITEM>& t) : CcuHashCellIter (t) { }
-inline ~CcuHashCellIterOf () {}
-inline CcuHashCellIterOf<ITEM>& operator ++ () { return (CcuHashCellIterOf<ITEM>&)(this->CcuHashCellIter::operator ++ ()); }
+inline IvlHashCellIterOf (const IvlHashTableOf<ITEM>& t) : IvlHashCellIter (t) { }
+inline ~IvlHashCellIterOf () {}
+inline IvlHashCellIterOf<ITEM>& operator ++ () { return (IvlHashCellIterOf<ITEM>&)(this->IvlHashCellIter::operator ++ ()); }
#ifndef CPLUS_BUG16
-inline CcuHashCellIterOf<ITEM> operator ++ (int i) { return *(CcuHashCellIterOf<ITEM>*)&(this->CcuHashCellIter::operator ++ (i)); }
+inline IvlHashCellIterOf<ITEM> operator ++ (int i) { return *(IvlHashCellIterOf<ITEM>*)&(this->IvlHashCellIter::operator ++ (i)); }
#endif
-inline CcuHashCellOf<ITEM>* operator * () const { return (CcuHashCellOf<ITEM>*) (CcuHashCellIter::operator * ()); }
+inline IvlHashCellOf<ITEM>* operator * () const { return (IvlHashCellOf<ITEM>*) (IvlHashCellIter::operator * ()); }
};
#endif /* CPLUS_BUG19 */
diff --git a/utils/IdTable.cc b/utils/IdTable.cc
index 193973c..5bc461f 100644
--- a/utils/IdTable.cc
+++ b/utils/IdTable.cc
@@ -16,8 +16,8 @@
#include "IdTable.h"
#include <memory.h>
-/*?class CcuIdTable
-A \typ{CcuIdTable} stores pointers in a table, and assigns them a unique identifier.
+/*?class IvlIdTable
+A \typ{IvlIdTable} stores pointers in a table, and assigns them a unique identifier.
Objects can be added, removed and retrieved in constant time (roughly, an index and a test).
This makes this class very useful for distributed applications that usually need
to communicate object identifiers instead of object pointers. In such applications,
@@ -59,15 +59,14 @@ This is far less expensive than rehashing a hash table for instance.
#define TID_SHIFT 16
#define TID_MASK 0xffff
-
-struct CcuIdCell {
+struct IvlIdCell {
sword Check; // the check number
- CcuIdType Type; // for the appli, for free list when not allocated
- CcuIdItem* Info;
+ IvlIdType Type; // for the appli, for free list when not allocated
+ IvlIdItem* Info;
-inline CcuID ComputeId (const CcuIdTable* t)
+inline IvlID ComputeId (const IvlIdTable* t)
{
- return (CcuID) ((Check << TID_SHIFT) | (this - t->Entries));
+ return (IvlID) ((Check << TID_SHIFT) | (this - t->Entries));
}
};
@@ -75,7 +74,7 @@ inline CcuID ComputeId (const CcuIdTable* t)
Build an ident table with $2^sz$ entries.
The table grows automatically (by a factor of 2) until 32768 entries (the maximum).
?*/
-CcuIdTable :: CcuIdTable (int sz)
+IvlIdTable :: IvlIdTable (int sz)
{
if (sz > TID_MAX)
sz = TID_MAX;
@@ -83,13 +82,13 @@ CcuIdTable :: CcuIdTable (int sz)
sz = 0;
int nb = 2 << sz;
- Entries = new CcuIdCell [nb];
- memset (Entries, 0, nb * sizeof (CcuIdCell));
+ Entries = new IvlIdCell [nb];
+ memset (Entries, 0, nb * sizeof (IvlIdCell));
LastCell = Entries + nb;
// link free entries with the 'Type' field
int i = 0;
- CcuIdCell* p;
+ IvlIdCell* p;
for (p = Entries; p < LastCell; p++)
p->Type = ++i;
@@ -101,7 +100,7 @@ CcuIdTable :: CcuIdTable (int sz)
/*?hidden?*/
bool
-CcuIdTable :: Grow (int newNb)
+IvlIdTable :: Grow (int newNb)
{
int nb = LastCell - Entries;
if (nb >= TID_MAX)
@@ -110,10 +109,10 @@ CcuIdTable :: Grow (int newNb)
if (newNb >= TID_MAX)
newNb = TID_MAX;
- CcuIdCell* newTbl = new CcuIdCell [newNb];
- int size = nb * sizeof (CcuIdCell);
+ IvlIdCell* newTbl = new IvlIdCell [newNb];
+ int size = nb * sizeof (IvlIdCell);
memcpy (newTbl, Entries, size);
- memset (newTbl + nb, 0, newNb * sizeof (CcuIdCell) - size);
+ memset (newTbl + nb, 0, newNb * sizeof (IvlIdCell) - size);
#ifdef CPLUS_BUG4
delete [nb] Entries;
#else
@@ -124,7 +123,7 @@ CcuIdTable :: Grow (int newNb)
// link free entries with the 'Type' field
int i = nb;
- CcuIdCell* p;
+ IvlIdCell* p;
for (p = Entries + nb; p < LastCell; p++)
p->Type = ++i;
// prepend to current free list (to use them first)
@@ -143,14 +142,14 @@ If the table is full, return 0 (0 cannot be a valid identifier).
It can be used to store the type of the object.
\var{obj} cannot be 0.
?*/
-CcuID
-CcuIdTable :: Store (CcuIdItem* obj, CcuIdType typ)
+IvlID
+IvlIdTable :: Store (IvlIdItem* obj, IvlIdType typ)
{
if (NumFree == 0)
if (! Grow ((LastCell - Entries) * 2))
return 0;
// get entry out of free list
- register CcuIdCell* p = Entries + FirstFree;
+ register IvlIdCell* p = Entries + FirstFree;
FirstFree = p->Type;
--NumFree;
@@ -165,15 +164,15 @@ CcuIdTable :: Store (CcuIdItem* obj, CcuIdType typ)
Remove object with identifier \var{id} from table.
Return false if it was not found.
?*/
-CcuIdItem*
-CcuIdTable :: Remove (CcuID id, bool* found, CcuIdType* type)
+IvlIdItem*
+IvlIdTable :: Remove (IvlID id, bool* found, IvlIdType* type)
{
- register CcuIdIndex i = CcuIdIndex (id & TID_MASK);
- register CcuIdCell* p = Entries + i;
+ register IvlIdIndex i = IvlIdIndex (id & TID_MASK);
+ register IvlIdCell* p = Entries + i;
- CcuIdType ret_type;
+ IvlIdType ret_type;
bool ret_found;
- CcuIdItem* ret_value;
+ IvlIdItem* ret_value;
if (p->Check != id >> TID_SHIFT) {
ret_type = 0;
@@ -187,7 +186,7 @@ CcuIdTable :: Remove (CcuID id, bool* found, CcuIdType* type)
p->Info = 0; // mark as free
p->Check = 0; // mark as free
if (NumFree > 0)
- Entries [LastFree].Type = (CcuIdType) i;
+ Entries [LastFree].Type = (IvlIdType) i;
else
FirstFree = i;
LastFree = i;
@@ -205,10 +204,10 @@ Retrieve object with identifier \var{id} from table.
Return the object pointer, or 0 if it was not found.
if \var{typ} is not 0, it is filled with the type of the object.
?*/
-CcuIdItem*
-CcuIdTable :: Get (CcuID id, CcuIdType* typ)
+IvlIdItem*
+IvlIdTable :: Get (IvlID id, IvlIdType* typ)
{
- register CcuIdCell* p;
+ register IvlIdCell* p;
p = Entries + (id & TID_MASK);
if (p->Check != id >> TID_SHIFT)
@@ -226,9 +225,9 @@ This makes it possible to store entries in the table with identifiers allocated
elsewhere, for instance to maintain a local copy of a remote table.
?*/
void
-CcuIdTable :: Change (CcuID id, CcuIdItem* obj, CcuIdType typ)
+IvlIdTable :: Change (IvlID id, IvlIdItem* obj, IvlIdType typ)
{
- register CcuIdCell* p;
+ register IvlIdCell* p;
p = Entries + (id & TID_MASK);
int ip = p - Entries;
@@ -263,15 +262,15 @@ CcuIdTable :: Change (CcuID id, CcuIdItem* obj, CcuIdType typ)
p->Info = obj;
}
-/*?class CcuIdIter
-The class \typ{CcuIdIter} is an iterator over \typ{CcuIdTable}.
+/*?class IvlIdIter
+The class \typ{IvlIdIter} is an iterator over \typ{IvlIdTable}.
?*/
#ifdef DOC
/*?
Build an iterator over the table \var{t}.
?*/
-CcuIdIter :: CcuIdIter (CcuIdTable& t)
+IvlIdIter :: IvlIdIter (IvlIdTable& t)
{
}
@@ -279,17 +278,16 @@ CcuIdIter :: CcuIdIter (CcuIdTable& t)
Reset the iterator to enumerate the whole table again.
?*/
void
-CcuIdIter :: Reset ()
+IvlIdIter :: Reset ()
{
}
#endif /* DOC */
-
/*?
Advance the iterator to the next entry.
?*/
-CcuIdIter&
-CcuIdIter :: operator ++ ()
+IvlIdIter&
+IvlIdIter :: operator ++ ()
{
if (! CurCell)
return *this;
@@ -313,15 +311,15 @@ CcuIdIter :: operator ++ ()
}
/*?nextdoc?*/
-CcuIdItem*
-CcuIdIter :: Current () const
+IvlIdItem*
+IvlIdIter :: Current () const
{
return (CurCell && StatusFlag == Normal) ? CurCell->Info : 0;
}
/*?nextdoc?*/
-CcuIdType
-CcuIdIter :: CurType () const
+IvlIdType
+IvlIdIter :: CurType () const
{
return (CurCell && StatusFlag == Normal) ? CurCell->Type : 0;
}
@@ -331,8 +329,8 @@ Return the information of the current entry:
its associated data, its type, and its ident.
If the iterator is finished, these functions return 0.
?*/
-CcuID
-CcuIdIter :: CurId () const
+IvlID
+IvlIdIter :: CurId () const
{
return (CurCell && StatusFlag == Normal) ? CurCell->ComputeId (TheTable) : 0;
}
diff --git a/utils/IdTable.h b/utils/IdTable.h
index e062ce2..aec3424 100644
--- a/utils/IdTable.h
+++ b/utils/IdTable.h
@@ -20,79 +20,77 @@
#include "word.h"
#include "bool.h"
-typedef void CcuIdItem;
-typedef lword CcuID;
-typedef sword CcuIdType;
-typedef sword CcuIdIndex;
+typedef void IvlIdItem;
+typedef lword IvlID;
+typedef sword IvlIdType;
+typedef sword IvlIdIndex;
-class CcuIdTable {
-friend class CcuIdIter;
-friend class CcuIdCell;
+class IvlIdTable {
+friend class IvlIdIter;
+friend class IvlIdCell;
protected:
- CcuIdCell* Entries; // the table itself
- CcuIdCell* LastCell; // its end
- CcuIdIndex FirstFree; // index of first free entry
- CcuIdIndex LastFree; // index of end of free list
+ IvlIdCell* Entries; // the table itself
+ IvlIdCell* LastCell; // its end
+ IvlIdIndex FirstFree; // index of first free entry
+ IvlIdIndex LastFree; // index of end of free list
short NumFree; // number of free Entries
bool Grow (int);
public:
- CcuIdTable (int); // initial size should be power of 2
+ IvlIdTable (int); // initial size should be power of 2
- CcuID Store (CcuIdItem*, CcuIdType = 0);
- CcuIdItem* Get (CcuID, CcuIdType* = 0);
- CcuIdItem* Remove (CcuID, bool* = 0, CcuIdType* = 0);
- void Change (CcuID, CcuIdItem*, CcuIdType = 0);
+ IvlID Store (IvlIdItem*, IvlIdType = 0);
+ IvlIdItem* Get (IvlID, IvlIdType* = 0);
+ IvlIdItem* Remove (IvlID, bool* = 0, IvlIdType* = 0);
+ void Change (IvlID, IvlIdItem*, IvlIdType = 0);
};
-class CcuIdIter {
+class IvlIdIter {
public:
enum iditer_status { Normal, StartOfTable, EndOfTable };
protected:
- const CcuIdTable* TheTable;
+ const IvlIdTable* TheTable;
iditer_status StatusFlag;
- CcuIdCell* Entries;
- CcuIdCell* CurCell;
+ IvlIdCell* Entries;
+ IvlIdCell* CurCell;
public:
-inline CcuIdIter (const CcuIdTable& t) : TheTable (&t), StatusFlag (StartOfTable) { CurCell = Entries = t.Entries; }
+inline IvlIdIter (const IvlIdTable& t) : TheTable (&t), StatusFlag (StartOfTable) { CurCell = Entries = t.Entries; }
inline void Reset () { CurCell = Entries = TheTable->Entries; StatusFlag = StartOfTable; }
-inline CcuIdIter& operator = (const CcuIdTable& t) { TheTable = &t; StatusFlag = StartOfTable; CurCell = Entries = t.Entries; return *this; }
-inline CcuIdIter& operator = (const CcuIdIter& it) { TheTable = it.TheTable; StatusFlag = it.StatusFlag; CurCell = it.CurCell; Entries = it.Entries; return *this; }
+inline IvlIdIter& operator = (const IvlIdTable& t) { TheTable = &t; StatusFlag = StartOfTable; CurCell = Entries = t.Entries; return *this; }
+inline IvlIdIter& operator = (const IvlIdIter& it) { TheTable = it.TheTable; StatusFlag = it.StatusFlag; CurCell = it.CurCell; Entries = it.Entries; return *this; }
- CcuIdIter& operator ++ ();
- CcuIdItem* Current () const;
-inline CcuIdItem* operator * () const { return Current (); }
+ IvlIdIter& operator ++ ();
+ IvlIdItem* Current () const;
+inline IvlIdItem* operator * () const { return Current (); }
inline operator int () const { return StatusFlag == Normal; }
- CcuIdType CurType () const;
- CcuID CurId () const;
+ IvlIdType CurType () const;
+ IvlID CurId () const;
};
-template <class ITEM> class CcuIdTableOf : public CcuIdTable {
+template <class ITEM> class IvlIdTableOf : public IvlIdTable {
public:
-inline CcuIdTableOf (int sz) : CcuIdTable (sz) {}
+inline IvlIdTableOf (int sz) : IvlIdTable (sz) {}
-inline CcuID Store (ITEM* it, CcuIdType typ = 0) { return CcuIdTable::Store (it, typ); }
-inline ITEM* Get (CcuID id, CcuIdType* typ = 0) { return (ITEM*) CcuIdTable::Get (id, typ); }
-inline ITEM* Remove (CcuID id, bool* f = 0, CcuIdType* t = 0) { return (ITEM*) CcuIdTable::Remove (id, f, t); }
-inline void Change (CcuID id, ITEM* i, CcuIdType t = 0) { CcuIdTable::Change (id, i, t); }
+inline IvlID Store (ITEM* it, IvlIdType typ = 0) { return IvlIdTable::Store (it, typ); }
+inline ITEM* Get (IvlID id, IvlIdType* typ = 0) { return (ITEM*) IvlIdTable::Get (id, typ); }
+inline ITEM* Remove (IvlID id, bool* f = 0, IvlIdType* t = 0) { return (ITEM*) IvlIdTable::Remove (id, f, t); }
+inline void Change (IvlID id, ITEM* i, IvlIdType t = 0) { IvlIdTable::Change (id, i, t); }
};
-template <class ITEM> class CcuIdIterOf : public CcuIdIter {
+template <class ITEM> class IvlIdIterOf : public IvlIdIter {
public:
-inline CcuIdIterOf (CcuIdTableOf <ITEM> & t) : CcuIdIter (t) { }
-inline CcuIdIterOf<ITEM>& operator = (const CcuIdTableOf <ITEM>& t) { return (CcuIdIterOf<ITEM>&) CcuIdIter::operator = (t); }
-inline CcuIdIterOf<ITEM>& operator = (const CcuIdIterOf<ITEM>& li) { return (CcuIdIterOf<ITEM>&) CcuIdIter::operator = (li); }
-inline CcuIdIterOf<ITEM>& operator ++ () { return (CcuIdIterOf<ITEM>&) CcuIdIter::operator ++ (); }
-inline ITEM* Current () const { return (ITEM*) CcuIdIter::Current (); }
+inline IvlIdIterOf (IvlIdTableOf <ITEM> & t) : IvlIdIter (t) { }
+inline IvlIdIterOf<ITEM>& operator = (const IvlIdTableOf <ITEM>& t) { return (IvlIdIterOf<ITEM>&) IvlIdIter::operator = (t); }
+inline IvlIdIterOf<ITEM>& operator = (const IvlIdIterOf<ITEM>& li) { return (IvlIdIterOf<ITEM>&) IvlIdIter::operator = (li); }
+inline IvlIdIterOf<ITEM>& operator ++ () { return (IvlIdIterOf<ITEM>&) IvlIdIter::operator ++ (); }
+inline ITEM* Current () const { return (ITEM*) IvlIdIter::Current (); }
inline ITEM* operator * () const { return Current (); }
};
-
-
#endif /* IdTable_H_ */
diff --git a/utils/Imakefile b/utils/Imakefile
deleted file mode 100644
index 4dd9253..0000000
--- a/utils/Imakefile
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# CENA C++ Utilities
-#
-# by Stephane Chatty
-#
-# Copyright 1991-1996
-# Laboratoire de Recherche en Informatique (LRI)
-# Centre d'Etudes de la Navigation Aerienne (CENA)
-#
-# Imakefile
-#
-# $Id$
-# $CurLog$
-#
-
- CXXFLAGS = $(CXXOPTIONS) -I$(LOCINCL)
-
- OBJ = Allocator.o List.o DList.o Chain.o String.o Array.o \
- HashTable.o IdTable.o DirPath.o RegExp.o SmartPointer.o \
- Signal.o Time.o Timer.o Automaton.o BitField.o
-
- cc = $(CXXSUFFIX)
- SRC = Allocator.$(cc) List.$(cc) DList.$(cc) String.$(cc) Array.$(cc) \
- HashTable.$(cc) DirPath.$(cc) IdTable.$(cc) RegExp.$(cc) SmartPointer.$(cc) \
- Signal.$(cc) Time.$(cc) Timer.$(cc) Automaton.$(cc) BitField.$(cc)
-
- HDR = bool.h word.h Initializer.h Allocator.h List.h DList.h Chain.h String.h Array.h \
- HashTable.h IdTable.h DirPath.h RegExp.h SmartPointer.h \
- Signal.h Time.h Timer.h Automaton.h BitField.h
-
-
- LLIB =
- DOC = ../../DOC/CCU
-
-CxxRule ()
-
-all : $(LOCLIB)/libCcu.a $(LOCINCL)/ccu.h headers
-
-headers: incldir \
- $(LOCINCL)/ccu/bool.h \
- $(LOCINCL)/ccu/word.h \
- $(LOCINCL)/ccu/Initializer.h \
- $(LOCINCL)/ccu/Allocator.h \
- $(LOCINCL)/ccu/List.h \
- $(LOCINCL)/ccu/DList.h \
- $(LOCINCL)/ccu/Chain.h \
- $(LOCINCL)/ccu/String.h \
- $(LOCINCL)/ccu/Array.h \
- $(LOCINCL)/ccu/HashTable.h \
- $(LOCINCL)/ccu/IdTable.h \
- $(LOCINCL)/ccu/DirPath.h \
- $(LOCINCL)/ccu/RegExp.h \
- $(LOCINCL)/ccu/SmartPointer.h \
- $(LOCINCL)/ccu/Signal.h \
- $(LOCINCL)/ccu/Time.h \
- $(LOCINCL)/ccu/Timer.h \
- $(LOCINCL)/ccu/Automaton.h \
- $(LOCINCL)/ccu/BitField.h
-
-incldir:
- -mkdir $(LOCINCL)/ccu
-
-
-InstallLibsTarget ($(LOCLIB),Ccu)
-InstallTarget ($(LOCINCL)/ccu.h, ccu.h)
-InstallTarget ($(LOCINCL)/ccu/bool.h, bool.h)
-InstallTarget ($(LOCINCL)/ccu/word.h, word.h)
-InstallTarget ($(LOCINCL)/ccu/Initializer.h, Initializer.h)
-InstallTarget ($(LOCINCL)/ccu/Allocator.h, Allocator.h)
-InstallTarget ($(LOCINCL)/ccu/List.h, List.h)
-InstallTarget ($(LOCINCL)/ccu/DList.h, DList.h)
-InstallTarget ($(LOCINCL)/ccu/Chain.h, Chain.h)
-InstallTarget ($(LOCINCL)/ccu/String.h, String.h)
-InstallTarget ($(LOCINCL)/ccu/Array.h, Array.h)
-InstallTarget ($(LOCINCL)/ccu/HashTable.h, HashTable.h)
-InstallTarget ($(LOCINCL)/ccu/IdTable.h, IdTable.h)
-InstallTarget ($(LOCINCL)/ccu/DirPath.h, DirPath.h)
-InstallTarget ($(LOCINCL)/ccu/RegExp.h, RegExp.h)
-InstallTarget ($(LOCINCL)/ccu/SmartPointer.h, SmartPointer.h)
-InstallTarget ($(LOCINCL)/ccu/Signal.h, Signal.h)
-InstallTarget ($(LOCINCL)/ccu/Time.h, Time.h)
-InstallTarget ($(LOCINCL)/ccu/Timer.h, Timer.h)
-InstallTarget ($(LOCINCL)/ccu/Automaton.h, Automaton.h)
-InstallTarget ($(LOCINCL)/ccu/BitField.h, BitField.h)
-
-GenHeaderTarget (ccu.h, version.h $(HDR))
-LibraryTarget (Ccu,$(OBJ))
-
-DocRule("CENA C++ Utilities")
-TeXRule()
-DistrDocRule(CCU)
diff --git a/utils/Initializer.h b/utils/Initializer.h
index 5ed3a59..85c8b27 100644
--- a/utils/Initializer.h
+++ b/utils/Initializer.h
@@ -20,9 +20,9 @@
#ifndef CPLUS_BUG19
-template <class CLASS> class CcuInitializerFor {
+template <class CLASS> class IvlInitializerFor {
public:
-inline CcuInitializerFor () { if (!CLASS::ClassInitialized) CLASS::ClassInit (); }
+inline IvlInitializerFor () { if (!CLASS::ClassInitialized) CLASS::ClassInit (); }
};
#endif
diff --git a/utils/List.cc b/utils/List.cc
index 37c11eb..c954ca7 100644
--- a/utils/List.cc
+++ b/utils/List.cc
@@ -17,51 +17,49 @@
#include <stdlib.h>
#include <stdio.h>
-/*?class CcuList
+/*?class IvlList
\begin{figure}[hbtp]
\hfil
-\psfig{figure=FIGURES/CcuList.epsf}\par \caption{Internal structure of \typ{CcuList}s}
+\psfig{figure=FIGURES/IvlList.epsf}\par \caption{Internal structure of \typ{IvlList}s}
\hfil
\end{figure}
?*/
#ifdef CPLUS_BUG20
-class CcuListLink {
-static CcuAllocator* ListLinkMem;
+class IvlListLink {
+static IvlAllocator* ListLinkMem;
static void ClassInit ();
public:
- CcuListItem* Entry;
- CcuListLink* Next;
-inline CcuListLink (CcuListItem* e, CcuListLink* n = 0) { Entry = e; Next = n ? n : this; }
- CcuListLink* Previous ();
+ IvlListItem* Entry;
+ IvlListLink* Next;
+inline IvlListLink (IvlListItem* e, IvlListLink* n = 0) { Entry = e; Next = n ? n : this; }
+ IvlListLink* Previous ();
void* operator new (size_t);
void operator delete (void*);
};
#endif
-
-
#ifdef CPLUS_BUG20
-CcuAllocator* CcuListLink::ListLinkMem = 0;
+IvlAllocator* IvlListLink::ListLinkMem = 0;
#else
-CcuAllocator* CcuList::CcuListLink::ListLinkMem = 0;
+IvlAllocator* IvlList::IvlListLink::ListLinkMem = 0;
#endif
/*?nodoc?*/
void*
#ifdef CPLUS_BUG20
-CcuListLink :: operator new (size_t)
+IvlListLink :: operator new (size_t)
#else
-CcuList::CcuListLink :: operator new (size_t)
+IvlList::IvlListLink :: operator new (size_t)
#endif
{
if (!ListLinkMem)
#ifdef CPLUS_BUG20
- ListLinkMem = new CcuAllocator (sizeof (CcuListLink));
+ ListLinkMem = new IvlAllocator (sizeof (IvlListLink));
#else
- ListLinkMem = new CcuAllocator (sizeof (CcuList::CcuListLink));
+ ListLinkMem = new IvlAllocator (sizeof (IvlList::IvlListLink));
#endif
return ListLinkMem->Alloc ();
}
@@ -69,31 +67,30 @@ CcuList::CcuListLink :: operator new (size_t)
/*?nodoc?*/
void
#ifdef CPLUS_BUG20
-CcuListLink :: operator delete (void* that)
+IvlListLink :: operator delete (void* that)
#else
-CcuList::CcuListLink :: operator delete (void* that)
+IvlList::IvlListLink :: operator delete (void* that)
#endif
{
ListLinkMem->Free (that);
}
-
/*!
Get the link whose next link is this one.
!*/
/*?hidden?*/
#ifndef CPLUS_BUG20
-CcuList::CcuListLink*
-CcuList::CcuListLink :: Previous ()
+IvlList::IvlListLink*
+IvlList::IvlListLink :: Previous ()
#else
-CcuListLink*
-CcuListLink :: Previous ()
+IvlListLink*
+IvlListLink :: Previous ()
#endif
{
#ifndef CPLUS_BUG20
- register CcuList::CcuListLink* pl = this;
+ register IvlList::IvlListLink* pl = this;
#else
- register CcuListLink* pl = this;
+ register IvlListLink* pl = this;
#endif
while (pl->Next != this)
pl = pl->Next;
@@ -104,7 +101,7 @@ CcuListLink :: Previous ()
/*?
Create an empty list.
?*/
-CcuList :: CcuList ()
+IvlList :: IvlList ()
{
}
#endif
@@ -112,27 +109,26 @@ CcuList :: CcuList ()
/*?
Create a list with one element \var{e}.
?*/
-CcuList :: CcuList (CcuListItem* e)
-: LastLink (new CcuListLink (e)),
+IvlList :: IvlList (IvlListItem* e)
+: LastLink (new IvlListLink (e)),
StatusFlag (NoError)
{
}
/*?nodoc?*/
-CcuList :: CcuList (const CcuList& l)
+IvlList :: IvlList (const IvlList& l)
: LastLink (0),
StatusFlag (NoError)
{
- CcuListIter li (l);
+ IvlListIter li (l);
while (++li)
Append (*li);
}
-
/*?
Destructor for lists. No operation is performed on the elements.
?*/
-CcuList :: ~CcuList ()
+IvlList :: ~IvlList ()
{
Clear ();
}
@@ -141,11 +137,11 @@ CcuList :: ~CcuList ()
Empty a list.
?*/
void
-CcuList :: Clear ()
+IvlList :: Clear ()
{
- CcuListLink* del = LastLink;
+ IvlListLink* del = LastLink;
while (del) {
- CcuListLink* next = del->Next;
+ IvlListLink* next = del->Next;
if (next == LastLink)
next = 0;
delete del;
@@ -155,12 +151,12 @@ CcuList :: Clear ()
}
/*?nodoc?*/
-CcuList&
-CcuList :: operator = (const CcuList& l)
+IvlList&
+IvlList :: operator = (const IvlList& l)
{
if (this != &l) {
Clear ();
- CcuListIter li (l);
+ IvlListIter li (l);
while (++li)
Append (*li);
}
@@ -169,21 +165,21 @@ CcuList :: operator = (const CcuList& l)
#ifdef DOC
/*?
-Get the status flag of a list. This can be one of \var{CcuList::NoError, CcuList::WasEmpty,
-CcuList::TooEarly, CcuList::TooFar} or \var{CcuList::BadIterator}.
+Get the status flag of a list. This can be one of \var{IvlList::NoError, IvlList::WasEmpty,
+IvlList::TooEarly, IvlList::TooFar} or \var{IvlList::BadIterator}.
The status flag is modified by most operations on lists. Those which
-modify it when errors are encountered also set it to \var{CcuList::NoError}
+modify it when errors are encountered also set it to \var{IvlList::NoError}
when there is no error.
?*/
list_status
-CcuList :: GetStatus () const
+IvlList :: GetStatus () const
{
}
#endif /* DOC */
/*?nextdoc?*/
-CcuListItem*
-CcuList :: First ()
+IvlListItem*
+IvlList :: First ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -197,10 +193,10 @@ CcuList :: First ()
Return the first (resp. last) element in the list, or 0 if the list was empty.
The case of a null element can be distinguished from the case
when the list is empty with the function \fun{GetStatus}: the status flag is
-set to \var{CcuList::WasEmpty} in the latter case.
+set to \var{IvlList::WasEmpty} in the latter case.
?*/
-CcuListItem*
-CcuList :: Last ()
+IvlListItem*
+IvlList :: Last ()
{
if (!LastLink) {
StatusFlag = WasEmpty;
@@ -212,16 +208,16 @@ CcuList :: Last ()
/*?
Get the \var{n}-th element of a list. If \var{n} is greater than the length of the list
-this function returns 0 and sets the status to \var{CcuList::TooFar}. If \var{n} is negative,
-this function returns 0 but sets the status to \var{CcuList::NoError}.
+this function returns 0 and sets the status to \var{IvlList::TooFar}. If \var{n} is negative,
+this function returns 0 but sets the status to \var{IvlList::NoError}.
?*/
-CcuListItem*
-CcuList :: Nth (int n)
+IvlListItem*
+IvlList :: Nth (int n)
{
StatusFlag = NoError;
if (n <= 0)
return 0;
- CcuListIter li (*this);
+ IvlListIter li (*this);
while (n > 0 && ++li)
--n;
if (n != 0)
@@ -233,10 +229,10 @@ CcuList :: Nth (int n)
Compute the number of elements in a list.
?*/
int
-CcuList :: Length () const
+IvlList :: Length () const
{
int result = 0;
- CcuListIter li (*this);
+ IvlListIter li (*this);
while (++li)
++result;
return result;
@@ -247,12 +243,12 @@ Check whether an item is present in a list. If \var{rank} is not null, it is fil
rank of the first occurence of \var{e} in the list.
?*/
int
-CcuList :: Find (CcuListItem* e, int* rank) const
+IvlList :: Find (IvlListItem* e, int* rank) const
{
int rk = 0;
int ret = 0;
- CcuListIter li (*this);
+ IvlListIter li (*this);
while (++rk, ++li)
if (*li == e) {
ret = 1;
@@ -265,36 +261,36 @@ CcuList :: Find (CcuListItem* e, int* rank) const
}
/*?nextdoc?*/
-CcuListIndex
-CcuList :: Prepend (CcuListItem* e)
+IvlListIndex
+IvlList :: Prepend (IvlListItem* e)
{
if (LastLink)
/* remember that LastLink->Next is the first */
- LastLink->Next = new CcuListLink (e, LastLink->Next);
+ LastLink->Next = new IvlListLink (e, LastLink->Next);
else
- LastLink = new CcuListLink (e);
+ LastLink = new IvlListLink (e);
return LastLink;
}
/*?
Add an element at the beginning (resp. end) of a list.
?*/
-CcuListIndex
-CcuList :: Append (CcuListItem* e)
+IvlListIndex
+IvlList :: Append (IvlListItem* e)
{
if (LastLink) {
- LastLink = LastLink->Next = new CcuListLink (e, LastLink->Next);
+ LastLink = LastLink->Next = new IvlListLink (e, LastLink->Next);
} else
- LastLink = new CcuListLink (e);
+ LastLink = new IvlListLink (e);
return LastLink;
}
/*?
Remove the first element of a list and return it. The status flag is set to
-\var{CcuList::WasEmpty} when the list was empty.
+\var{IvlList::WasEmpty} when the list was empty.
?*/
-CcuListItem*
-CcuList :: RemoveFirst ()
+IvlListItem*
+IvlList :: RemoveFirst ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -304,8 +300,8 @@ CcuList :: RemoveFirst ()
StatusFlag = NoError;
/* Get the first element and its data */
- CcuListLink* first = LastLink->Next;
- CcuListItem* data = first->Entry;
+ IvlListLink* first = LastLink->Next;
+ IvlListItem* data = first->Entry;
/* Remove it from the chain */
if (LastLink == first)
LastLink = 0;
@@ -317,14 +313,13 @@ CcuList :: RemoveFirst ()
return data;
}
-
/*?
Remove the last element of a list and return it. The status flag is set to
-\var{CcuList::WasEmpty} when the list was empty. This function has to locate the last
+\var{IvlList::WasEmpty} when the list was empty. This function has to locate the last
element, and hence has a linear cost.
?*/
-CcuListItem*
-CcuList :: RemoveLast ()
+IvlListItem*
+IvlList :: RemoveLast ()
{
/* Handle the case when the list is empty */
if (!LastLink) {
@@ -334,11 +329,11 @@ CcuList :: RemoveLast ()
StatusFlag = NoError;
/* Find the element that will be the new LastLink */
- register CcuListLink* newlast = LastLink->Previous ();
+ register IvlListLink* newlast = LastLink->Previous ();
/* Save the element to be deleted and its data */
- CcuListLink* del = LastLink;
- CcuListItem* data = LastLink->Entry;
+ IvlListLink* del = LastLink;
+ IvlListItem* data = LastLink->Entry;
/* Remove it from the chain */
if (newlast == LastLink)
LastLink = 0;
@@ -356,24 +351,23 @@ CcuList :: RemoveLast ()
Insert an element before the link \var{l}. This function has a linear cost.
!*/
/*?hidden?*/
-CcuListIndex
-CcuList :: InsertBeforeLink (CcuListLink* l, CcuListItem* e)
+IvlListIndex
+IvlList :: InsertBeforeLink (IvlListLink* l, IvlListItem* e)
{
- CcuListLink* prev = l->Previous ();
- CcuListLink* newlink = new CcuListLink (e, l);
+ IvlListLink* prev = l->Previous ();
+ IvlListLink* newlink = new IvlListLink (e, l);
prev->Next = newlink;
return newlink;
}
-
/*!
Insert an element after the link \var{l}.
!*/
/*?hidden?*/
-CcuListIndex
-CcuList :: InsertAfterLink (CcuListLink* l, CcuListItem* e)
+IvlListIndex
+IvlList :: InsertAfterLink (IvlListLink* l, IvlListItem* e)
{
- CcuListLink* newlink = new CcuListLink (e, l->Next);
+ IvlListLink* newlink = new IvlListLink (e, l->Next);
l->Next = newlink;
if (LastLink == l)
LastLink = newlink;
@@ -385,11 +379,11 @@ Remove the link which is after \var{l} and return its entry. If \var{l} is the l
the list, the first one is removed.
!*/
/*?hidden?*/
-CcuListItem*
-CcuList :: RemoveAfterLink (CcuListLink* l)
+IvlListItem*
+IvlList :: RemoveAfterLink (IvlListLink* l)
{
- CcuListLink* del = l->Next;
- CcuListItem* data = del->Entry;
+ IvlListLink* del = l->Next;
+ IvlListItem* data = del->Entry;
if (del == l) {
LastLink = 0;
} else {
@@ -407,11 +401,11 @@ Remove an element from a list. This function iterates through the list until it
If \var{num} is \var{All} or is negative, all appearances of \var{entry} are deleted.
?*/
int
-CcuList :: Remove (CcuListItem* entry, int num)
+IvlList :: Remove (IvlListItem* entry, int num)
{
int removed = 0;
- CcuListIter li (*this);
- CcuListIter lj (*this);
+ IvlListIter li (*this);
+ IvlListIter lj (*this);
while ((num < 0 || removed < num) && ++li) {
if (*li == entry) {
RemoveAfter (lj);
@@ -430,11 +424,11 @@ The actual number of removals is returned.
If \var{num} is \var{All} or is negative, all matching elements are deleted.
?*/
int
-CcuList :: Remove (int (*p) (CcuListItem*), int num)
+IvlList :: Remove (int (*p) (IvlListItem*), int num)
{
int removed = 0;
- CcuListIter li (*this);
- CcuListIter lj (*this);
+ IvlListIter li (*this);
+ IvlListIter lj (*this);
while ((num < 0 || removed < num) && ++li) {
if ((*p) (*li)) {
RemoveAfter (lj);
@@ -446,25 +440,24 @@ CcuList :: Remove (int (*p) (CcuListItem*), int num)
return removed;
}
-
/*?nextdoc?*/
-CcuListIndex
-CcuList :: InsertAfter (const CcuListIter& li, CcuListItem* e)
+IvlListIndex
+IvlList :: InsertAfter (const IvlListIter& li, IvlListItem* e)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
return 0;
}
StatusFlag = NoError;
- CcuListIndex idx = 0;
+ IvlListIndex idx = 0;
if (!li.CurLink) {
- if (li.StatusFlag == CcuListIter::StartOfList) {
+ if (li.StatusFlag == IvlListIter::StartOfList) {
idx = Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuList::InsertAfter\n");
+ fprintf (stderr, "abnormal status in IvlList::InsertAfter\n");
abort ();
}
- } else if (li.StatusFlag == CcuListIter::EndOfList) {
+ } else if (li.StatusFlag == IvlListIter::EndOfList) {
idx = Append (e);
} else {
idx = InsertAfterLink (li.CurLink, e);
@@ -474,29 +467,29 @@ CcuList :: InsertAfter (const CcuListIter& li, CcuListItem* e)
/*?
Insert an element before (resp. after) the current position of the iterator \var{li}.
-These functions are both equivalent to \fun{CcuList::Prepend} if the iterator is at the
+These functions are both equivalent to \fun{IvlList::Prepend} if the iterator is at the
beginning of the list (ie. before the first element).
\fun{InsertAfter} is performed in a constant time, while \fun{InsertBefore}
has a linear cost. If \var{li} is not an iterator on this list, the status flag of the list
-is set to \var{CcuList::BadIterator}.
+is set to \var{IvlList::BadIterator}.
?*/
-CcuListIndex
-CcuList :: InsertBefore (const CcuListIter& li, CcuListItem* e)
+IvlListIndex
+IvlList :: InsertBefore (const IvlListIter& li, IvlListItem* e)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
return 0;
}
StatusFlag = NoError;
- CcuListIndex idx = 0;
+ IvlListIndex idx = 0;
if (!li.CurLink) {
- if (li.StatusFlag == CcuListIter::StartOfList) {
+ if (li.StatusFlag == IvlListIter::StartOfList) {
idx = Prepend (e);
} else {
- fprintf (stderr, "abnormal status in CcuList::InsertAfter\n");
+ fprintf (stderr, "abnormal status in IvlList::InsertAfter\n");
abort ();
}
- } else if (li.StatusFlag == CcuListIter::EndOfList) {
+ } else if (li.StatusFlag == IvlListIter::EndOfList) {
idx = Append (e);
} else {
idx = InsertBeforeLink (li.CurLink, e);
@@ -507,15 +500,15 @@ CcuList :: InsertBefore (const CcuListIter& li, CcuListItem* e)
/*?
Remove the element after the current element of the iterator \var{li}.
If \var{li} points before the beginning of the list, the first element is removed.
-If \var{li} points at the last element, the status flag is set to \var{CcuList::TooFar}.
-If the list is empty, the flag is set to \var{CcuList::EmptyList}. In both cases, the
+If \var{li} points at the last element, the status flag is set to \var{IvlList::TooFar}.
+If the list is empty, the flag is set to \var{IvlList::EmptyList}. In both cases, the
return value is null. If \var{li} is not an iterator
-on this list, the flag is set to \var{CcuList::BadIterator}.
+on this list, the flag is set to \var{IvlList::BadIterator}.
This function may be used
when one wants to iterate through a list and remove some elements:
\begin{ccode}
- CcuListIter li = l;
- CcuListIter lj = l;
+ IvlListIter li = l;
+ IvlListIter lj = l;
while (++li)
if (do_remove (*li)) {
l.RemoveAfter (lj);
@@ -525,8 +518,8 @@ when one wants to iterate through a list and remove some elements:
}
\end{ccode}
?*/
-CcuListItem*
-CcuList :: RemoveAfter (const CcuListIter& li)
+IvlListItem*
+IvlList :: RemoveAfter (const IvlListIter& li)
{
if (li.TheList != this) {
StatusFlag = BadIterator;
@@ -544,11 +537,10 @@ CcuList :: RemoveAfter (const CcuListIter& li)
}
}
-
#ifdef DOC
-/*?class CcuListIter
-The class \typ{CcuListIter} allows iterations on lists.
+/*?class IvlListIter
+The class \typ{IvlListIter} allows iterations on lists.
Several iterators may be used at a time on the same list. It is dangerous to modify
a list that is being iterated. Refer to the implementation figure for more details.
Of course, the functions such as \var{InsertAfter} or \var{RemoveAfter} are designed
@@ -556,8 +548,8 @@ to be harmless. However, they may be dangerous if another iterator is used at th
time on the same list.
The basic usage of an iterator is the following:
\begin{ccode}
- extern CcuList& l;
- CcuListIter li = l;
+ extern IvlList& l;
+ IvlListIter li = l;
while (++li)
foo (*li); // *li is the value that was stored with Append
\end{ccode}
@@ -567,7 +559,7 @@ The basic usage of an iterator is the following:
Initialize an iterator associated to the list \var{l}. That iterator will point at the beginning
of the list, {\em before} the first element.
?*/
-CcuListIter :: CcuListIter (const CcuList& l)
+IvlListIter :: IvlListIter (const IvlList& l)
{
}
#endif /* DOC */
@@ -576,25 +568,24 @@ CcuListIter :: CcuListIter (const CcuList& l)
Build an iterator on list \var{l}, pointing at the element denoted by \var{idx}. No check is done on whether
\var{idx} is a valid index of list \var{l}.
?*/
-CcuListIter :: CcuListIter (const CcuList& l, CcuListIndex idx)
+IvlListIter :: IvlListIter (const IvlList& l, IvlListIndex idx)
: TheList (&l),
#ifdef CPLUS_BUG20
- CurLink ((CcuListLink*) idx),
+ CurLink ((IvlListLink*) idx),
#else
- CurLink ((CcuList::CcuListLink*) idx),
+ CurLink ((IvlList::IvlListLink*) idx),
#endif
StatusFlag (idx ? Normal : StartOfList)
{
}
-
#ifdef DOC
/*?
-Get the status of an iterator. The status may be one of \var{CcuListIter::Normal,
-CcuListIter::StartOfList}, or \var{CcuListIter::EndOfList}
+Get the status of an iterator. The status may be one of \var{IvlListIter::Normal,
+IvlListIter::StartOfList}, or \var{IvlListIter::EndOfList}
?*/
listiter_status
-CcuListIter :: GetStatus () const
+IvlListIter :: GetStatus () const
{
}
@@ -602,39 +593,37 @@ CcuListIter :: GetStatus () const
Reset an iterator to the beginning of the list.
?*/
void
-CcuListIter :: Reset ()
+IvlListIter :: Reset ()
{
}
#endif /* DOC */
-
/*?
Get the current entry pointed by an iterator. This operator returns 0 if the iterator is
at the beginning or the end of the list. To distinguish those cases from the
case when the entry is null, you can use the method \fun{GetStatus}.
?*/
-CcuListItem*
-CcuListIter :: operator * () const
+IvlListItem*
+IvlListIter :: operator * () const
{
return (CurLink && StatusFlag == Normal) ? CurLink->Entry : 0;
}
#ifdef DOC
/*?
-Check whether the status of an iterator is \var{CcuListIter::Normal}.
+Check whether the status of an iterator is \var{IvlListIter::Normal}.
?*/
-CcuListIter :: operator int () const
+IvlListIter :: operator int () const
{
}
#endif /* DOC */
-
/*?
Take one step of iteration.
?*/
-CcuListIter&
-CcuListIter :: operator ++ ()
+IvlListIter&
+IvlListIter :: operator ++ ()
{
/* This test covers all the cases :
- the iteration has already begun, and is at its end.
@@ -654,8 +643,8 @@ CcuListIter :: operator ++ ()
Post-increment equivalent of the previous operator. This operator is just here
as a placeholder: it does the same thing as the previous one.
?*/
-CcuListIter&
-CcuListIter :: operator ++ (int)
+IvlListIter&
+IvlListIter :: operator ++ (int)
{
++(*this);
return *this;
@@ -669,7 +658,7 @@ If \var{e} is present in the list, the iterator will
be correctly positionned. If not, it will have reached the end of the list.
?*/
int
-CcuListIter :: Find (CcuListItem* e)
+IvlListIter :: Find (IvlListItem* e)
{
while (++(*this))
if (**this == e)
@@ -679,125 +668,124 @@ CcuListIter :: Find (CcuListItem* e)
#ifdef DOC
-/*?class CcuListOf
-The generic classes \typ{CcuListOf} and \typ{CcuListIterOf} are derived classes
-of \typ{CcuList} and \typ{CcuListIter} that provide lists of pointers to class objects.
+/*?class IvlListOf
+The generic classes \typ{IvlListOf} and \typ{IvlListIterOf} are derived classes
+of \typ{IvlList} and \typ{IvlListIter} that provide lists of pointers to class objects.
When parameterized by the class \typ{ITEM}, the following functions are redefined:
?*/
/*?nextdoc?*/
-CcuListOf :: CcuListOf (ITEM* it)
+IvlListOf :: IvlListOf (ITEM* it)
{
}
/*?nextdoc?*/
ITEM*
-CcuListOf :: First ()
+IvlListOf :: First ()
{
}
/*?nextdoc?*/
ITEM*
-CcuListOf :: Last ()
+IvlListOf :: Last ()
{
}
/*?nextdoc?*/
ITEM*
-CcuListOf :: Nth (int n)
+IvlListOf :: Nth (int n)
{
}
/*?nextdoc?*/
int
-CcuListOf :: Find (ITEM* it) const
+IvlListOf :: Find (ITEM* it) const
{
}
/*?nextdoc?*/
void
-CcuListOf :: Append (ITEM* it)
+IvlListOf :: Append (ITEM* it)
{
}
/*?nextdoc?*/
void
-CcuListOf :: Prepend (ITEM* it)
+IvlListOf :: Prepend (ITEM* it)
{
}
/*?nextdoc?*/
-CcuListOf&
-CcuListOf :: operator << (ITEM* it)
+IvlListOf&
+IvlListOf :: operator << (ITEM* it)
{
}
/*?nextdoc?*/
ITEM*
-CcuListOf :: RemoveFirst ()
+IvlListOf :: RemoveFirst ()
{
}
/*?nextdoc?*/
ITEM*
-CcuListOf :: RemoveLast ()
+IvlListOf :: RemoveLast ()
{
}
/*?nextdoc?*/
int
-CcuListOf :: Remove (ITEM* it, int nb = 1)
+IvlListOf :: Remove (ITEM* it, int nb = 1)
{
}
/*?nextdoc?*/
int
-CcuListOf :: Remove (int (*p) (ITEM*), int nb = 1)
+IvlListOf :: Remove (int (*p) (ITEM*), int nb = 1)
{
}
/*?nextdoc?*/
void
-CcuListOf :: InsertAfter (const CcuListIterOf <ITEM>& li, ITEM*it)
+IvlListOf :: InsertAfter (const IvlListIterOf <ITEM>& li, ITEM*it)
{
}
/*?nextdoc?*/
void
-CcuListOf :: InsertBefore (const CcuListIterOf <ITEM>& li, ITEM* it)
+IvlListOf :: InsertBefore (const IvlListIterOf <ITEM>& li, ITEM* it)
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuList},
+These functions are equivalent to their homonyms in the class \typ{IvlList},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
ITEM*
-CcuListOf :: RemoveAfter (const CcuListIterOf <ITEM>& li)
+IvlListOf :: RemoveAfter (const IvlListIterOf <ITEM>& li)
{
}
/*?nextdoc?*/
-CcuListIterOf :: CcuListIterOf (const CcuListOf <ITEM>& l)
+IvlListIterOf :: IvlListIterOf (const IvlListOf <ITEM>& l)
{
}
/*?nextdoc?*/
ITEM*
-CcuListIterOf :: operator * () const
+IvlListIterOf :: operator * () const
{
}
/*?
-These functions are equivalent to their homonyms in the class \typ{CcuListIter},
+These functions are equivalent to their homonyms in the class \typ{IvlListIter},
except that they are customized in order to manipulate pointers to \typ{ITEM}
instead of \typ{void*}.
?*/
int
-CcuListIterOf :: Find (ITEM* it)
+IvlListIterOf :: Find (ITEM* it)
{
}
-
#endif /* DOC */
diff --git a/utils/List.h b/utils/List.h
index 5067da6..def2919 100644
--- a/utils/List.h
+++ b/utils/List.h
@@ -18,26 +18,26 @@
#include "cplus_bugs.h"
#include <sys/types.h>
-class CcuAllocator;
+class IvlAllocator;
-typedef void CcuListItem;
-typedef void* CcuListIndex;
+typedef void IvlListItem;
+typedef void* IvlListIndex;
#ifdef CPLUS_BUG20
-class CcuListLink;
+class IvlListLink;
#endif
-class CcuList {
-friend class CcuListIter;
+class IvlList {
+friend class IvlListIter;
#ifndef CPLUS_BUG20
- class CcuListLink {
- static CcuAllocator* ListLinkMem;
+ class IvlListLink {
+ static IvlAllocator* ListLinkMem;
public:
- CcuListItem* Entry;
- CcuListLink* Next;
- inline CcuListLink (CcuListItem* e, CcuListLink* n = 0) { Entry = e; Next = n ? n : this; }
- CcuListLink* Previous ();
+ IvlListItem* Entry;
+ IvlListLink* Next;
+ inline IvlListLink (IvlListItem* e, IvlListLink* n = 0) { Entry = e; Next = n ? n : this; }
+ IvlListLink* Previous ();
void* operator new (size_t);
void operator delete (void*);
};
@@ -49,155 +49,158 @@ public:
private:
- CcuListLink* LastLink;
+ IvlListLink* LastLink;
list_status StatusFlag;
- CcuListIndex InsertAfterLink (CcuListLink*, CcuListItem*);
- CcuListIndex InsertBeforeLink (CcuListLink*, CcuListItem*);
- CcuListItem* RemoveAfterLink (CcuListLink*);
+ IvlListIndex InsertAfterLink (IvlListLink*, IvlListItem*);
+ IvlListIndex InsertBeforeLink (IvlListLink*, IvlListItem*);
+ IvlListItem* RemoveAfterLink (IvlListLink*);
public:
-inline CcuList () : LastLink (0), StatusFlag (NoError) { }
- CcuList (CcuListItem*);
- CcuList (const CcuList&);
- ~CcuList ();
- CcuList& operator = (const CcuList&);
+inline IvlList () : LastLink (0), StatusFlag (NoError) { }
+ IvlList (IvlListItem*);
+ IvlList (const IvlList&);
+ ~IvlList ();
+ IvlList& operator = (const IvlList&);
inline list_status GetStatus () const { return StatusFlag; }
inline int IsEmpty () const { return !LastLink; }
- CcuListItem* First ();
- CcuListItem* Last ();
- CcuListItem* Nth (int n);
+ IvlListItem* First ();
+ IvlListItem* Last ();
+ IvlListItem* Nth (int n);
int Length () const;
- int Find (CcuListItem*, int* = 0) const;
+ int Find (IvlListItem*, int* = 0) const;
- CcuListIndex Append (CcuListItem*);
- CcuListIndex Prepend (CcuListItem*);
-inline CcuList& operator << (CcuListItem* it) { Append (it); return *this; }
+ IvlListIndex Append (IvlListItem*);
+ IvlListIndex Prepend (IvlListItem*);
+inline IvlList& operator << (IvlListItem* it) { Append (it); return *this; }
- CcuListItem* RemoveFirst ();
- CcuListItem* RemoveLast ();
- int Remove (CcuListItem*, int = 1);
- int Remove (int (*) (CcuListItem*), int = 1);
+ IvlListItem* RemoveFirst ();
+ IvlListItem* RemoveLast ();
+ int Remove (IvlListItem*, int = 1);
+ int Remove (int (*) (IvlListItem*), int = 1);
void Clear ();
- CcuListIndex InsertAfter (const CcuListIter&, CcuListItem*);
- CcuListIndex InsertBefore (const CcuListIter&, CcuListItem*);
- CcuListItem* RemoveAfter (const CcuListIter&);
+ IvlListIndex InsertAfter (const IvlListIter&, IvlListItem*);
+ IvlListIndex InsertBefore (const IvlListIter&, IvlListItem*);
+ IvlListItem* RemoveAfter (const IvlListIter&);
};
-class CcuListIter {
-friend class CcuList;
+class IvlListIter {
+friend class IvlList;
public:
enum listiter_status { Normal, StartOfList, EndOfList };
private:
- const CcuList* TheList;
+ const IvlList* TheList;
#ifdef CPLUS_BUG20
- CcuListLink* CurLink;
+ IvlListLink* CurLink;
#else
- CcuList::CcuListLink* CurLink;
+ IvlList::IvlListLink* CurLink;
#endif
listiter_status StatusFlag;
public:
-inline CcuListIter (const CcuList& l) : TheList (&l), CurLink (0), StatusFlag (StartOfList) { }
- CcuListIter (const CcuList&, CcuListIndex);
+inline IvlListIter (const IvlList& l) : TheList (&l), CurLink (0), StatusFlag (StartOfList) { }
+ IvlListIter (const IvlList&, IvlListIndex);
inline void Reset () { CurLink = 0; StatusFlag = StartOfList; }
-inline CcuListIter& operator = (const CcuList& l) { TheList = &l; CurLink = 0; StatusFlag = StartOfList; return *this; }
-inline CcuListIter& operator = (const CcuListIter& li) { TheList = li.TheList; CurLink = li.CurLink; StatusFlag = li.StatusFlag; return *this; }
- CcuListIter& operator ++ ();
+inline IvlListIter& operator = (const IvlList& l) { TheList = &l; CurLink = 0; StatusFlag = StartOfList; return *this; }
+inline IvlListIter& operator = (const IvlListIter& li) { TheList = li.TheList; CurLink = li.CurLink; StatusFlag = li.StatusFlag; return *this; }
+ IvlListIter& operator ++ ();
#ifndef CPLUS_BUG16
- CcuListIter& operator ++ (int);
+ IvlListIter& operator ++ (int);
#endif
- CcuListItem* operator * () const;
- int Find (CcuListItem*);
+ IvlListItem* operator * () const;
+ int Find (IvlListItem*);
inline listiter_status GetStatus () const { return StatusFlag; }
inline operator int () const { return StatusFlag == Normal; }
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuListIterOf;
+template <class ITEM> class IvlListIterOf;
-template <class ITEM> class CcuListOf : public CcuList {
+template <class ITEM> class IvlListOf : public IvlList {
public:
-inline CcuListOf () : CcuList () {}
-inline CcuListOf (ITEM* it) : CcuList (it) {}
-inline ITEM* First () { return (ITEM*) (CcuList::First ()); }
-inline ITEM* Last () { return (ITEM*) (CcuList::Last ()); }
-inline ITEM* Nth (int n) { return (ITEM*) (CcuList::Nth (n)); }
-inline int Find (ITEM* it, int* r = 0) const { return CcuList::Find (it, r); }
-
-inline CcuListIndex Append (ITEM* it) { return CcuList::Append (it); }
-inline CcuListIndex Prepend (ITEM* it) { return CcuList::Prepend (it); }
-inline CcuListOf<ITEM>& operator << (ITEM* it) { CcuList::Append (it); return *this; }
-
-inline ITEM* RemoveFirst () { return (ITEM*) (CcuList::RemoveFirst ()); }
-inline ITEM* RemoveLast () { return (ITEM*) (CcuList::RemoveLast ()); }
-inline int Remove (ITEM* it, int nb = 1) { return CcuList::Remove (it, nb); }
-inline int Remove (int (*p) (ITEM*), int nb = 1) { return CcuList::Remove ((int (*) (void*)) p, nb); }
-
-inline CcuListIndex InsertAfter (const CcuListIterOf <ITEM>& li, ITEM*it) { return CcuList::InsertAfter (li, it); }
-inline CcuListIndex InsertBefore (const CcuListIterOf <ITEM>& li, ITEM* it) { return CcuList::InsertBefore (li, it); }
-inline ITEM* RemoveAfter (const CcuListIterOf <ITEM>& li) { return (ITEM*) CcuList::RemoveAfter (li); }
+inline IvlListOf () : IvlList () {}
+inline IvlListOf (ITEM* it) : IvlList (it) {}
+inline ITEM* First () { return (ITEM*) (IvlList::First ()); }
+inline ITEM* Last () { return (ITEM*) (IvlList::Last ()); }
+inline ITEM* Nth (int n) { return (ITEM*) (IvlList::Nth (n)); }
+inline int Find (ITEM* it, int* r = 0) const { return IvlList::Find (it, r); }
+
+inline IvlListIndex Append (ITEM* it) { return IvlList::Append (it); }
+inline IvlListIndex Prepend (ITEM* it) { return IvlList::Prepend (it); }
+inline IvlListOf<ITEM>& operator << (ITEM* it) { IvlList::Append (it); return *this; }
+
+inline ITEM* RemoveFirst () { return (ITEM*) (IvlList::RemoveFirst ()); }
+inline ITEM* RemoveLast () { return (ITEM*) (IvlList::RemoveLast ()); }
+inline int Remove (ITEM* it, int nb = 1) { return IvlList::Remove (it, nb); }
+inline int Remove (int (*p) (ITEM*), int nb = 1) { return IvlList::Remove ((int (*) (void*)) p, nb); }
+
+inline IvlListIndex InsertAfter (const IvlListIterOf <ITEM>& li, ITEM*it) { return IvlList::InsertAfter (li, it); }
+inline IvlListIndex InsertBefore (const IvlListIterOf <ITEM>& li, ITEM* it) { return IvlList::InsertBefore (li, it); }
+inline ITEM* RemoveAfter (const IvlListIterOf <ITEM>& li) { return (ITEM*) IvlList::RemoveAfter (li); }
};
-template <class ITEM> class CcuListIterOf : public CcuListIter {
+template <class ITEM> class IvlListIterOf : public IvlListIter {
public:
-inline CcuListIterOf (const CcuListOf <ITEM>& l) : CcuListIter (l) { }
-inline CcuListIterOf<ITEM>& operator = (const CcuListOf <ITEM>& l) { return (CcuListIterOf <ITEM>&) CcuListIter::operator = (l); }
-inline CcuListIterOf<ITEM>& operator = (const CcuListIterOf <ITEM>& li) { return (CcuListIterOf <ITEM>&) CcuListIter::operator = (li); }
-inline CcuListIterOf<ITEM>& operator ++ () { return (CcuListIterOf <ITEM>&) CcuListIter::operator ++ (); }
-inline ITEM* operator * () const { return (ITEM*) CcuListIter::operator * (); }
-inline int Find (ITEM* it) { return CcuListIter::Find (it); }
+inline IvlListIterOf (const IvlListOf <ITEM>& l) : IvlListIter (l) { }
+inline IvlListIterOf<ITEM>& operator = (const IvlListOf <ITEM>& l) { return (IvlListIterOf <ITEM>&) IvlListIter::operator = (l); }
+inline IvlListIterOf<ITEM>& operator = (const IvlListIterOf <ITEM>& li) { return (IvlListIterOf <ITEM>&) IvlListIter::operator = (li); }
+inline IvlListIterOf<ITEM>& operator ++ () { return (IvlListIterOf <ITEM>&) IvlListIter::operator ++ (); }
+inline ITEM* operator * () const { return (ITEM*) IvlListIter::operator * (); }
+inline int Find (ITEM* it) { return IvlListIter::Find (it); }
};
#endif /* CPLUS_BUG19 */
-typedef CcuListItem CcuStackItem;
+typedef IvlListItem IvlStackItem;
/* CPLUS_BUG10 */
-class CcuStack : _private CcuList {
+class IvlStack : _private IvlList {
public:
- CcuList :: Clear;
- CcuList :: IsEmpty;
- CcuList :: GetStatus;
-inline void Push (CcuStackItem* p) { Prepend (p); }
-inline CcuStackItem* Pop () { return RemoveFirst (); }
-inline CcuStackItem* Top () { return First (); }
+ IvlList :: Clear;
+ IvlList :: IsEmpty;
+ IvlList :: GetStatus;
+inline void Push (IvlStackItem* p) { Prepend (p); }
+inline IvlStackItem* Pop () { return RemoveFirst (); }
+inline IvlStackItem* Top () { return First (); }
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuStackOf : public CcuStack {
+template <class ITEM> class IvlStackOf : public IvlStack {
public:
-inline void Push (ITEM* p) { CcuStack::Push (p); }
-inline ITEM* Pop () { return (ITEM*) CcuStack::Pop (); }
-inline ITEM* Top () { return (ITEM*) CcuStack::Top (); }
-inline operator const CcuListOf <ITEM>& () { return *(CcuListOf <ITEM>*) this; }
+inline void Push (ITEM* p) { IvlStack::Push (p); }
+inline ITEM* Pop () { return (ITEM*) IvlStack::Pop (); }
+inline ITEM* Top () { return (ITEM*) IvlStack::Top (); }
+inline operator const IvlListOf <ITEM>& () { return *(IvlListOf <ITEM>*) this; }
};
#endif /* CPLUS_BUG19 */
-typedef CcuListItem CcuQueueItem;
+typedef IvlListItem IvlQueueItem;
+#if 0
/* CPLUS_BUG10 */
-class CcuQueue : _private CcuList {
+class IvlQueue : _private IvlList {
public:
- CcuList :: Clear;
- CcuList :: IsEmpty;
- CcuList :: GetStatus;
-inline void Put (CcuQueueItem* p) { Append (p); }
-inline CcuQueueItem* Get () { return RemoveFirst (); }
-inline operator const CcuList& () { return *this; }
+ IvlList :: Clear;
+ IvlList :: IsEmpty;
+ IvlList :: GetStatus;
+inline void Put (IvlQueueItem* p) { Append (p); }
+inline IvlQueueItem* Get () { return RemoveFirst (); }
+inline operator const IvlList& () { return *this; }
};
#ifndef CPLUS_BUG19
-template <class ITEM> class CcuQueueOf : public CcuQueue {
+template <class ITEM> class IvlQueueOf : public IvlQueue {
public:
-inline void Put (ITEM* p) { CcuQueue::Put (p); }
-inline ITEM* Get () { return (ITEM*) CcuQueue::Get (); }
-inline operator const CcuListOf <ITEM>& () { return *(CcuListOf <ITEM>*) this; }
+inline void Put (ITEM* p) { IvlQueue::Put (p); }
+inline ITEM* Get () { return (ITEM*) IvlQueue::Get (); }
+inline operator const IvlListOf <ITEM>& () { return *(IvlListOf <ITEM>*) this; }
};
#endif /* CPLUS_BUG19 */
+#endif /* 0 */
+
#endif /* List_H_ */
diff --git a/utils/Makefile b/utils/Makefile
new file mode 100755
index 0000000..d82f9fb
--- /dev/null
+++ b/utils/Makefile
@@ -0,0 +1,179 @@
+#
+# Ivy League Utilities
+#
+# by Stephane Chatty
+#
+# Copyright 1991-2000
+# Laboratoire de Recherche en Informatique (LRI)
+# Centre d'Etudes de la Navigation Aerienne (CENA)
+#
+# Makefile
+#
+# $Id$
+# $CurLog$
+#
+
+MAJOR = 1
+MINOR = 0
+LOCINCL = ../include
+CXX = g++
+CXXOPTIONS = -O2
+CXXSUFFIX = cc
+
+
+CXXFLAGS = $(CXXOPTIONS) -I$(LOCINCL)
+
+OBJ = Allocator.o List.o DList.o Chain.o String.o Array.o \
+ HashTable.o IdTable.o DirPath.o RegExp.o \
+ Signal.o Time.o Timer.o Automaton.o BitField.o
+
+cc = $(CXXSUFFIX)
+SRC = Allocator.$(cc) List.$(cc) DList.$(cc) String.$(cc) Array.$(cc) \
+ HashTable.$(cc) DirPath.$(cc) IdTable.$(cc) RegExp.$(cc) \
+ Signal.$(cc) Time.$(cc) Timer.$(cc) Automaton.$(cc) BitField.$(cc)
+
+HDR = bool.h word.h Initializer.h Allocator.h List.h DList.h Chain.h String.h \
+ Array.h HashTable.h IdTable.h DirPath.h RegExp.h \
+ Signal.h Time.h Timer.h Automaton.h BitField.h
+
+TESTS = testchain testdlist testid testregexp testtimer testdirpath testhash testlist testsignal
+
+
+all: libIvlUtils.a libIvlUtils.so.$(MAJOR).$(MINOR) headers
+
+test: $(TESTS)
+
+libIvlUtils.a: $(OBJ)
+ rm -f $@
+ ar q $@ $(OBJ)
+
+libIvlUtils.so.$(MAJOR).$(MINOR): $(OBJ)
+ rm -f $@
+ $(CXX) -shared -Wl,-soname,libIvlUtils.so.$(MAJOR) -o $@ $(OBJ) -lc
+
+
+headers: incldir \
+ $(LOCINCL)/ivl/cplus_bugs.h \
+ $(LOCINCL)/ivl/bool.h \
+ $(LOCINCL)/ivl/word.h \
+ $(LOCINCL)/ivl/Initializer.h \
+ $(LOCINCL)/ivl/Allocator.h \
+ $(LOCINCL)/ivl/List.h \
+ $(LOCINCL)/ivl/DList.h \
+ $(LOCINCL)/ivl/Chain.h \
+ $(LOCINCL)/ivl/String.h \
+ $(LOCINCL)/ivl/Array.h \
+ $(LOCINCL)/ivl/HashTable.h \
+ $(LOCINCL)/ivl/IdTable.h \
+ $(LOCINCL)/ivl/DirPath.h \
+ $(LOCINCL)/ivl/RegExp.h \
+ $(LOCINCL)/ivl/Signal.h \
+ $(LOCINCL)/ivl/Time.h \
+ $(LOCINCL)/ivl/Timer.h \
+ $(LOCINCL)/ivl/Automaton.h \
+ $(LOCINCL)/ivl/BitField.h
+
+incldir:
+ test -d $(LOCINCL)/ivl || mkdirhier $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/cplus_bugs.h: cplus_bugs.h
+ cp cplus_bugs.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/bool.h: bool.h
+ cp bool.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/word.h: word.h
+ cp word.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Initializer.h: Initializer.h
+ cp Initializer.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Allocator.h: Allocator.h
+ cp Allocator.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/List.h: List.h
+ cp List.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/DList.h: DList.h
+ cp DList.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Chain.h: Chain.h
+ cp Chain.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/String.h: String.h
+ cp String.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Array.h: Array.h
+ cp Array.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/HashTable.h: HashTable.h
+ cp HashTable.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/IdTable.h: IdTable.h
+ cp IdTable.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/DirPath.h: DirPath.h
+ cp DirPath.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/RegExp.h: RegExp.h
+ cp RegExp.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Signal.h: Signal.h
+ cp Signal.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Time.h: Time.h
+ cp Time.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Timer.h: Timer.h
+ cp Timer.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Automaton.h: Automaton.h
+ cp Automaton.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/BitField.h: BitField.h
+ cp BitField.h $(LOCINCL)/ivl
+
+install: all
+ test -d $(PREFIX)/usr/include/ivl || mkdirhier $(PREFIX)/usr/include/ivl
+ for f in `find $(LOCINCL)/ivl/*.h -type f -maxdepth 1`; do \
+ install -m 644 $$f $(PREFIX)/usr/include/ivl; \
+ done
+ test -d $(PREFIX)/usr/lib || mkdirhier $(PREFIX)/usr/lib
+ install -m 644 libIvlUtils.a $(PREFIX)/usr/lib
+ install -m 644 libIvlUtils.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
+ ln -s /usr/lib/libIvlUtils.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libIvlUtils.so.$(MAJOR)
+ ln -s /usr/lib/libIvlUtils.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libIvlUtils.so
+
+
+
+clean:
+ rm -f *.o libIvlUtils.a libIvlUtils.so.$(MAJOR).$(MINOR) $(TESTS)
+
+
+testchain: testchain.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testdirpath: testdirpath.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testdlist: testdlist.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testhash: testhash.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testid: testid.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testlist: testlist.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testregexp: testregexp.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testsignal: testsignal.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
+testtimer: testtimer.$(cc) $(SRC) libIvlUtils.a
+ $(CXX) -o $@ $@.$(cc) -L. -lIvlUtils
+
diff --git a/utils/RegExp.cc b/utils/RegExp.cc
index 82e5dab..994b8d7 100644
--- a/utils/RegExp.cc
+++ b/utils/RegExp.cc
@@ -15,24 +15,23 @@
#include "RegExp.h"
-/*?class CcuRegExp
-The class \typ{CcuRegExp} was designed to encapsulate regular expression management,
+/*?class IvlRegExp
+The class \typ{IvlRegExp} was designed to encapsulate regular expression management,
implemented by \fun{re\_comp} and \fun{re\_exec}, or \fun{regcmp} and \fun{regex},
depending on the operating system. The standard usage consists in initializing
-a \typ{CcuRegExp}, then compiling it, and finally match strings against it.
+a \typ{IvlRegExp}, then compiling it, and finally match strings against it.
?*/
#ifdef DOC
/*?
-Initialize a \typ{CcuRegExp} with expression \var{expr}. The string \var{epxr}
+Initialize a \typ{IvlRegExp} with expression \var{expr}. The string \var{epxr}
is {\em not} copied.
?*/
-CcuRegExp :: CcuRegExp (const char* expr)
+IvlRegExp :: IvlRegExp (const char* expr)
{
}
#endif
-
#ifdef REGCOMP
#include <regex.h>
#include <memory.h>
@@ -43,7 +42,7 @@ Compile a regular expression before using it. This function returns false upon f
true upon success.
?*/
bool
-CcuRegExp :: Compile ()
+IvlRegExp :: Compile ()
{
struct regex_t tmp;
if (regcomp (&tmp, String, REG_NOSUB) == 0) {
@@ -59,7 +58,7 @@ Match a string against a regular expression. This function returns false upon fa
true upon success.
?*/
bool
-CcuRegExp :: Match (const char* s)
+IvlRegExp :: Match (const char* s)
{
if (Compiled)
return regexec ((struct regex_t*) Compiled, s, 0, 0, 0) == 0 ? true : false;
@@ -68,7 +67,7 @@ CcuRegExp :: Match (const char* s)
}
/*?nodoc?*/
-CcuRegExp :: ~CcuRegExp ()
+IvlRegExp :: ~IvlRegExp ()
{
if (Compiled) {
regfree ((struct regex_t*) Compiled);
@@ -78,7 +77,6 @@ CcuRegExp :: ~CcuRegExp ()
#endif
-
#ifdef RE_COMP
extern "C" {
@@ -87,12 +85,11 @@ extern "C" {
}
/* should be #include <regcmp.h>, but not available everywhere ... */
-
-CcuRegExp* CcuRegExp::Compiled = 0;
+IvlRegExp* IvlRegExp::Compiled = 0;
/*?nodoc?*/
bool
-CcuRegExp :: Compile ()
+IvlRegExp :: Compile ()
{
if (re_comp (String) != 0) {
Compiled = 0;
@@ -105,7 +102,7 @@ CcuRegExp :: Compile ()
/*?nodoc?*/
bool
-CcuRegExp :: Match (const char* s)
+IvlRegExp :: Match (const char* s)
{
if (Compiled != this)
if (!Compile ())
@@ -134,7 +131,7 @@ Compile a regular expression before using it. This function returns false upon f
true upon success.
?*/
bool
-CcuRegExp :: Compile ()
+IvlRegExp :: Compile ()
{
Compiled = regcmp (String, 0);
return Compiled ? true : false;
@@ -145,7 +142,7 @@ Match a string against a regular expression. This function returns false upon fa
true upon success.
?*/
bool
-CcuRegExp :: Match (const char* s)
+IvlRegExp :: Match (const char* s)
{
if (Compiled)
return regex (Compiled, s) ? true : false;
@@ -154,7 +151,7 @@ CcuRegExp :: Match (const char* s)
}
/*?nodoc?*/
-CcuRegExp :: ~CcuRegExp ()
+IvlRegExp :: ~IvlRegExp ()
{
if (Compiled)
free (Compiled);
diff --git a/utils/RegExp.h b/utils/RegExp.h
index ac1321d..189d5ad 100644
--- a/utils/RegExp.h
+++ b/utils/RegExp.h
@@ -31,13 +31,13 @@
/* POSIX version of regular expressions */
-class CcuRegExp {
+class IvlRegExp {
private:
const char* String;
void* Compiled;
public:
-inline CcuRegExp (const char* s) : String (s), Compiled (0) {}
- ~CcuRegExp ();
+inline IvlRegExp (const char* s) : String (s), Compiled (0) {}
+ ~IvlRegExp ();
bool Compile ();
bool Match (const char*);
inline const char* GetExpr () {return String;}
@@ -47,14 +47,14 @@ inline const char* GetExpr () {return String;}
#ifdef RE_COMP
-class CcuRegExp {
+class IvlRegExp {
private:
const char* String;
-static CcuRegExp* Compiled;
+static IvlRegExp* Compiled;
public:
-inline CcuRegExp (const char* s) : String (s) {}
-inline ~CcuRegExp () {};
+inline IvlRegExp (const char* s) : String (s) {}
+inline ~IvlRegExp () {};
bool Compile ();
bool Match (const char*);
inline const char* GetExpr () {return String;}
@@ -64,14 +64,14 @@ inline const char* GetExpr () {return String;}
#if !defined(REGCOMP) && !defined(RE_COMP)
-class CcuRegExp {
+class IvlRegExp {
private:
const char* String;
char* Compiled;
public:
-inline CcuRegExp (const char* s) : String (s), Compiled (0) {}
- ~CcuRegExp ();
+inline IvlRegExp (const char* s) : String (s), Compiled (0) {}
+ ~IvlRegExp ();
bool Compile ();
bool Match (const char*);
inline const char* GetExpr () { return String; }
diff --git a/utils/Signal.cc b/utils/Signal.cc
index d03ff65..c15167e 100644
--- a/utils/Signal.cc
+++ b/utils/Signal.cc
@@ -78,10 +78,9 @@ extern "C" {
#include <signal.h>
#endif
-
-/*?class CcuBaseSignalHandler
-The class \typ{CcuBaseSignalHandler} is provided as a base class for signal handlers.
-It comes with a derived class \typ{CcuSignalHandler} that can be used as is, without
+/*?class IvlBaseSignalHandler
+The class \typ{IvlBaseSignalHandler} is provided as a base class for signal handlers.
+It comes with a derived class \typ{IvlSignalHandler} that can be used as is, without
any derivation.
A signal handler is created for a specific signal, identified by a numeric value.
The following constants are defined: \var{AllSigs, SigHup, SigInt, SigQuit, SigIll, SigTrap,
@@ -91,7 +90,7 @@ and \var{SigLost}. The value \var{AllSigs} is not meaningful to signal handlers.
When a signal is received by the program and a signal handler was created for that
signal, its method \fun{Handle} is called. This method should be redefined in derived
-classes of \var{CcuBaseSignalHandler}.
+classes of \var{IvlBaseSignalHandler}.
Several signal handlers can be created for the same signal. However, only one is
active at a time. A stack of signal handlers is maintained for every signal, so that
@@ -136,22 +135,22 @@ const int SigUrg = SIGURG;
const int SigLost = SIGLOST;
#endif
-CcuList* CcuBaseSignalHandler::HandlerStacks = 0;
+IvlList* IvlBaseSignalHandler::HandlerStacks = 0;
/*?hidden?*/
void
-CcuBaseSignalHandler :: ClassInit ()
+IvlBaseSignalHandler :: ClassInit ()
{
- HandlerStacks = new CcuList [NumSigs];
+ HandlerStacks = new IvlList [NumSigs];
}
/*?
Create a signal handler for the signal \var{sig}.
?*/
-CcuBaseSignalHandler :: CcuBaseSignalHandler (int sig)
+IvlBaseSignalHandler :: IvlBaseSignalHandler (int sig)
: Signal (sig)
{
- CcuSignalBlocker b (sig);
+ IvlSignalBlocker b (sig);
if (!HandlerStacks)
ClassInit ();
HandlerStacks [Signal-1].Prepend (this);
@@ -159,16 +158,16 @@ CcuBaseSignalHandler :: CcuBaseSignalHandler (int sig)
}
/*?nodoc?*/
-CcuBaseSignalHandler :: ~CcuBaseSignalHandler ()
+IvlBaseSignalHandler :: ~IvlBaseSignalHandler ()
{
- CcuSignalBlocker b (Signal);
- CcuList& stack = HandlerStacks [Signal-1];
+ IvlSignalBlocker b (Signal);
+ IvlList& stack = HandlerStacks [Signal-1];
if (stack.First () == this) {
stack.RemoveFirst ();
if (stack.IsEmpty ())
InstallNone (Signal);
else
- ((CcuBaseSignalHandler*) stack.First ())->Install ();
+ ((IvlBaseSignalHandler*) stack.First ())->Install ();
} else
stack.Remove (this, 1);
}
@@ -178,14 +177,14 @@ CcuBaseSignalHandler :: ~CcuBaseSignalHandler ()
Get the signal that is handled by this signal handler.
?*/
int
-CcuBaseSignalHandler :: GetSignal ()
+IvlBaseSignalHandler :: GetSignal ()
{
}
#endif /* DOC */
/*?hidden?*/
void
-CcuBaseSignalHandler :: Install ()
+IvlBaseSignalHandler :: Install ()
{
struct sigaction act;
#ifdef __sgi
@@ -200,7 +199,7 @@ CcuBaseSignalHandler :: Install ()
/*?hidden?*/
void
-CcuBaseSignalHandler :: InstallNone (int sig)
+IvlBaseSignalHandler :: InstallNone (int sig)
{
struct sigaction act;
act.sa_handler = SIG_DFL;
@@ -211,9 +210,9 @@ CcuBaseSignalHandler :: InstallNone (int sig)
/*?hidden?*/
void
-CcuBaseSignalHandler :: DoHandle (int sig)
+IvlBaseSignalHandler :: DoHandle (int sig)
{
- CcuBaseSignalHandler* s = (CcuBaseSignalHandler*) HandlerStacks [sig-1].First ();
+ IvlBaseSignalHandler* s = (IvlBaseSignalHandler*) HandlerStacks [sig-1].First ();
if (s)
s->Handle ();
}
@@ -223,14 +222,14 @@ This virtual function should be redefined in derived classes. It is called
when this handler is the currently active one and a signal is received.
?*/
void
-CcuBaseSignalHandler :: Handle ()
+IvlBaseSignalHandler :: Handle ()
{
}
-/*?class CcuSignalHandler
-The class \typ{CcuSignalHandler} is a derived class of \typ{CcuBaseSignalHandler} that
+/*?class IvlSignalHandler
+The class \typ{IvlSignalHandler} is a derived class of \typ{IvlBaseSignalHandler} that
can be used without deriving a new class.
-Each \typ{CcuSignalHandler} holds a pointer to a function which is called when a
+Each \typ{IvlSignalHandler} holds a pointer to a function which is called when a
signal is received. This function, which is passed to the constructor, must
take an \typ{int} argument and return \typ{void}.
?*/
@@ -239,27 +238,27 @@ take an \typ{int} argument and return \typ{void}.
Create a signal handler for signal \var{sig}. The function \var{handler} will be
called when a signal is received.
?*/
-CcuSignalHandler :: CcuSignalHandler (int sig, void (*handler) (int))
-: CcuBaseSignalHandler (sig),
+IvlSignalHandler :: IvlSignalHandler (int sig, void (*handler) (int))
+: IvlBaseSignalHandler (sig),
Handler (handler)
{
}
/*?nodoc?*/
-CcuSignalHandler :: ~CcuSignalHandler ()
+IvlSignalHandler :: ~IvlSignalHandler ()
{
}
/*?hidden?*/
void
-CcuSignalHandler :: Handle ()
+IvlSignalHandler :: Handle ()
{
(*Handler) (Signal);
}
-/*?class CcuSignalBlocker
-The class \typ{CcuSignalBlocker} provides protection against signals.
-When a \typ{CcuSignalBlocker} is created for a signal type, the program will
+/*?class IvlSignalBlocker
+The class \typ{IvlSignalBlocker} provides protection against signals.
+When a \typ{IvlSignalBlocker} is created for a signal type, the program will
be protected against such signals during the lifetime of the signal blocker.
Signal blockers are often used as follows:
\begin{ccode}
@@ -267,7 +266,7 @@ Signal blockers are often used as follows:
sensitive_function ()
{
// protect this function against alarms
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
...
}
\end{ccode}
@@ -280,14 +279,13 @@ However, the special value \var{AllSigs} allows the creation of signal blockers
that protect against all kinds of signals.
?*/
-int CcuSignalBlocker::BlockCounts [NumSigs];
-
+int IvlSignalBlocker::BlockCounts [NumSigs];
/*?
Create a signal blocker for the signal \var{sig}. If \var{sig} is \var{AllSigs},
all signals will be blocked.
?*/
-CcuSignalBlocker :: CcuSignalBlocker (int sig)
+IvlSignalBlocker :: IvlSignalBlocker (int sig)
: Signal (sig)
{
int all = sig < 1 || sig > NumSigs;
@@ -311,7 +309,7 @@ CcuSignalBlocker :: CcuSignalBlocker (int sig)
}
/*?nodoc?*/
-CcuSignalBlocker :: ~CcuSignalBlocker ()
+IvlSignalBlocker :: ~IvlSignalBlocker ()
{
int all = Signal < 1 || Signal > NumSigs;
int change = 0;
diff --git a/utils/Signal.h b/utils/Signal.h
index 7daf114..d27bcb5 100644
--- a/utils/Signal.h
+++ b/utils/Signal.h
@@ -16,7 +16,7 @@
#define Signal_H_
#include "cplus_bugs.h"
-class CcuList;
+class IvlList;
#ifdef CPLUS_BUG21
#ifdef sun
@@ -26,9 +26,9 @@ class CcuList;
#endif
#endif
-class CcuBaseSignalHandler {
+class IvlBaseSignalHandler {
private:
-static CcuList* HandlerStacks;
+static IvlList* HandlerStacks;
static void ClassInit ();
void Install ();
static void InstallNone (int);
@@ -38,8 +38,8 @@ protected:
int Signal;
public:
- CcuBaseSignalHandler (int);
-virtual ~CcuBaseSignalHandler ();
+ IvlBaseSignalHandler (int);
+virtual ~IvlBaseSignalHandler ();
inline int GetSignal () const { return Signal; }
protected:
@@ -52,17 +52,17 @@ extern const int AllSigs, SigHup, SigInt, SigQuit, SigIll, SigTrap, SigAbrt, Sig
SigUsr2, SigChld, SigVtalrm, SigIo, SigStop,
SigTstp, SigCont, SigTtin, SigTtou, SigUrg, SigLost;
-class CcuSignalHandler : public CcuBaseSignalHandler {
+class IvlSignalHandler : public IvlBaseSignalHandler {
protected:
void (*Handler) (int);
void Handle ();
public:
- CcuSignalHandler (int, void (*) (int));
- ~CcuSignalHandler ();
+ IvlSignalHandler (int, void (*) (int));
+ ~IvlSignalHandler ();
};
-class CcuSignalBlocker {
+class IvlSignalBlocker {
private:
#ifndef CPLUS_BUG21
static int BlockCounts [];
@@ -72,8 +72,8 @@ static int BlockCounts [NSIG-1];
protected:
int Signal:6;
public:
- CcuSignalBlocker (int);
- ~CcuSignalBlocker ();
+ IvlSignalBlocker (int);
+ ~IvlSignalBlocker ();
};
#endif /* Signal_H_ */
diff --git a/utils/SmartPointer.cc b/utils/SmartPointer.cc
deleted file mode 100644
index 50343df..0000000
--- a/utils/SmartPointer.cc
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * CENA C++ Utilities
- *
- * by Stephane Chatty
- *
- * Copyright 1990-1995
- * Laboratoire de Recherche en Informatique (LRI)
- * Centre d'Etudes de la Navigation Aerienne (CENA)
- *
- * smart pointers, originally by Michel Beaudouin-Lafon
- *
- * $Id$
- * $CurLog$
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef __GNUG__
-#pragma implementation "SmartPointer.h"
-#endif
-#include "SmartPointer.h"
-#include "List.h"
-
-CcuSmartData::check_type CcuSmartData::check = doWarn;
-#ifdef OLD
-int CcuSmartData::NextCreatedIsDynamic = 0;
-#else
-CcuList* CcuSmartData::LastDynamics;
-#endif
-
-/*?class CcuSmartData
-The class \typ{CcuSmartData} is the base class for objects that you want to reference through smart pointers.
-Such an object contains a reference count.
-This reference count contains the number of smart pointers to this object.
-When that number reaches 0 and the object was allocated dynamically, it is safe to destroy it
-(unless there are still plain pointers to it!).
-Hence, a \typ{CcuSmartData} destroys itself when its reference count reaches 0
-and it was allocated dynamically (ie. with \fun{operator new}).
-
-To implement the reference counting properly, it is necessary to overload the assignment operator on
-the reference count, so that when object \var{a} is assigned to object \var{b},
-the reference count of \var{b} does not change.
-This means that all classes deriving from \typ{CcuSmartData} will have their assignment operator implicitly redefined.
-This implies a small run-time overhead, and a special care if you need to overload this operator
-in a derived class of \typ{CcuSmartData}.
-
-Another point needs special attention. The only way of deciding whether an object was dynamically
-allocated is to redefine \fun{operator new}. This was done in \typ{CcuSmartData}. However, you might
-want to define your own \fun{new} and \fun{delete} in derived classes. If you do so, you
-should take care that \fun{new} sets the flag \var{CcuSmartData::NextCreatedIsDynamic} to a non-null value.
-?*/
-
-/*!
-One big problem with smart pointers lies in making a distinction between
-objects created in the stack (that we should not delete) and objects created
-dynamically, that we should delete when no more referenced. There's no way
-to make that distinction in constructors, sowe try to use operator new. This
-works well only if the constructor is called right after operator new, which is not
-always the case...
-!*/
-void*
-CcuSmartData :: operator new (size_t size)
-{
-#ifdef OLD
- NextCreatedIsDynamic = 1;
- return ::operator new (size);
-#else
- int sz = (int) size;
- void* p = ::operator new (sz);
- if (!LastDynamics)
- LastDynamics = new CcuList;
- LastDynamics->Prepend (p);
- return p;
-#endif
-
-}
-
-/*?
-Create a data, ie. initialize its reference count to 0.
-?*/
-CcuSmartData :: CcuSmartData ()
-#ifdef OLD
-: State (NextCreatedIsDynamic ? 0 : 1)
-#else
-: State (1)
-#endif
-{
-#ifdef OLD
- NextCreatedIsDynamic = 0;
-#else
- if (LastDynamics && LastDynamics->Remove (this))
- State = 0;
-#endif
-}
-
-/*?
-This is the copy constructor for the class \typ{CcuSmartData}.
-Because there is a copy constructor defined,
-all derived class will have a copy constructor defined implicitly,
-unless you specify one explicitely.
-?*/
-CcuSmartData :: CcuSmartData (const CcuSmartData&)
-#ifdef OLD
-: State (NextCreatedIsDynamic ? 0 : 1)
-#else
-: State (1)
-#endif
-{
-#ifdef OLD
- NextCreatedIsDynamic = 0;
-#else
- if (LastDynamics && LastDynamics->Remove (this))
- State = 0;
-#endif
-}
-
-/*?
-This is the destructor for class \typ{CcuSmartData}. It is {\em virtual}.
-This destructor checks that the deleted object has a null reference count.
-If not, it notifies the user according to the sanity check value defined with
-the static member function \fun{SetCheck}.
-Dynamically allocated \typ{CcuSmartData} objects are automatically deleted by the smart pointer package
-when their reference count reaches zero.
-?*/
-CcuSmartData :: ~CcuSmartData ()
-{
- if (State > 1) {
- if (check >= doOnlyDynamic) {
- if (IsDynamic ())
- fprintf (stderr, "*** ~CcuSmartData (0x%x) : ref count of dynamic object is %d !\n", this, int (State/2));
- else if (check >= doWarn)
- fprintf (stderr, "*** ~CcuSmartData (0x%x) : ref count of global or automatic object is %d !\n", this, int (State/2));
- }
- if (check == doAbort) {
- fprintf (stderr, "*** aborting\n");
- abort ();
- }
- }
-}
-
-
-void
-CcuSmartData :: DecrRef ()
-{
- State -=2;
- if (State == 0)
- delete this;
-}
-
-#ifdef DOC
-/*?
-This protected member returns 1 if this object was allocated with \fun{operator new}.
-?*/
-int
-CcuSmartData :: IsDynamic () const
-{
-}
-#endif
-
-
-/*?
-This {\em static} member controls the sanity check done by the destructor of class \typ{CcuSmartData}:
-a \typ{CcuSmartData} should not be destroyed when its refcount is non zero, because this means
-that some smart pointers are still pointing at it.
-Such errors can happen in two situations:\\
- \hspace*{0.5cm}1. when calling explicitely \fun{operator delete} on an object that has smart pointers to it;\\
- \hspace*{0.5cm}2. when a local object (an object on the stack) that has smart pointers to it is automatically
-destroyed upon exit of its enclosing block.\\
-\vspace{0.5ex}
-When an error occurs, the value of \var{chk} defines what happens, as follows:\\
- \hspace*{0.5cm}$\bullet$ if \var{t} is \var{doWarn}, a message is issued on \var{stderr} and processing continues;\\
- \hspace*{0.5cm}$\bullet$ if \var{t} is \var{doAbort}, a message is issued and and \fun{abort} is called, forcing a core dump;\\
-but not for dynamically allocated objects.\\
- \hspace*{0.5cm}$\bullet$ if \var{t} is \var{doOnlyDynamic}, checking is disabled for global and automatic objects,
- \hspace*{0.5cm}$\bullet$ if \var{t} is \var{doNoCheck}, checking is disabled.\\
-\fun{SetCheck} returns the previous value of the checking status.
-The initial value is 0 (warning message).
-?*/
-CcuSmartData::check_type
-CcuSmartData :: SetCheck (check_type t)
-{
- check_type old = check;
- check = t;
- return old;
-}
-
-/*?class CcuSmartPointerTo
-The class \typ{CcuSmartPointerTo} is the smart pointer class itself.
-A \typ{CcuSmartPointerTo} object contains a pointer to a \typ{DATA} object.
-?*/
-
-#ifdef DOC
-
-/*?
-Construct a null smart pointer.
-?*/
-CcuSmartPointerTo :: CcuSmartPointerTo ()
-{
-}
-
-/*?
-Construct a smart pointer to data \var{d}.
-\var{d} may be 0.
-?*/
-CcuSmartPointerTo :: CcuSmartPointerTo (DATA* d)
-{
-}
-
-/*?
-This is the copy constructor for smart pointers.
-It ensures that the reference counts are properly updated when a smart pointer
-is initialized by copy (argument passing and function return for instance).
-?*/
-CcuSmartPointerTo :: CcuSmartPointerTo (const CcuSmartPointerTo& p)
-{
-}
-
-/*?
-The destructor updates the reference count of the pointed to data,
-and destroys it if the reference count reaches 0 and the data was dynamically allocated.
-?*/
-CcuSmartPointerTo :: ~CcuSmartPointerTo ()
-{
-}
-
-/*?
-This operator overloads the assignment of smart pointers.
-It can destroy the data pointed by the left-hand side pointer if its reference count reaches 0.
-?*/
-CcuSmartPointerTo&
-CcuSmartPointerTo :: operator = (const DATA* d)
-{
-}
-
-/*?
-This operator overloads the dereferencing of smart pointers.
-Unfortunately, it returns a \typ{DATA*} where one would prefer a pointer to a derived class of \typ{DATA}.
-This problem, which occurs also with the overloading operators below,
-is fixed by the generic pointer class (\fun{PointerClass}) described below.
-?*/
-DATA*
-CcuSmartPointerTo :: operator -> ()
-{
-}
-
-/*?
-These conversion operators make it possible to pass a pointer to data where a smart pointer is expected.
-They also make it possible to test a smart pointer like a usual pointer.
-?*/
-CcuSmartPointerTo :: operator DATA* ()
-{
-}
-
-// note: this is hacked up for the doc stuff
-/*?
-This is a macro to generate a smart pointer class.
-\typ{SmartClass} is the name of the class to generate,
-and \typ{DataClass} is the name of the class to which \typ{SmartClass} objects will point.
-\typ{DataClass} must derive from \typ{DATA}.
-The generated class is similar to the class \typ{CcuSmartPointerTo} described above,
-with \typ{CcuSmartPointerTo} replaced by \typ{SmartClass} and \typ{DATA} replaced by \typ{DataClass}.
-In particular, this means that such smart pointers can be dereferenced with the \fun{operator ->}
-like usual pointers.
-?*/
-generic
-PointerClass (SmartClass, DataClass)
-{
-}
-
-/*?
-This macro is similar to \fun{PointerClass} described above.
-It generates a smart pointer class named \typ{SmartClass}
-for the class \typ{DataClass}.
-Unlike the previous macro, the generated class is not a base class,
-but instead a derived class of \typ{SmartBaseClass},
-which must be a smart pointer class itself.
-If \typ{pA} is a smart pointer class to class \typ{A} and \typ{B} derives from \typ{A},
-you can declare a smart pointer class \typ{pB} to the class \typ{B} with:\\
-\hspace*{1cm}\com{DerivedPointerClass (pB, pA, A)}\\
-Then \typ{pB} objects can be used where \typ{pA} objects are expected,
-which would not be the case if \typ{pB} was declared with \fun{PointerClass}.
-?*/
-generic
-DerivedPointerClass (SmartClass, BaseSmartClass, DataClass)
-{
-}
-
-#endif
-
diff --git a/utils/SmartPointer.h b/utils/SmartPointer.h
deleted file mode 100644
index b1b5003..0000000
--- a/utils/SmartPointer.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * CENA C++ Utilities
- *
- * by Stephane Chatty
- *
- * Copyright 1990-1995
- * Laboratoire de Recherche en Informatique (LRI)
- * Centre d'Etudes de la Navigation Aerienne (CENA)
- *
- * smart pointers, originally by Michel Beaudouin-Lafon
- *
- * $Id$
- * $CurLog$
- */
-
-#ifndef SmartPointer_H_
-#define SmartPointer_H_
-
-#include "cplus_bugs.h"
-#include <sys/types.h>
-
-class CcuList;
-
-class CcuSmartData {
-public:
- enum check_type { doNoCheck, doOnlyDynamic, doWarn, doAbort };
-private:
-static check_type check;
-
- int State;
-inline int IsDynamic () const { return !(State & 1); }
-
-protected:
-#ifdef OLD
-static int NextCreatedIsDynamic;
-#else
-static CcuList* LastDynamics;
-#endif
-
-public:
- void* operator new (size_t);
-inline void operator delete (void* that) { ::delete (that); }
-
- CcuSmartData ();
- CcuSmartData (const CcuSmartData&);
-virtual ~CcuSmartData ();
-
-static check_type SetCheck (check_type);
-
- void DecrRef ();
-inline void IncrRef () { State += 2; }
-};
-
-#ifndef CPLUS_BUG19
-template <class DATA> class CcuSmartPointerTo {
-protected:
- DATA* Data;
-inline void DecrDataRef () const { if (Data) Data->DecrRef (); }
-inline void IncrDataRef () const { if (Data) Data->IncrRef (); }
-
-public:
-inline CcuSmartPointerTo () : Data (0) { }
-inline CcuSmartPointerTo (DATA* d) : Data (d) { IncrDataRef (); }
-inline CcuSmartPointerTo (const CcuSmartPointerTo<DATA>& p) : Data (p.Data) { IncrDataRef (); }
-inline ~CcuSmartPointerTo () { DecrDataRef (); Data = 0; }
-inline CcuSmartPointerTo<DATA>& operator = (DATA* d) { if (d != Data) { DecrDataRef (); Data = d; IncrDataRef (); } return *this;}
-inline int operator == (const DATA* d) const { return Data == d;}
-inline int operator != (const DATA* d) const { return Data != d;}
-inline int operator == (const CcuSmartPointerTo<DATA>& p) const { return Data == p.Data;}
-inline int operator != (const CcuSmartPointerTo<DATA>& p) const { return Data != p.Data;}
-inline DATA* operator -> () const { return Data; }
-inline DATA& operator * () const { return *Data; }
-inline operator DATA* () const { return Data; }
-};
-
-#define PointerClass(SmartClass, DataClass) typedef CcuSmartPointerTo <DataClass> SmartClass;
-
-#else /* CPLUS_BUG19 */
-
-#define PointerClass(SmartClass, DataClass) \
- class SmartClass { \
- protected: \
- DataClass* Data; \
- inline void DecrDataRef () const { if (Data) Data->DecrRef (); } \
- inline void IncrDataRef () const { if (Data) Data->IncrRef (); } \
- \
- public: \
- inline SmartClass () : Data (0) { } \
- inline SmartClass (DataClass* d) : Data (d) { IncrDataRef (); } \
- inline SmartClass (const SmartClass& p) : Data (p.Data) { IncrDataRef (); } \
- inline ~SmartClass () { DecrDataRef (); Data = 0; } \
- inline SmartClass& operator = (DataClass* d) { if (d != Data) { DecrDataRef (); Data = d; IncrDataRef (); } return *this;} \
- inline int operator == (const DataClass* d) const { return Data == d;} \
- inline int operator != (const DataClass* d) const { return Data != d;} \
- inline int operator == (const SmartClass& p) const { return Data == p.Data;} \
- inline int operator != (const SmartClass& p) const { return Data != p.Data;} \
- inline DataClass* operator -> () const { return Data; } \
- inline DataClass& operator * () const { return *Data; } \
- inline operator DataClass* () const { return Data; } \
- };
-
-#endif /* CPLUS_BUG19 */
-
-#define DerivedPointerClass(SmartClass, BaseSmartClass, DataClass) \
- class SmartClass : public BaseSmartClass { \
- public: \
- inline SmartClass () : BaseSmartClass () { } \
- inline SmartClass (const SmartClass& p) : BaseSmartClass (p) { } \
- inline SmartClass (DataClass* d) : BaseSmartClass (d) { } \
- inline SmartClass& operator = (DataClass* d) { if (d != Data) { DecrDataRef (); Data = d; IncrDataRef (); } return *this; } \
- inline DataClass* operator -> () const { return (DataClass*) Data; } \
- inline DataClass& operator * () const { return * ((DataClass*) Data); } \
- inline operator DataClass* () const { return (DataClass*) Data; } \
- };
-
-#ifdef DOC
-global macro PointerClass (SmartClass, DataClass);
-global macro DerivedPointerClass (SmartClass, BaseSmartClass, DataClass);
-#endif
-
-#endif /* SmartPointer_H_ */
-
diff --git a/utils/String.cc b/utils/String.cc
index f6b7e4a..cd5b52d 100644
--- a/utils/String.cc
+++ b/utils/String.cc
@@ -35,7 +35,6 @@ NewString (const char* s)
return p;
}
-
/*?
Allocate a string of \var{n} characters,
copy the \var{n} first characters of \var{s} in it,
@@ -74,7 +73,6 @@ NewString (int n)
return new char [n+1];
}
-
/*?
Free a string which has previously been
allocated with \fun{NewString}.
@@ -92,64 +90,64 @@ FreeString (char* s)
#endif
}
-/*?class CcuString
+/*?class IvlString
?*/
#ifdef DOC
/*?
-Build an empty \typ{CcuString}.
+Build an empty \typ{IvlString}.
?*/
-CcuString :: CcuString ()
+IvlString :: IvlString ()
{
}
#endif
/*?
-Build a \typ{CcuString} from \var{s}. \var{s} can be null.
+Build a \typ{IvlString} from \var{s}. \var{s} can be null.
?*/
-CcuString :: CcuString (const char* s)
+IvlString :: IvlString (const char* s)
: Str (NewString (s))
{
}
/*?
-Build a \typ{CcuString} from the \var{n} first characters of \var{s}. \var{s} can be null.
+Build a \typ{IvlString} from the \var{n} first characters of \var{s}. \var{s} can be null.
If it is shorter than \var{n} characters,
the new string is padded with null characters.
?*/
-CcuString :: CcuString (const char* s, int n)
+IvlString :: IvlString (const char* s, int n)
: Str (NewString (s, n))
{
}
/*?
-Create a \typ{CcuString} suitable for storing at most \var{n} characters, and
+Create a \typ{IvlString} suitable for storing at most \var{n} characters, and
initialize it to the null string.
?*/
-CcuString :: CcuString (int n)
+IvlString :: IvlString (int n)
: Str (NewString (n))
{
*Str = '\0';
}
/*?
-Create a new \typ{CcuString} by copying \var{s}.
+Create a new \typ{IvlString} by copying \var{s}.
?*/
-CcuString :: CcuString (const CcuString& s)
+IvlString :: IvlString (const IvlString& s)
: Str (NewString (s))
{
}
/*?
-Create a new \typ{CcuString} by copying \var{s}.
+Create a new \typ{IvlString} by copying \var{s}.
?*/
-CcuString :: CcuString (const CcuShadowString& s)
+IvlString :: IvlString (const IvlShadowString& s)
{
Str = NewString (s);
}
/*?nodoc?*/
-CcuString :: ~CcuString ()
+IvlString :: ~IvlString ()
{
if (Str)
FreeString (Str);
@@ -159,18 +157,16 @@ CcuString :: ~CcuString ()
/*?
Return the value of a string.
?*/
-CcuString :: operator const char* () const
+IvlString :: operator const char* () const
{
}
#endif
-
-
/*?
Copy \var{s} into this string. The old string is freed.
?*/
-CcuString&
-CcuString :: operator = (const CcuString& s)
+IvlString&
+IvlString :: operator = (const IvlString& s)
{
if (this != &s) {
FreeString (Str);
@@ -179,8 +175,8 @@ CcuString :: operator = (const CcuString& s)
return *this;
}
-CcuString&
-CcuString :: operator = (const char* s)
+IvlString&
+IvlString :: operator = (const char* s)
{
if (Str != s) {
FreeString (Str);
@@ -189,8 +185,8 @@ CcuString :: operator = (const char* s)
return *this;
}
-CcuString&
-CcuString :: operator = (const CcuShadowString& s)
+IvlString&
+IvlString :: operator = (const IvlShadowString& s)
{
if (Str != (const char*) (s)) {
FreeString (Str);
@@ -205,8 +201,8 @@ Assign to a string the \var{n} first characters of \var{s}.
If it is shorter than \var{n} characters,
the new string is padded with null characters.
?*/
-CcuString&
-CcuString :: Assign (const char* s, int n)
+IvlString&
+IvlString :: Assign (const char* s, int n)
{
if (Str != s) {
FreeString (Str);
@@ -219,16 +215,16 @@ CcuString :: Assign (const char* s, int n)
Compute the length of a string.
?*/
int
-CcuString :: Length () const
+IvlString :: Length () const
{
return strlen (Str);
}
#ifdef DOC
/*?
-Build an empty \typ{CcuShadowString}.
+Build an empty \typ{IvlShadowString}.
?*/
-CcuShadowString :: CcuShadowString ()
+IvlShadowString :: IvlShadowString ()
{
Str = 0;
}
@@ -236,36 +232,35 @@ CcuShadowString :: CcuShadowString ()
/*?
?*/
-CcuShadowString :: CcuShadowString (const char* s)
+IvlShadowString :: IvlShadowString (const char* s)
{
Str = s;
}
/*?
-Create a new \typ{CcuShadowString} by referencing \var{s}.
+Create a new \typ{IvlShadowString} by referencing \var{s}.
?*/
-CcuShadowString :: CcuShadowString (const CcuString& s)
+IvlShadowString :: IvlShadowString (const IvlString& s)
{
Str = (const char*) s;
}
#ifdef DOC
-CcuShadowString&
-CcuShadowString :: operator = (const CcuString& s)
+IvlShadowString&
+IvlShadowString :: operator = (const IvlString& s)
{
}
-CcuShadowString&
-CcuShadowString :: operator = (const char* s)
+IvlShadowString&
+IvlShadowString :: operator = (const char* s)
{
}
/*?
Return the value of a string.
?*/
-CcuShadowString :: operator const char* () const
+IvlShadowString :: operator const char* () const
{
}
#endif
-
diff --git a/utils/String.h b/utils/String.h
index 42509d3..b411dc0 100644
--- a/utils/String.h
+++ b/utils/String.h
@@ -7,7 +7,7 @@
* Laboratoire de Recherche en Informatique (LRI)
* Centre d'Etudes de la Navigation Aerienne (CENA)
*
- * CcuString allocation and copying
+ * IvlString allocation and copying
*
* $Id$
* $CurLog$
@@ -25,36 +25,36 @@ extern char* NewString (int);
extern void FreeString (char*);
/*? end ?*/
-class CcuShadowString;
+class IvlShadowString;
-class CcuString {
+class IvlString {
private:
char* Str;
public:
-inline CcuString () { Str = 0; }
- CcuString (const char*);
- CcuString (const char*, int);
- CcuString (int);
- CcuString (const CcuString&);
- CcuString (const CcuShadowString&);
- ~CcuString ();
+inline IvlString () { Str = 0; }
+ IvlString (const char*);
+ IvlString (const char*, int);
+ IvlString (int);
+ IvlString (const IvlString&);
+ IvlString (const IvlShadowString&);
+ ~IvlString ();
inline operator const char* () const { return Str; }
- CcuString& operator = (const CcuString&);
- CcuString& operator = (const char*);
- CcuString& operator = (const CcuShadowString&);
- CcuString& Assign (const char*, int);
+ IvlString& operator = (const IvlString&);
+ IvlString& operator = (const char*);
+ IvlString& operator = (const IvlShadowString&);
+ IvlString& Assign (const char*, int);
int Length () const;
};
-class CcuShadowString {
+class IvlShadowString {
private:
const char* Str;
public:
-inline CcuShadowString () { Str = 0; }
- CcuShadowString (const char*);
- CcuShadowString (const CcuString&);
-inline CcuShadowString& operator = (const CcuString& s) { Str = (const char*) s; return *this; }
-inline CcuShadowString& operator = (const char* s) { Str = s; return *this; }
+inline IvlShadowString () { Str = 0; }
+ IvlShadowString (const char*);
+ IvlShadowString (const IvlString&);
+inline IvlShadowString& operator = (const IvlString& s) { Str = (const char*) s; return *this; }
+inline IvlShadowString& operator = (const char* s) { Str = s; return *this; }
inline operator const char* () const { return Str; }
int Length () const;
};
diff --git a/utils/Time.cc b/utils/Time.cc
index 3e57a3c..ced0df5 100644
--- a/utils/Time.cc
+++ b/utils/Time.cc
@@ -16,24 +16,24 @@
#include <sys/time.h>
//extern "C" int gettimeofday (struct timeval *, struct timezone *);
-/*?class CcuTimeStamp
-The class \var{CcuTimeStamp} provides variables that can be manipulated as
+/*?class IvlTimeStamp
+The class \var{IvlTimeStamp} provides variables that can be manipulated as
integers, but whose initial value is set according to the current time.
The following example should be self-explanatory:
\begin{ccode}
- CcuTimeStamp before;
+ IvlTimeStamp before;
long_task ();
- CcuTimeStamp after;
+ IvlTimeStamp after;
Millisecond delay = after - before;
\end{ccode}
-The values of \typ{CcuTimeStamp}s are expressed in milliseconds.
+The values of \typ{IvlTimeStamp}s are expressed in milliseconds.
The type \typ{Millisecond} is currently defined as \typ{long int}.
?*/
/*?
Create a time stamp. Its value is set according to the current time.
?*/
-CcuTimeStamp :: CcuTimeStamp ()
+IvlTimeStamp :: IvlTimeStamp ()
{
struct timeval tv;
gettimeofday (&tv, 0);
@@ -44,53 +44,53 @@ CcuTimeStamp :: CcuTimeStamp ()
/*?
Get the value of a time stamp.
?*/
-CcuTimeStamp :: operator Millisecond () const
+IvlTimeStamp :: operator Millisecond () const
{
}
#endif /* DOC */
const char*
-CcuTimeStamp :: AsString () const
+IvlTimeStamp :: AsString () const
{
time_t t = Value / 1000;
return ctime (&t);
}
-/*?class CcuTime
-The class \typ{CcuTime} provides a simple way of manipulating real-time. Objects
+/*?class IvlTime
+The class \typ{IvlTime} provides a simple way of manipulating real-time. Objects
of this class are used like integer variables whose value would change with time.
That behavior is obtained through the redefinition of the operator yielding the
integer value.
Time values are expressed with the type \typ{Millisecond}, which is currently implemented
-as \typ{long int}. You may initialize a \typ{CcuTime} with a negative value.
+as \typ{long int}. You may initialize a \typ{IvlTime} with a negative value.
?*/
/*?
Initialize a time variable with initial value \var{t}.
?*/
-CcuTime :: CcuTime (Millisecond t)
+IvlTime :: IvlTime (Millisecond t)
{
- CcuTimeStamp now;
+ IvlTimeStamp now;
Offset = now - t;
}
/*?
Get the current value of a time variable.
?*/
-CcuTime :: operator Millisecond () const
+IvlTime :: operator Millisecond () const
{
- CcuTimeStamp now;
+ IvlTimeStamp now;
return now - Offset;
}
/*?
Reinitialize a time variable to the value \var{t}.
?*/
-CcuTime&
-CcuTime :: operator = (Millisecond t)
+IvlTime&
+IvlTime :: operator = (Millisecond t)
{
- CcuTimeStamp now;
+ IvlTimeStamp now;
Offset = now - t;
return *this;
}
diff --git a/utils/Time.h b/utils/Time.h
index 19b0648..a56615a 100644
--- a/utils/Time.h
+++ b/utils/Time.h
@@ -15,27 +15,25 @@
#ifndef Time_H_
#define Time_H_
-
-
#include "cplus_bugs.h"
typedef long Millisecond;
-class CcuTimeStamp {
+class IvlTimeStamp {
protected:
Millisecond Value;
public:
- CcuTimeStamp ();
+ IvlTimeStamp ();
inline operator Millisecond () const { return Value; }
const char* AsString () const;
};
-class CcuTime {
+class IvlTime {
protected:
Millisecond Offset;
public:
- CcuTime (Millisecond = 0);
- CcuTime& operator = (Millisecond);
+ IvlTime (Millisecond = 0);
+ IvlTime& operator = (Millisecond);
operator Millisecond () const;
};
diff --git a/utils/Timer.cc b/utils/Timer.cc
index 8342854..c2b4d11 100644
--- a/utils/Timer.cc
+++ b/utils/Timer.cc
@@ -26,8 +26,8 @@
#include <sys/time.h>
#include <stdio.h>
-/*!class CcuCoreTimer
-The implementation of \typ{CcuCoreTimer} is a bit tricky, because it tries to be fast.
+/*!class IvlCoreTimer
+The implementation of \typ{IvlCoreTimer} is a bit tricky, because it tries to be fast.
Here is the basic idea: active timers are stored in a list, sorted by increasing time-out
times. When a signal occurs, all timers whose time-out time is smaller than the current
time are notified and removed from the list, then they are inserted again.
@@ -43,15 +43,15 @@ and if we make sure that a timer is flagged as inactive when we insert it, all w
occurences before the right one will be removed.
!*/
-/*?class CcuCoreTimer
+/*?class IvlCoreTimer
Timers are a means to manage or one more periodic tasks in a program.
-The class \typ{CcuCoreTimer} is a base class for all kinds of timers. It provides
+The class \typ{IvlCoreTimer} is a base class for all kinds of timers. It provides
the basic storing and scheduling of timers, as well as a set of member functions
available to the user, but does not provide the actual, system dependent, timing
scheme.
-\typ{CcuCoreTimers} were not designed to be used as is, but only to be derived
+\typ{IvlCoreTimers} were not designed to be used as is, but only to be derived
in order to implement a specific timing scheme.
-For instance, the class \var{CcuBaseTimer} is derived from it and implements
+For instance, the class \var{IvlBaseTimer} is derived from it and implements
signal-based timers (see next section). Building such derived class is very rare,
and it has only be done for timers based on the Unix \com{select} system call,
in the Unix Channel library.
@@ -67,42 +67,41 @@ current (absolute) time when the signal was received from the system. However,
several timers may be triggered at the same time.
If one of them has a slow \fun{Handle}, the time passed to the next ones no more
corrresponds to the current time. If you want to know the exact time, and you are
-not sure of the behaviour of the other timers, it is preferable to use a \typ{CcuTimeStamp}.
+not sure of the behaviour of the other timers, it is preferable to use a \typ{IvlTimeStamp}.
?*/
-/*?class CcuTimerSet
-The class \typ{CcuTimerSet} is the data structure used by the class \typ{CcuCoreTimer}
+/*?class IvlTimerSet
+The class \typ{IvlTimerSet} is the data structure used by the class \typ{IvlCoreTimer}
to manage a set of timers. Each different implementation of timers should work
-with one such timer set, which is passed to the constructor of \typ{CcuCoreTimer}.
+with one such timer set, which is passed to the constructor of \typ{IvlCoreTimer}.
?*/
#ifdef DOC
/*?
-Create an empty \typ{CcuTimerSet}.
+Create an empty \typ{IvlTimerSet}.
?*/
-CcuTimerSet :: CcuTimerSet ()
+IvlTimerSet :: IvlTimerSet ()
{
}
#endif /* DOC */
-
/*!
Remove and return the first active timer in the active timer list.
Timers in that list can actually be inactive.
!*/
/*?hidden?*/
-CcuCoreTimer*
-CcuTimerSet :: ExtractNextActive ()
+IvlCoreTimer*
+IvlTimerSet :: ExtractNextActive ()
{
- CcuCoreTimer* t;
+ IvlCoreTimer* t;
/* all entries of OtherTimers are valid pointers,
hence t == 0 iff OtherTimers is empty */
#ifndef CPLUS_BUG19
- while ((t = OtherTimers.RemoveFirst ()) && (t->StatusFlag != CcuCoreTimer::Active))
+ while ((t = OtherTimers.RemoveFirst ()) && (t->StatusFlag != IvlCoreTimer::Active))
#else
- while ((t = (CcuCoreTimer*) OtherTimers.RemoveFirst ()) && (t->StatusFlag != CcuCoreTimer::Active))
+ while ((t = (IvlCoreTimer*) OtherTimers.RemoveFirst ()) && (t->StatusFlag != IvlCoreTimer::Active))
#endif
;
@@ -124,15 +123,15 @@ or more timer has expired. It decides which timers should be triggered,
and prepares the set of timers for the next call.
?*/
void
-CcuCoreTimer :: Fire (CcuTimerSet* s)
+IvlCoreTimer :: Fire (IvlTimerSet* s)
{
- CcuCoreTimer*& first = s->FirstTimer;
+ IvlCoreTimer*& first = s->FirstTimer;
/* If the first timer is not mature yet, ignore this call */
if (!first)
return;
- CcuTimeStamp now;
+ IvlTimeStamp now;
#if defined(sun) && defined(__svr4__)
/* add tolerance because Solaris sends signals before the expected time (bug #1164919)*/
if (first->NextDate > now + 5) {
@@ -154,7 +153,7 @@ CcuCoreTimer :: Fire (CcuTimerSet* s)
first->Handle (now);
/* handle all other expired timers. */
- CcuCoreTimer* t;
+ IvlCoreTimer* t;
while (t = s->ExtractNextActive ()) {
/* Problem : if one Handle () is long, "now" will then be wrong. */
if (t->NextDate > now) {
@@ -171,7 +170,7 @@ CcuCoreTimer :: Fire (CcuTimerSet* s)
return;
if (t) {
- CcuTimeStamp then;
+ IvlTimeStamp then;
t->SetAlarm (t->NextDate - then);
} else if (first) {
/* we need a valid timer just to be able to call StopAlarm */
@@ -182,12 +181,11 @@ CcuCoreTimer :: Fire (CcuTimerSet* s)
first = t;
}
-
#ifndef CPLUS_BUG19
/*?hidden?*/
int
-CcuCoreTimer :: IsInactive (CcuCoreTimer* t)
+IvlCoreTimer :: IsInactive (IvlCoreTimer* t)
{
return (t->StatusFlag != Active);
}
@@ -196,21 +194,20 @@ CcuCoreTimer :: IsInactive (CcuCoreTimer* t)
/*?hidden?*/
int
-CcuCoreTimer :: IsInactive (CcuListItem* t)
+IvlCoreTimer :: IsInactive (IvlListItem* t)
{
- return (((CcuCoreTimer*) t)->StatusFlag != Active);
+ return (((IvlCoreTimer*) t)->StatusFlag != Active);
}
#endif /* CPLUS_BUG19 */
-
/*?
Create a timer with that will time out every \var{period} milliseconds, and at most
\var{pulses} times. This timer will be managed by the timer set \var{s}.
{\em This constructor is only useful when deriving new timers based on a new
timing scheme.}
?*/
-CcuCoreTimer :: CcuCoreTimer (Millisecond period, int pulses, CcuTimerSet* s)
+IvlCoreTimer :: IvlCoreTimer (Millisecond period, int pulses, IvlTimerSet* s)
: MySet (s),
StatusFlag (Active),
Period (period > 0 ? period : 10),
@@ -218,14 +215,13 @@ CcuCoreTimer :: CcuCoreTimer (Millisecond period, int pulses, CcuTimerSet* s)
{
}
-
/*?nodoc?*/
-CcuCoreTimer :: ~CcuCoreTimer ()
+IvlCoreTimer :: ~IvlCoreTimer ()
{
/* the timer has to be stopped in the derived class */
/* Remove all entries pointing to inactive timers, including this one */
if (MySet)
- MySet->OtherTimers.Remove (IsInactive, CcuList::All);
+ MySet->OtherTimers.Remove (IsInactive, IvlList::All);
}
/*?
@@ -233,9 +229,9 @@ Change the period of a timer. The new period will not be taken into account
before the next time-out.
?*/
void
-CcuCoreTimer :: ChangePeriod (Millisecond period)
+IvlCoreTimer :: ChangePeriod (Millisecond period)
{
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
Period = period;
}
@@ -244,25 +240,24 @@ Change the number of times a timer will go off before stopping. If
the timer is stopped, it is not restarted.
?*/
void
-CcuCoreTimer :: ChangeNbPulses (int nb)
+IvlCoreTimer :: ChangeNbPulses (int nb)
{
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
PulsesLeft = nb;
}
-
/*?
Stop this timer if it was running, then start it with its current period.
This function can be used to reset a timer to the beginning of a period.
?*/
void
-CcuCoreTimer :: Restart ()
+IvlCoreTimer :: Restart ()
{
if (PulsesLeft == 0)
return;
/* this function could be optimized: sometimes SetAlarm is called twice. */
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
if (StatusFlag == Active)
Stop ();
Activate ();
@@ -275,13 +270,13 @@ first one, the alarm is updated.
!*/
/*?hidden?*/
void
-CcuCoreTimer :: Activate ()
+IvlCoreTimer :: Activate ()
{
if (!MySet)
return;
- CcuTimeStamp now;
+ IvlTimeStamp now;
NextDate = now + Period;
- CcuCoreTimer*& first = MySet->FirstTimer;
+ IvlCoreTimer*& first = MySet->FirstTimer;
if (!first) {
first = this;
SetAlarm (Period);
@@ -297,7 +292,7 @@ CcuCoreTimer :: Activate ()
/*?hidden?*/
void
-CcuCoreTimer :: Reschedule ()
+IvlCoreTimer :: Reschedule ()
{
if (PulsesLeft == 0) // this should not happen...
return;
@@ -311,29 +306,29 @@ CcuCoreTimer :: Reschedule ()
/*?hidden?*/
void
-CcuCoreTimer :: Schedule (Millisecond when)
+IvlCoreTimer :: Schedule (Millisecond when)
{
NextDate = when;
/* temporarily set status to inactive so that obsolete entries
in OtherTimers pointing to this timer can be removed */
StatusFlag = Inactive;
- CcuListOf <CcuCoreTimer>& others = MySet->OtherTimers;
+ IvlListOf <IvlCoreTimer>& others = MySet->OtherTimers;
#ifndef CPLUS_BUG19
- CcuListIterOf <CcuCoreTimer> li (others);
- CcuListIterOf <CcuCoreTimer> lj (others);
+ IvlListIterOf <IvlCoreTimer> li (others);
+ IvlListIterOf <IvlCoreTimer> lj (others);
#else
- CcuListIter li (others);
- CcuListIter lj (others);
+ IvlListIter li (others);
+ IvlListIter lj (others);
#endif
while (++li) {
/* while we're at it, remove inactive timers from the list */
#ifndef CPLUS_BUG19
- CcuCoreTimer* cur = *li;
+ IvlCoreTimer* cur = *li;
#else
- CcuCoreTimer* cur = (CcuCoreTimer*) *li;
+ IvlCoreTimer* cur = (IvlCoreTimer*) *li;
#endif
if (cur->StatusFlag != Active) {
others.RemoveAfter (lj);
@@ -352,13 +347,13 @@ Stop a timer.
This timer will not deliver any signal until \fun{Restart} is called.
?*/
void
-CcuCoreTimer :: Stop ()
+IvlCoreTimer :: Stop ()
{
if (StatusFlag != Active)
return;
- CcuSignalBlocker b (SigAlrm);
- CcuCoreTimer*& first = MySet->FirstTimer;
+ IvlSignalBlocker b (SigAlrm);
+ IvlCoreTimer*& first = MySet->FirstTimer;
StatusFlag = Inactive;
@@ -368,7 +363,7 @@ CcuCoreTimer :: Stop ()
if (first == 0)
StopAlarm ();
else {
- CcuTimeStamp now;
+ IvlTimeStamp now;
first->SetAlarm (first->NextDate - now);
}
}
@@ -379,7 +374,7 @@ CcuCoreTimer :: Stop ()
Wait for this timer to expire. If it is stopped, return immediately.
?*/
void
-CcuCoreTimer :: Wait ()
+IvlCoreTimer :: Wait ()
{
if (StatusFlag != Active)
return;
@@ -396,7 +391,7 @@ CcuCoreTimer :: Wait ()
#ifdef DOC
/*?nextdoc?*/
Millisecond
-CcuCoreTimer :: GetPeriod () const
+IvlCoreTimer :: GetPeriod () const
{
}
@@ -404,7 +399,7 @@ CcuCoreTimer :: GetPeriod () const
Get the period (resp. the number of pulses to go) of a timer.
?*/
int
-CcuCoreTimer :: GetNbPulses () const
+IvlCoreTimer :: GetNbPulses () const
{
}
@@ -412,13 +407,13 @@ CcuCoreTimer :: GetNbPulses () const
Get the status of a timer. The returned value is \var{Active} or \var{Inactive}.
?*/
timer_status
-CcuCoreTimer :: GetStatus () const
+IvlCoreTimer :: GetStatus () const
{
}
/*?nextdoc?*/
void
-CcuCoreTimer :: SetAlarm (Millisecond delay)
+IvlCoreTimer :: SetAlarm (Millisecond delay)
{
}
@@ -429,7 +424,7 @@ scheme. \fun{SetAlarm} should ensure that the function \fun{Fire} will be
called in \var{delay} milliseconds from now. \fun{StopAlarm} should disable such calls.
?*/
void
-CcuCoreTimer :: StopAlarm ()
+IvlCoreTimer :: StopAlarm ()
{
}
@@ -440,14 +435,13 @@ This virtual function is called when the timer is triggered. It should be
redefined in derived classes to attach a behaviour to a timer.
?*/
void
-CcuCoreTimer :: Handle (Millisecond)
+IvlCoreTimer :: Handle (Millisecond)
{
}
-
-/*?class CcuBaseTimer
-The class \typ{CcuBaseTimer} is provided as a base class for signal-based timers.
-It comes with a derived class \typ{CcuTimer} that can be used as is.
+/*?class IvlBaseTimer
+The class \typ{IvlBaseTimer} is provided as a base class for signal-based timers.
+It comes with a derived class \typ{IvlTimer} that can be used as is.
A timer is created with a period expressed in milliseconds. It will then
periodically call the member function \fun{Handle}, which should be redefined
in derived classes.
@@ -458,16 +452,15 @@ Using them concurrently with system calls such as \fun{sleep} yields
unexpected results.
?*/
-
-CcuSignalHandler* CcuBaseTimer::TimeOutHandler = 0;
-CcuTimerSet* CcuBaseTimer::TimerSet = 0;
+IvlSignalHandler* IvlBaseTimer::TimeOutHandler = 0;
+IvlTimerSet* IvlBaseTimer::TimerSet = 0;
/*?hidden?*/
void
-CcuBaseTimer :: ClassInit ()
+IvlBaseTimer :: ClassInit ()
{
- TimeOutHandler = new CcuSignalHandler (SigAlrm, &CcuBaseTimer::HandleSignal);
- TimerSet = new CcuTimerSet;
+ TimeOutHandler = new IvlSignalHandler (SigAlrm, &IvlBaseTimer::HandleSignal);
+ TimerSet = new IvlTimerSet;
}
/*?
@@ -476,17 +469,17 @@ If \var{pulses} is negative, the timer will send signals forever.
Timers are activated at creation time. They are disactivated, but not destroyed, after
their last pulse.
?*/
-CcuBaseTimer :: CcuBaseTimer (Millisecond period, int pulses)
-: CcuCoreTimer (period, pulses, (TimerSet ? TimerSet : (ClassInit (), TimerSet)))
+IvlBaseTimer :: IvlBaseTimer (Millisecond period, int pulses)
+: IvlCoreTimer (period, pulses, (TimerSet ? TimerSet : (ClassInit (), TimerSet)))
{
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
if (PulsesLeft != 0)
Activate ();
}
/*?nodoc?*/
-CcuBaseTimer :: ~CcuBaseTimer ()
+IvlBaseTimer :: ~IvlBaseTimer ()
{
/* stop it */
if (StatusFlag == Active)
@@ -495,7 +488,7 @@ CcuBaseTimer :: ~CcuBaseTimer ()
/*?hidden?*/
void
-CcuBaseTimer :: StopAlarm ()
+IvlBaseTimer :: StopAlarm ()
{
struct itimerval itval;
timerclear (&itval.it_value);
@@ -505,7 +498,7 @@ CcuBaseTimer :: StopAlarm ()
/*?hidden?*/
void
-CcuBaseTimer :: SetAlarm (Millisecond delay)
+IvlBaseTimer :: SetAlarm (Millisecond delay)
{
if (delay <= 0) {
StopAlarm ();
@@ -521,7 +514,6 @@ CcuBaseTimer :: SetAlarm (Millisecond delay)
fprintf (stderr, "setitimer failed for interval %d\n", delay);
}
-
/*!
This function is called by the signal handler. The first active timer is expired
and scheduled again. Then all the timers whose expiration time is earlier
@@ -533,16 +525,15 @@ active timer.
!*/
/*?hidden?*/
void
-CcuBaseTimer :: HandleSignal (int)
+IvlBaseTimer :: HandleSignal (int)
{
Fire (TimerSet);
}
-
-/*?class CcuTimer
-The class \typ{CcuTimer} is a derived class of \typ{CcuBaseTimer} that
+/*?class IvlTimer
+The class \typ{IvlTimer} is a derived class of \typ{IvlBaseTimer} that
can be used without deriving a new class.
-Each \typ{CcuTimer} holds a pointer to a function which is called when the timer
+Each \typ{IvlTimer} holds a pointer to a function which is called when the timer
expires. This function, which is passed to the constructor, must
take a \typ{Millisecond} argument and return \typ{void}.
?*/
@@ -551,20 +542,20 @@ take a \typ{Millisecond} argument and return \typ{void}.
Create a timer that will expire every \var{period} milliseconds and call
the function \var{handler}.
?*/
-CcuTimer :: CcuTimer (Millisecond period, void (*handler) (Millisecond), int pulses)
-: CcuBaseTimer (period, pulses),
+IvlTimer :: IvlTimer (Millisecond period, void (*handler) (Millisecond), int pulses)
+: IvlBaseTimer (period, pulses),
Handler (handler)
{
}
/*?nodoc?*/
-CcuTimer :: ~CcuTimer ()
+IvlTimer :: ~IvlTimer ()
{
}
/*?hidden?*/
void
-CcuTimer :: Handle (Millisecond ref)
+IvlTimer :: Handle (Millisecond ref)
{
(*Handler) (ref);
}
@@ -574,7 +565,7 @@ Change the handling function of a timer.
?*/
#ifdef DOC
void
-CcuTimer :: SetHandler ((void)(*h)(Millisecond))
+IvlTimer :: SetHandler ((void)(*h)(Millisecond))
{
}
#endif
diff --git a/utils/Timer.h b/utils/Timer.h
index bdeb520..1c5281b 100644
--- a/utils/Timer.h
+++ b/utils/Timer.h
@@ -19,42 +19,42 @@
#include "bool.h"
#include "Time.h"
-class CcuSignalHandler;
+class IvlSignalHandler;
#if 0
-template <class ITEM> class CcuListOf;
+template <class ITEM> class IvlListOf;
#else
#include "List.h"
#endif
-class CcuCoreTimer;
+class IvlCoreTimer;
-class CcuTimerSet {
-friend class CcuCoreTimer;
+class IvlTimerSet {
+friend class IvlCoreTimer;
private:
- CcuCoreTimer* FirstTimer;
+ IvlCoreTimer* FirstTimer;
#ifndef CPLUS_BUG19
- CcuListOf <CcuCoreTimer> OtherTimers;
+ IvlListOf <IvlCoreTimer> OtherTimers;
#else
- CcuList OtherTimers;
+ IvlList OtherTimers;
#endif
bool FirstIsUpdated;
- CcuCoreTimer* ExtractNextActive ();
+ IvlCoreTimer* ExtractNextActive ();
public:
-inline CcuTimerSet () : FirstTimer (0), OtherTimers (), FirstIsUpdated (false) {}
-inline ~CcuTimerSet () {}
+inline IvlTimerSet () : FirstTimer (0), OtherTimers (), FirstIsUpdated (false) {}
+inline ~IvlTimerSet () {}
//inline bool IsEmpty () const { return bool (FirstTimer == 0); } seems useless (10 may 96)
};
-class CcuCoreTimer {
-friend class CcuTimerSet;
+class IvlCoreTimer {
+friend class IvlTimerSet;
public:
enum timer_status { Active, Inactive };
protected:
-static int IsInactive (CcuCoreTimer*);
+static int IsInactive (IvlCoreTimer*);
- CcuTimerSet* MySet;
+ IvlTimerSet* MySet;
Millisecond NextDate;
Millisecond Period;
int PulsesLeft;
@@ -65,8 +65,8 @@ static int IsInactive (CcuCoreTimer*);
void Reschedule ();
/*?public?*/
- CcuCoreTimer (Millisecond, int, CcuTimerSet*);
-virtual ~CcuCoreTimer ();
+ IvlCoreTimer (Millisecond, int, IvlTimerSet*);
+virtual ~IvlCoreTimer ();
public:
void ChangePeriod (Millisecond);
@@ -85,13 +85,13 @@ virtual void SetAlarm (Millisecond) = 0;
virtual void StopAlarm () = 0;
public:
-static void Fire (CcuTimerSet*);
+static void Fire (IvlTimerSet*);
};
-class CcuBaseTimer : public CcuCoreTimer {
+class IvlBaseTimer : public IvlCoreTimer {
private:
-static CcuSignalHandler* TimeOutHandler;
-static CcuTimerSet* TimerSet;
+static IvlSignalHandler* TimeOutHandler;
+static IvlTimerSet* TimerSet;
static void HandleSignal (int);
static void ClassInit ();
@@ -100,20 +100,20 @@ protected:
void StopAlarm ();
public:
- CcuBaseTimer (Millisecond, int = -1);
- ~CcuBaseTimer ();
+ IvlBaseTimer (Millisecond, int = -1);
+ ~IvlBaseTimer ();
};
-typedef void (*CcuTimerFun) (Millisecond);
+typedef void (*IvlTimerFun) (Millisecond);
-class CcuTimer : public CcuBaseTimer {
+class IvlTimer : public IvlBaseTimer {
protected:
void (*Handler) (Millisecond);
void Handle (Millisecond);
public:
- CcuTimer (Millisecond, void (*) (Millisecond), int = -1);
- ~CcuTimer ();
+ IvlTimer (Millisecond, void (*) (Millisecond), int = -1);
+ ~IvlTimer ();
inline void SetHandler (void (*h) (Millisecond)) { Handler = h; }
};
diff --git a/utils/cplus_bugs.h b/utils/cplus_bugs.h
new file mode 100644
index 0000000..63f71b3
--- /dev/null
+++ b/utils/cplus_bugs.h
@@ -0,0 +1,6 @@
+#ifndef cplus_bug_h_
+#define cplus_bug_h_
+
+#define _private public
+
+#endif /* cplus_bug_h_ */
diff --git a/utils/doc.main b/utils/doc.main
index 5622ec3..28607a6 100644
--- a/utils/doc.main
+++ b/utils/doc.main
@@ -86,24 +86,23 @@ count of the pointed to data. This makes it easy to manage shared data structure
\item
\samepage
- {the archive file \com{libCcu.a}, which is usually instal\-led in
+ {the archive file \com{libIvl.a}, which is usually instal\-led in
\com{/usr/loc\-al/lib}, contains the library procedures. It must be loaded
with the object files which use \utils. This is usually performed
- by adding the flag \com{-lCcu} in the command line for your C++ compiler.
+ by adding the flag \com{-lIvl} in the command line for your C++ compiler.
For instance, you can type~:
\begin{center}
- \com{CC -o demo demo.C -lCcu}
+ \com{CC -o demo demo.C -lIvl}
\end{center}}
\end{enumerate}
-
\chapter{Memory allocators}
\label{Memory management}
-#class CcuAllocator
-#class CcuAllocatorOf
+#class IvlAllocator
+#class IvlAllocatorOf
\section{Allocating small objects}
When creating an instance of a C++ class, some memory is allocated for the object,
@@ -117,7 +116,7 @@ typedef int COORD;
class POINT {
private :
-static CcuAllocator* PtAlloc;
+static IvlAllocator* PtAlloc;
COORD X, Y;
public :
inline POINT (COORD, COORD) : X (x), Y (y) {}
@@ -125,14 +124,14 @@ inline POINT (COORD, COORD) : X (x), Y (y) {}
void operator delete (void*);
};
-CcuAllocator* POINT::PtAlloc = 0;
+IvlAllocator* POINT::PtAlloc = 0;
void*
POINT :: operator new (int)
{
/* Initialize the allocator for POINTs, if not done. */
if (!PtAlloc)
- PtAlloc = new CcuAllocator (sizeof (POINT));
+ PtAlloc = new IvlAllocator (sizeof (POINT));
return PtAlloc->Alloc ();
}
@@ -149,11 +148,10 @@ a class from class \typ{POINT}, if you do not overload \fun{operator new} again.
implementation would check the size argument against the size of chunks allocated
by the allocator being used.
-
\chapter{Dynamic arrays}
-#class CcuArray
-#class CcuArrayOf
+#class IvlArray
+#class IvlArrayOf
\chapter{Lists}
@@ -162,32 +160,32 @@ Arrays provide a way to do this, but are inappropriate when
these sets vary frequently and randomly, and especially when
new elements have to be inserted at any position.
-The classes \typ{CcuList} and \typ{CcuDList} are designed to manage such sets.
-\typ{CcuList} implements single linked lists, while \typ{CcuDList} implements
+The classes \typ{IvlList} and \typ{IvlDList} are designed to manage such sets.
+\typ{IvlList} implements single linked lists, while \typ{IvlDList} implements
double linked lists.
-Elements of a list can be enumerated by an iterator. The classes \typ{CcuListIter}
-and \typ{CcuDListIter} provide such iterators.
+Elements of a list can be enumerated by an iterator. The classes \typ{IvlListIter}
+and \typ{IvlDListIter} provide such iterators.
Lists can store objects of different types since the entries of the list are
of type \typ{void *}.
However you should be careful when using such heterogeneous lists.
\section {Simple lists}
-#iclass CcuList
+#iclass IvlList
\subsection {Iterating through lists}
-#iclass CcuListIter
+#iclass IvlListIter
\subsection{Generic versions}
-#iclass CcuListOf
-#iclass CcuListIterOf
+#iclass IvlListOf
+#iclass IvlListIterOf
\section {Bidirectionnal lists}
-#iclass CcuDList
+#iclass IvlDList
\subsection {Iterating}
-#iclass CcuDListIter
+#iclass IvlDListIter
\subsection{Generic versions}
-#iclass CcuDListOf
-#iclass CcuDListIterOf
+#iclass IvlDListOf
+#iclass IvlDListIterOf
\section {Example}
The following example illustrates a common usage of lists.
@@ -207,20 +205,19 @@ The following example illustrates a common usage of lists.
\chapter{Hash Tables}
-
-#iclass CcuHashTable
-#iclass CcuHashCell
+#iclass IvlHashTable
+#iclass IvlHashCell
\section{Iterating on hash tables}
-#iclass CcuHashCellIter
-#iclass CcuHashIter
+#iclass IvlHashCellIter
+#iclass IvlHashIter
\section{Strings as keys: dictionnaries}
-#iclass CcuDictionnary
+#iclass IvlDictionnary
\section{Generic classes}
-#iclass CcuHashTableOf
-#iclass CcuHashCellOf
-#iclass CcuHashCellIterOf
-#iclass CcuHashIterOf
-#iclass CcuDictionnaryOf
+#iclass IvlHashTableOf
+#iclass IvlHashCellOf
+#iclass IvlHashCellIterOf
+#iclass IvlHashIterOf
+#iclass IvlDictionnaryOf
\section{Example}
@@ -230,11 +227,11 @@ The keys are entered by the user, and the program assigns the information.
\begin{ccode}
main ()
{
- CcuDictionnary table (16);
+ IvlDictionnary table (16);
char line [256];
char *s;
int num = 0;
- CcuHashCell *h;
+ IvlHashCell *h;
int found;
table.Reset ();
@@ -315,33 +312,33 @@ main ()
\end{ccode}
\chapter{Identifier tables}
-#iclass CcuIdTable
-#iclass CcuIdIter
+#iclass IvlIdTable
+#iclass IvlIdIter
\chapter{Signal management}
-#class CcuSignalBlocker
+#class IvlSignalBlocker
-#class CcuBaseSignalHandler
-#class CcuSignalHandler
+#class IvlBaseSignalHandler
+#class IvlSignalHandler
\chapter{Time management}
\section{Measuring time}
\utils\ provides two classes for measuring time. The class
-\typ{CcuTimeStamp} provides a mean of dating events with reference to an absolute
-clock (the standard dating scheme of Unix), whereas the class \typ{CcuTime} makes it possible
+\typ{IvlTimeStamp} provides a mean of dating events with reference to an absolute
+clock (the standard dating scheme of Unix), whereas the class \typ{IvlTime} makes it possible
to measure time intervals.
-#iclass CcuTimeStamp
-#iclass CcuTime
+#iclass IvlTimeStamp
+#iclass IvlTime
\section{Timers}
-#iclass CcuCoreTimer
+#iclass IvlCoreTimer
\subsection{Signal-based timers}
-#iclass CcuBaseTimer
-#iclass CcuTimer
+#iclass IvlBaseTimer
+#iclass IvlTimer
\subsection{Example}
@@ -363,7 +360,6 @@ ding ()
write (1, "\n", 1); // change line each minute
}
-
void
done ()
{
@@ -373,9 +369,9 @@ done ()
main ()
{
- CcuTimer seconds (1000, tick);
- CcuTimer minutes (60000, ding);
- CcuTimer eggs (done, 180000, 0);
+ IvlTimer seconds (1000, tick);
+ IvlTimer minutes (60000, ding);
+ IvlTimer eggs (done, 180000, 0);
// wait for the eggs ...
// usual programs do other things meanwhile
for (;;)
@@ -386,14 +382,14 @@ main ()
\subsection{Deriving new kinds of timers}
If you have another source of interruptions than signals and
you want to map timers on it, you will need to derive a new class from
-\typ{CcuCoreTimer}. The derived class must implement the functions
+\typ{IvlCoreTimer}. The derived class must implement the functions
\fun{StartAlarm} and \fun{StopAlarm}. Its constructor must also provide a timer set
-to the constructor of \typ{CcuCoreTimer}. This timer set will hold all the timers of the
-new class. It will belong to the class \typ{CcuTimerSet}.
-#iclass CcuTimerSet
+to the constructor of \typ{IvlCoreTimer}. This timer set will hold all the timers of the
+new class. It will belong to the class \typ{IvlTimerSet}.
+#iclass IvlTimerSet
\chapter{Search paths}
-#class CcuDirPath
+#class IvlDirPath
\section{Example}
@@ -403,8 +399,7 @@ This example illustrates the use of the allocation mode with respect to
destroying the returned string.
\begin{ccode}
-CcuDirPath path;
-
+IvlDirPath path;
path.Append (".");
path.AppendEnvPath (getenv ("PATH"));
@@ -425,7 +420,7 @@ FreeString (file3); // safe (default allocation now true)
\end{ccode}
\chapter{Regular expressions}
-#class CcuRegExp
+#class IvlRegExp
\section{Example}
This procedure matches a string against a regular expression.
@@ -434,7 +429,7 @@ This procedure matches a string against a regular expression.
int
match (const char* exp, const char* s)
{
- CcuRegExp re (exp);
+ IvlRegExp re (exp);
if (!re.Compile ()) {
printf ("Cannot compile expression \"%s\"", exp);
return 0;
@@ -443,7 +438,6 @@ match (const char* exp, const char* s)
}
\end{ccode}
-
\chapter{Smart pointers}
The classes described here implement what we call smart pointers.
@@ -468,8 +462,8 @@ p = 0; // original object now unreachable
Smart pointers eliminate both problems, but of course with some run-time overhead.
-#class CcuSmartData
-#class CcuSmartPointerTo
+#class IvlSmartData
+#class IvlSmartPointerTo
\section{Example}
diff --git a/utils/metaclass.h b/utils/metaclass.h
index b036603..df896d6 100644
--- a/utils/metaclass.h
+++ b/utils/metaclass.h
@@ -13,7 +13,6 @@
* $CurLog$
*/
-
#ifndef _MetaClass_H_
#define _MetaClass_H_
@@ -22,7 +21,7 @@
class MetaClass {
protected:
const char* Name;
- CcuListOf <MetaClass> BaseClasses;
+ IvlListOf <MetaClass> BaseClasses;
public:
MetaClass (const char*, MetaClass&);
@@ -43,7 +42,6 @@ inline int operator != (const MetaClass& c) const { return (this != &c); }
inline const MetaClass& operator = (const MetaClass&) const { return *this; }
};
-
#ifdef __GNUG__
#define _nameCLASS(a) #a
#else
@@ -76,7 +74,6 @@ name :: Class () const \
return CLASS; \
}
-
#define NarrowMembers(derived,base) \
static inline derived* Narrow (base* p) { if (p && p->Class () <= CLASS) return (derived*) p; else return 0; } \
static inline const derived* Narrow (const base* p) { if (p && p->Class () <= CLASS) return (const derived*) p; else return 0; } \
diff --git a/utils/testchain.cc b/utils/testchain.cc
index ae5fef8..04351f5 100644
--- a/utils/testchain.cc
+++ b/utils/testchain.cc
@@ -5,15 +5,15 @@
class C {
public:
C* Next;
- char* CcuString;
-inline C (const char* c) : Next (0), CcuString (NewString (c)) {}
+ char* IvlString;
+inline C (const char* c) : Next (0), IvlString (NewString (c)) {}
inline C* GetNext () const { /*printf ("GetNext (%x) = %x)\n", this, Next); */ return Next; }
inline void SetNext (C* c) { /*printf ("SetNext (%x, %x)\n", this, c); */ Next = c; }
};
main ()
{
- CcuChainOf <C> l;
+ IvlChainOf <C> l;
char c;
char s[80];
while ((c = getchar ()) != EOF) {
@@ -38,7 +38,7 @@ main ()
{
int i;
scanf (" %d %s", &i, s);
- CcuChainIterOf <C> lj (l);
+ IvlChainIterOf <C> lj (l);
while ((i-- > 0) && ++lj)
;
l.InsertBefore (lj, new C (s));
@@ -48,17 +48,17 @@ main ()
{
int i;
scanf (" %d %s", &i, s);
- CcuChainIterOf <C> lj (l);
+ IvlChainIterOf <C> lj (l);
while ((i-- > 0) && ++lj)
;
l.InsertAfter (lj, new C (s));
break;
}
}
- CcuChainIterOf <C> li (l);
+ IvlChainIterOf <C> li (l);
while (++li) {
C* pt = *li;
- printf ("%s ", pt->CcuString);
+ printf ("%s ", pt->IvlString);
}
printf ("\n");
}
diff --git a/utils/testdirpath.cc b/utils/testdirpath.cc
index c709560..3ffd2cd 100644
--- a/utils/testdirpath.cc
+++ b/utils/testdirpath.cc
@@ -7,11 +7,10 @@ main ()
char line [256];
const char *s;
const char *found;
- CcuDirPath p;
+ IvlDirPath p;
const char* path = getenv ("PATH");
p.AppendEnvPath (path);
-
while (s = gets (line)) {
found = p.FindFile (s);
printf ("%s %s\n", found ? "found" : s, found ? found : "not found");
diff --git a/utils/testdlist.cc b/utils/testdlist.cc
index 9656883..0447ae6 100644
--- a/utils/testdlist.cc
+++ b/utils/testdlist.cc
@@ -5,9 +5,9 @@
main ()
{
#ifdef CPLUS_BUG19
- CcuDList l;
+ IvlDList l;
#else
- CcuDListOf <char> l;
+ IvlDListOf <char> l;
#endif
char c;
char s[80];
@@ -31,7 +31,7 @@ main ()
continue;
case 'r':
{
- CcuDListIterOf <char> li (l);
+ IvlDListIterOf <char> li (l);
li.GotoEnd ();
while (--li) {
char* pt = *li;
@@ -44,7 +44,7 @@ main ()
{
int i;
scanf (" %d %s", &i, s);
- CcuDListIterOf <char> lj (l);
+ IvlDListIterOf <char> lj (l);
while ((i-- > 0) && ++lj)
;
l.InsertBefore (lj, NewString (s));
@@ -54,7 +54,7 @@ main ()
{
int i;
scanf (" %d %s", &i, s);
- CcuDListIterOf <char> lj (l);
+ IvlDListIterOf <char> lj (l);
while ((i-- > 0) && ++lj)
;
l.InsertAfter (lj, NewString (s));
@@ -62,11 +62,11 @@ main ()
}
}
#ifdef CPLUS_BUG19
- CcuDListIter li (l);
+ IvlDListIter li (l);
while (++li)
printf ("%s ", (char*) *li);
#else
- CcuDListIterOf <char> li (l);
+ IvlDListIterOf <char> li (l);
while (++li) {
char* pt = *li;
printf ("%s ", pt);
diff --git a/utils/testhash.cc b/utils/testhash.cc
index ccc5bab..31d67df 100644
--- a/utils/testhash.cc
+++ b/utils/testhash.cc
@@ -2,8 +2,7 @@
#include <stdio.h>
#include <string.h>
-
-CcuDictionnary dict (16);
+IvlDictionnary dict (16);
main ()
{
@@ -43,8 +42,8 @@ main ()
}
#endif
if (strcmp (s, "#") == 0) {
- CcuDictionnary dictbis (dict);
- CcuHashCellIter hi (dictbis);
+ IvlDictionnary dictbis (dict);
+ IvlHashCellIter hi (dictbis);
while (++hi)
printf ("%s\n", (*hi)->GetKey());
continue;
diff --git a/utils/testid.cc b/utils/testid.cc
index bb79ced..72f30ae 100644
--- a/utils/testid.cc
+++ b/utils/testid.cc
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
-CcuIdTableOf <char> table (2);
+IvlIdTableOf <char> table (2);
main ()
{
@@ -32,7 +32,7 @@ main ()
}
if (strcmp (s, "#") == 0) {
- CcuIdIter hi = table;
+ IvlIdIter hi = table;
while (++hi)
printf ("%d: %s\n", hi.CurId (), *hi);
continue;
@@ -41,7 +41,7 @@ main ()
/* delete */
if (*s == '-') {
bool found;
- CcuID id = (CcuID) (atoi (++s));
+ IvlID id = (IvlID) (atoi (++s));
printf ("searching id %d\n", id);
char* info = table.Remove (id, &found);
if (! found)
@@ -54,7 +54,7 @@ main ()
}
/* add */
- CcuID id = table.Store (NewString (s));
+ IvlID id = table.Store (NewString (s));
printf ("-> %d\n", id);
}
diff --git a/utils/testlist.cc b/utils/testlist.cc
index 076d88e..934c28f 100644
--- a/utils/testlist.cc
+++ b/utils/testlist.cc
@@ -5,9 +5,9 @@
main ()
{
#ifdef CPLUS_BUG19
- CcuList l;
+ IvlList l;
#else
- CcuListOf <char> l;
+ IvlListOf <char> l;
#endif
char c;
char s[80];
@@ -34,9 +34,9 @@ main ()
int i;
scanf (" %d %s", &i, s);
#ifdef CPLUS_BUG19
- CcuListIter lj (l);
+ IvlListIter lj (l);
#else
- CcuListIterOf <char> lj (l);
+ IvlListIterOf <char> lj (l);
#endif
while ((i-- > 0) && ++lj)
;
@@ -48,9 +48,9 @@ main ()
int i;
scanf (" %d %s", &i, s);
#ifdef CPLUS_BUG19
- CcuListIter lj (l);
+ IvlListIter lj (l);
#else
- CcuListIterOf <char> lj (l);
+ IvlListIterOf <char> lj (l);
#endif
while ((i-- > 0) && ++lj)
;
@@ -59,13 +59,13 @@ main ()
}
}
#ifdef CPLUS_BUG19
- CcuListIter li (l);
+ IvlListIter li (l);
while (++li) {
char* pt = (char*) *li;
printf ("%s ", pt);
}
#else
- CcuListIterOf <char> li (l);
+ IvlListIterOf <char> li (l);
while (++li) {
char* pt = *li;
printf ("%s ", pt);
diff --git a/utils/testregexp.cc b/utils/testregexp.cc
index 5949ec8..fc8ed34 100644
--- a/utils/testregexp.cc
+++ b/utils/testregexp.cc
@@ -9,7 +9,7 @@ main (int argc, char** argv)
char* s1 = "tota toto";
if (argc > 1)
s1 = argv[1];
- CcuRegExp re = s;
+ IvlRegExp re = s;
if (re.Compile ()) {
if (re.Match (s1))
printf ("%s\n",s1);
diff --git a/utils/testsignal.cc b/utils/testsignal.cc
index 4971b51..eda5bb5 100644
--- a/utils/testsignal.cc
+++ b/utils/testsignal.cc
@@ -2,10 +2,12 @@
#include <stdlib.h>
#include "Signal.h"
+#if 0
extern "C" {
int write (int, const void*, unsigned int);
int strlen (const char*);
}
+#endif
const char* signal_strings [32] = {
"SIGHUP\n",
@@ -57,16 +59,16 @@ main ()
{
{
printf ("block signal 2\n");
- CcuSignalBlocker b (2);
+ IvlSignalBlocker b (2);
getchar ();
}
printf ("print signals 1 and 2\n");
- CcuSignalHandler s1 (1, outputsig);
- CcuSignalHandler s3 (2, outputsig);
+ IvlSignalHandler s1 (1, outputsig);
+ IvlSignalHandler s3 (2, outputsig);
getchar ();
{
printf ("ignore signal 1\n");
- CcuSignalHandler s2 (1, ignoresig);
+ IvlSignalHandler s2 (1, ignoresig);
getchar ();
}
printf ("print again signal 1\n");
diff --git a/utils/testtimer.cc b/utils/testtimer.cc
index 3dc4b0c..231b65c 100644
--- a/utils/testtimer.cc
+++ b/utils/testtimer.cc
@@ -7,7 +7,7 @@ int foo_counter = 0;
void
foo (Millisecond)
{
- CcuTimeStamp t;
+ IvlTimeStamp t;
fprintf (stderr, "tic %d\n", (unsigned long) (t));
foo_counter++;
}
@@ -15,7 +15,7 @@ foo (Millisecond)
void
baz (Millisecond)
{
- CcuTimeStamp t;
+ IvlTimeStamp t;
fprintf (stderr, "tac %d\n", (unsigned long) (t));
}
@@ -26,17 +26,17 @@ bar (Millisecond)
// exit (0);
}
-CcuList l;
+IvlList l;
main ()
{
#if 1
- CcuTimer t (1000, foo, 5);
- CcuTimer s (1000, baz);
- CcuTimer tt (10000, bar);
+ IvlTimer t (1000, foo, 5);
+ IvlTimer s (1000, baz);
+ IvlTimer tt (10000, bar);
#else
- CcuTimer t (20, foo);
- CcuTimer tt (10000, bar);
+ IvlTimer t (20, foo);
+ IvlTimer tt (10000, bar);
#endif
for (;;)
;
diff --git a/utils/version.h b/utils/version.h
index 661e3f9..6cd2f81 100644
--- a/utils/version.h
+++ b/utils/version.h
@@ -13,7 +13,6 @@
* $CurLog$
*/
-
/***
* Copyright 1990, 1991 Laboratoire de Recherche en Informatique (LRI)
* Copyright 1992-1996 Centre d'Etudes de la Navigation Aerienne (CENA)
@@ -65,10 +64,10 @@ phone 33+ 62 25 95 42
fax 33+ 62 25 95 99
**/
-#ifndef CcuVersion
+#ifndef IvlVersion
-#define CcuVersion 1
-#define CcuRelease 5
-#define CcuPatchLevel 4
+#define IvlVersion 1
+#define IvlRelease 5
+#define IvlPatchLevel 4
#endif