Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

SExpressionBacklink Class Reference

#include <sbacklnk.hpp>

Inheritance diagram for SExpressionBacklink:

Inheritance graph
[legend]
Collaboration diagram for SExpressionBacklink:

Collaboration graph
[legend]
List of all members.

Detailed Description

An element of a doubly-linked list.

Effectively this class is just a cons with a pointer for backwards direction, intended to point to the previous node of the list.

Warning:
Generic doubly-linked list is a data structure with oriented cycles of references, therefore it can NOT be garbage-collected with the usual reference-counting technique. To avoid this problem, the backwards reference is made a plain pointer instead of a reference. Thus it sometimes can be unsafe to use it. That's why there's no direct access to it; the methods of the class change the field only together with changing Cdr of the pointed object. You can destroy this consistensy changing Cdr manually; the behaviour is undefined for this case. DO NOT assign to Cdr() if you want to be safe.

Definition at line 43 of file sbacklnk.hpp.

Public Member Functions

 SExpressionBacklink (const SReference &acar, const SReference &acdr)
 The constructor.
virtual SExpressionClone () const
bool ConnectBack (const SBacklinkRef &where_to)
 Connect this element to the end of another one.
bool DisconnectBack ()
 Destroy the connection between us and the item right back to us.
void InsertAfter (const SReference &ref)
 Insert new item into the list right after this one.
bool RemoveNext ()
 Remove the next item from the list.
SBacklinkRef Prev () const
 Get the previous item reference.
SBacklinkRef Next () const
 Get the next item reference.
SReferenceCar ()
const SReferenceCar () const
SReferenceCdr ()
const SReferenceCdr () const
SString CoreTextRepresentation (const char *delim, const char *dotdelim, SString(*repfun)(const SReference &)=0) const
virtual SString TextRepresentation () const
const IntelibTypeIdTermType () const
 Actual S-expression type.
bool IsChangeable () const
 Can it be changed during the lifetime of the object?
virtual bool SpecificEql (const SExpression *) const
 Are the two objects EQL (while not EQ).

Static Public Attributes

static IntelibTypeId TypeId
 Type identifier.

Protected Member Functions

 SExpressionBacklink (const SReference &acar, const SReference &acdr, const IntelibTypeId &t)
 ~SExpressionBacklink ()
bool CanDie ()
 Is it OK to delete the object now?


Constructor & Destructor Documentation

SExpressionBacklink::SExpressionBacklink const SReference acar,
const SReference acdr
 

The constructor.

Backward reference is set to NULL

Definition at line 51 of file sbacklnk.hpp.

References TypeId.

Referenced by InsertAfter().

SExpressionBacklink::SExpressionBacklink const SReference acar,
const SReference acdr,
const IntelibTypeId t
[protected]
 

Definition at line 55 of file sbacklnk.hpp.

SExpressionBacklink::~SExpressionBacklink  )  [protected]
 

Definition at line 26 of file sbacklnk.cpp.

References back, SExpressionCons::Cdr(), SReference::DynamicCastGetPtr(), SReference::GetPtr(), and SReference::IsEmptyList().


Member Function Documentation

SExpression * SExpressionBacklink::Clone  )  const [virtual]
 

Warning:
In this version cloning 2l-lists is not implemented

Reimplemented from SExpressionCons.

Definition at line 36 of file sbacklnk.cpp.

bool SExpressionBacklink::ConnectBack const SBacklinkRef where_to  ) 
 

Connect this element to the end of another one.

If this element has something before the back or the where_to item has something after it, the function returns false. Otherwise, it connects them (thus changing our backlink and where_to's Cdr), returning true.

Definition at line 41 of file sbacklnk.cpp.

References SExpressionCons::Cdr(), and SReference::IsEmptyList().

bool SExpressionBacklink::DisconnectBack  ) 
 

Destroy the connection between us and the item right back to us.

If there's no item backwards to us, simply returns false; Otherwise, destroys the link between us (thus changing our backlink and where_to's Cdr), returning true.

Definition at line 49 of file sbacklnk.cpp.

References SExpressionCons::Cdr(), and PTheEmptyList.

Referenced by SBacklinkRef::Remove().

void SExpressionBacklink::InsertAfter const SReference ref  ) 
 

Insert new item into the list right after this one.

Definition at line 57 of file sbacklnk.cpp.

References back, SExpressionCons::Cdr(), SReference::DynamicCastGetPtr(), and SExpressionBacklink().

Referenced by SBacklinkRef::InsertAfter(), and SBacklinkRef::operator,().

bool SExpressionBacklink::RemoveNext  ) 
 

Remove the next item from the list.

Definition at line 68 of file sbacklnk.cpp.

References back, SExpressionCons::Cdr(), SReference::DynamicCastGetPtr(), SReference::IsEmptyList(), and PTheEmptyList.

SBacklinkRef SExpressionBacklink::Prev  )  const
 

Get the previous item reference.

Definition at line 91 of file sbacklnk.cpp.

References PTheEmptyList.

Referenced by SExpressionDoubleList::Iterator::IsBegin(), SBacklinkRef::operator--(), and SBacklinkRef::Remove().

SBacklinkRef SExpressionBacklink::Next  )  const
 

Get the next item reference.

Definition at line 99 of file sbacklnk.cpp.

References SExpressionCons::Cdr().

Referenced by SExpressionDoubleList::Iterator::IsEnd().

SReference& SExpressionCons::Car  )  [inherited]
 

Definition at line 622 of file sexpress.hpp.

Referenced by LispLambdaBody::DoAnalyseLambdaList(), SExpressionHashTable::FindItem(), SExpressionHashTable::GetItemPosition(), SchReference::IsEqual(), LReference::IsEqual(), pretty_print(), SExpressionHashTable::RemoveItem(), RetrieveFunctionObject(), SchReference::TextRepresentation(), and LReference::TextRepresentation().

const SReference& SExpressionCons::Car  )  const [inherited]
 

Definition at line 624 of file sexpress.hpp.

SReference& SExpressionCons::Cdr  )  [inherited]
 

Definition at line 623 of file sexpress.hpp.

Referenced by SQueue::Append(), ConnectBack(), DisconnectBack(), LispLambdaBody::DoAnalyseLambdaList(), SExpressionHashTable::FindItem(), SExpressionHashTable::GetItemPosition(), InsertAfter(), SchReference::IsEqual(), LReference::IsEqual(), Next(), SBacklinkRef::operator++(), SBacklinkRef::operator,(), pretty_print(), RemoveNext(), RetrieveFunctionObject(), SQueue::SQueue(), SchReference::TextRepresentation(), LReference::TextRepresentation(), and ~SExpressionBacklink().

const SReference& SExpressionCons::Cdr  )  const [inherited]
 

Definition at line 625 of file sexpress.hpp.

SString SExpressionCons::CoreTextRepresentation const char *  delim,
const char *  dotdelim,
SString(*)(const SReference &)  repfun = 0
const [inherited]
 

Used as a subroutine of TextRepresentation() to implement a representation of a part of a list

delim is the string to delimit the list's elements
(" " is used by TextRepresentation())
dotdelim is the string to delimit an irregular (dotted)
list's termination element (" . " is used by TextRepresentation())
repfun If given, this function is used to create
representation of each element. If repfun remains null, then generic TextRepresentation is used for all but unbound SReferences, and the stirng "#<UNBOUND>" is used for unbounds.

Referenced by SchReference::TextRepresentation(), and LReference::TextRepresentation().

virtual SString SExpressionCons::TextRepresentation  )  const [virtual, inherited]
 

List and dotted lists are represented just like in a real Lisp, that is, with traditional Lisp syntax.

Implements SExpression.

const IntelibTypeId& SExpression::TermType  )  const [inherited]
 

Actual S-expression type.

Definition at line 195 of file sexpress.hpp.

Referenced by SReference::DynamicCastGetPtr(), SchReference::IsEql(), LReference::IsEql(), SReference::SimpleCastGetPtr(), SchReference::TextRepresentation(), and LReference::TextRepresentation().

bool SExpression::IsChangeable  )  const [inherited]
 

Can it be changed during the lifetime of the object?

Definition at line 198 of file sexpress.hpp.

References IntelibTypeId::IsChangeable().

virtual bool SExpression::SpecificEql const SExpression  )  const [virtual, inherited]
 

Are the two objects EQL (while not EQ).

This function is overriden by those SExpressions able to be EQL while being not EQ.

Warning:
It is not demanded that this function return true if it's arguments are the same SExpression (that is, they're EQ). It is only called by the EQL predicate implementation when it has been checked that the operands are not the same object.

Reimplemented in SExpressionInt, SExpressionFloat, SExpressionChar, and SExpressionString.

Definition at line 235 of file sexpress.hpp.

Referenced by SchReference::IsEql(), and LReference::IsEql().

bool GarbageSafe::CanDie  )  [protected, inherited]
 

Is it OK to delete the object now?

Our children have no access to the private attribute RefCount and should never need it except when checking if the destruction is not an error. This solves the problem.

Definition at line 53 of file refcount.hpp.


Member Data Documentation

IntelibTypeId SExpressionBacklink::TypeId [static]
 

Type identifier.

Reimplemented from SExpressionCons.

Referenced by SExpressionBacklink().


The documentation for this class was generated from the following files:
Generated on Tue Dec 18 00:41:03 2007 for InteLib by  doxygen 1.4.1