00001 #ifndef _DESPERADO_CHAIN_H_ 00002 #define _DESPERADO_CHAIN_H_ 00003 00004 /* vim: set ts=4 expandtab shiftwidth=4: */ 00005 00006 /****************************************************************************** 00007 00008 Copyright 2006 Digital Aggregates Corp., Arvada CO 80001-0587, USA. 00009 This file is part of the Digital Aggregates Desperado library. 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Lesser General Public 00013 License as published by the Free Software Foundation; either 00014 version 2.1 of the License, or (at your option) any later version. 00015 00016 As a special exception, if other files instantiate templates or 00017 use macros or inline functions from this file, or you compile 00018 this file and link it with other works to produce a work based on 00019 this file, this file does not by itself cause the resulting work 00020 to be covered by the GNU Lesser General Public License. However 00021 the source code for this file must still be made available in 00022 accordance with the GNU Lesser General Public License. 00023 00024 This exception does not invalidate any other reasons why a work 00025 based on this file might be covered by the GNU Lesser General 00026 Public License. 00027 00028 Alternative commercial licensing terms are available from the copyright 00029 holder. Contact Digital Aggregates Corporation for more information. 00030 00031 This library is distributed in the hope that it will be useful, 00032 but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00034 GNU Lesser General Public License for more details. 00035 00036 You should have received a copy of the GNU Lesser General 00037 Public License along with this library; if not, write to the 00038 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00039 Boston, MA 02111-1307 USA, or http://www.gnu.org/copyleft/lesser.txt. 00040 00041 $Name: $ 00042 00043 $Id: Chain.h,v 1.23 2007/01/04 23:16:03 jsloan Exp $ 00044 00045 ******************************************************************************/ 00046 00047 00063 #include "Link.h" 00064 #include "Output.h" 00065 00066 00108 class Chain : public Link { 00109 00110 public: 00111 00116 explicit Chain(); 00117 00125 virtual ~Chain(); 00126 00142 virtual bool initialize(); 00143 00149 bool isEmpty() const; 00150 00158 bool isMember(const Link* link) const; 00159 00167 virtual Link* peekFirst() const; 00168 00176 virtual Link* peekLast() const; 00177 00191 virtual Link* peekNext(const Link* previous) const; 00192 00206 virtual Link* peekPrevious(const Link* next) const; 00207 00215 virtual Link* removeFirst(); 00216 00224 virtual Link* removeLast(); 00225 00238 virtual Link* removeNext(Link* previous); 00239 00252 virtual Link* removePrevious(Link* next); 00253 00266 virtual Link* insertFirst(Link* link); 00267 00280 virtual Link* insertLast(Link* link); 00281 00297 virtual Link* insertNext(Link* previous, Link* link); 00298 00314 virtual Link* insertPrevious(Link* next, Link* link); 00315 00337 virtual void show(int level = 0, Output* display = 0, int indent = 0) const; 00338 00339 private: 00340 00346 Chain(const Chain& that); 00347 00353 Chain& operator=(const Chain& that); 00354 00355 }; 00356 00357 00358 // 00359 // Return true if the link has this chain as its root. 00360 // 00361 inline bool Chain::isMember(const Link* link) const { 00362 return link->hasRoot(this); 00363 } 00364 00365 00366 // 00367 // Return true if this chain is empty. 00368 // 00369 inline bool Chain::isEmpty() const { 00370 return !this->isChained(); 00371 } 00372 00373 00379 extern "C" int unittestChain(); 00380 00381 00382 #endif