Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

circuitADT.h

Go to the documentation of this file.
00001 // SuperMix version 1.0  C++ source file
00002 //
00003 // Copyright (c) 1999 California Institute of Technology.
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms for noncommercial
00007 // purposes are permitted provided that the above copyright notice and
00008 // this paragraph are duplicated in all such forms and that any
00009 // documentation and other materials related to such distribution and
00010 // use acknowledge that the software was developed by California
00011 // Institute of Technology. Redistribution and/or use in source or
00012 // binary forms is not permitted for any commercial purpose. Use of
00013 // this software does not include a permitted use of the Institute's
00014 // name or trademark for any purpose.
00015 //
00016 // DISCLAIMER:
00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00021 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00026 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00028 // MATERIALS.
00029 //
00030 /**************************************************************\
00031 *                                                              *
00032 * circuitADT.h                                                 *
00033 *                                                              *
00034 * John Ward, September 10, 1997                                *
00035 *                                                              *
00036 * 8/21/98: added pop() to portVector                           *
00037 *                                                              *
00038 * Abstract data types to assist in building up circuits.       *
00039 * These classes are used by circuit.cc.                        *
00040 *                                                              *
00041 *   class nportSet                                             *
00042 *   class tmpList                                              *
00043 *   class portStack                                            *
00044 *   class portVector                                           *
00045 *                                                              *
00046 \**************************************************************/
00047 
00048 #ifndef CIRCUITADT_H
00049 #define CIRCUITADT_H 1
00050 
00051 #include "nport.h"
00052 #include "connection.h"
00053 
00054 /**************************************************************\
00055 *                                                              *
00056 * class nportSetNode                                           *
00057 *                                                              *
00058 \**************************************************************/
00059 class nportSetNode
00060 {
00061 public:
00062   nportSetNode *next;
00063   nportSetNode *prev;
00064   unsigned long key;
00065   nport *dev;
00066 };
00067 
00068 /**************************************************************\
00069 *                                                              *
00070 * class nportSet                                               *
00071 *                                                              *
00072 * nportSet is used to hold the set of all devices used in a    *
00073 * circuit.                                                     *
00074 *                                                              *
00075 \**************************************************************/
00076 class nportSet
00077 {
00078 private:
00079   // The head points to the first node in the list.
00080   nportSetNode *head;
00081 
00082   // The number of devices in the set.
00083   int numnodes;
00084 
00085   // Return a pointer to the node containing the desired device.
00086   // Find leaves the node in the set.
00087   // Find returns a 0 if the device isn't in the set.
00088   nportSetNode *find(unsigned long id);
00089 
00090   // Remove removes the node from the set and deletes it.
00091   // The device held in the node is not deleted.
00092   void remove(nportSetNode *n);
00093 
00094 public:
00095   // Default constructor creates the empty set.
00096   nportSet();
00097 
00098   // Copy constructor creates a complete new copy of the set s.
00099   // NOTE:  The devices themselves don't get copied!
00100   nportSet(const nportSet & s);
00101 
00102   // The destructor must free each node of the set.
00103   // NOTE:  The devices don't get deleted.
00104   ~nportSet();
00105  
00106   // Return the number of devices in the set.
00107   int len() const;
00108 
00109   // Add a device to the set.
00110   // Add has no effect if the device is already in the set.
00111   void add(nport *n);
00112 
00113   // Remove device with id from the set and return it.
00114   // Return 0 if device not found.
00115   nport *pop(unsigned long id);
00116 
00117   // Remove and return the device at the head of the set.
00118   // Return 0 if list is empty.
00119   nport *pop();
00120 
00121   // We must overload the = operator because we use dynamic memory
00122   nportSet& operator=(const nportSet&);
00123 
00124   // Debugging routine.
00125   void show();
00126 };
00127 
00128 /**************************************************************\
00129 *                                                              *
00130 * class tmpListNode                                            *
00131 *                                                              *
00132 \**************************************************************/
00133 class tmpListNode
00134 {
00135 public:
00136   tmpListNode *next;
00137   tmpListNode *prev;
00138   connection *dev;
00139 };
00140 
00141 /**************************************************************\
00142 *                                                              *
00143 * class tmpList                                                *
00144 *                                                              *
00145 * tmpList is used to hold temporary connection devices until   *
00146 * they are needed, after which they must be deleted.           *
00147 *                                                              *
00148 \**************************************************************/
00149 class tmpList
00150 {
00151 private:
00152   // The head points to the first node in the list.
00153   tmpListNode *head;
00154 
00155   // The number of devices in the list.
00156   int numnodes;
00157 
00158   // Return a pointer to the node containing the desired device.
00159   // Find leaves the node in the list.
00160   // Find returns a 0 if the device isn't in the list.
00161   tmpListNode *find(port p);
00162 
00163   // Remove removes the node from the list and deletes it.
00164   void remove(tmpListNode *n);
00165 
00166 public:
00167   // Default constructor creates the empty list.
00168   tmpList();
00169 
00170   // Copy constructor creates a complete new copy of the list l.
00171   // NOTE:  The devices themselves don't get copied!
00172   tmpList(const tmpList & l);
00173 
00174   // The destructor must free each node of the list.
00175   // NOTE:  The devices don't get deleted.
00176   ~tmpList();
00177  
00178   // Return the number of devices in the list.
00179   int len() const;
00180 
00181   // Add a device to the list.
00182   // Device is added even if it is already in the list.
00183   void add(connection *c);
00184 
00185   // Remove device with port from the list and return it.
00186   // Return 0 if device not found.
00187   connection *pop(port p);
00188 
00189   // Remove and return the device at the head of the list.
00190   // Return 0 if list is empty.
00191   connection *pop();
00192 
00193   // We must overload the = operator because we use dynamic memory
00194   tmpList& operator=(const tmpList&);
00195 
00196   // Debugging routine.
00197   void show();
00198 };
00199 
00200 /**************************************************************\
00201 *                                                              *
00202 * class portStackNode                                          *
00203 *                                                              *
00204 \**************************************************************/
00205 class portStackNode
00206 {
00207 public:
00208   portStackNode *next;
00209   portArray cons;
00210 };
00211 
00212 /**************************************************************\
00213 *                                                              *
00214 * class portStack                                              *
00215 *                                                              *
00216 * portStack is used to hold a stack of connections to make.    *
00217 *                                                              *
00218 \**************************************************************/
00219 class portStack
00220 {
00221 private:
00222   // The head points to the first node in the stack.
00223   portStackNode *head;
00224 
00225 public:
00226   // Default constructor creates the empty stack.
00227   portStack();
00228 
00229   // Copy constructor creates a complete new copy of the stack s.
00230   portStack(const portStack & s);
00231 
00232   // The destructor must free each node of the stack.
00233   ~portStack();
00234  
00235   // Return TRUE if the stack is empty.
00236   int isEmpty();
00237 
00238   // Return TRUE if the port is already in the stack.
00239   int isPresent(port);
00240 
00241   // Add a pair of ports to connect to the stack.
00242   // push fails if portArray is not of length 2.
00243   void push(portArray);
00244 
00245   // Remove a pair of ports to connect from the stack.
00246   // Throw a fatal error if the stack is empty.
00247   portArray pop();
00248 
00249   // We must overload the = operator because we use dynamic memory
00250   portStack& operator=(const portStack&);
00251 
00252   // Debugging routine.
00253   void show();
00254 };
00255 
00256 /**************************************************************\
00257 *                                                              *
00258 * class portVectorNode                                         *
00259 *                                                              *
00260 \**************************************************************/
00261 class portVectorNode
00262 {
00263 public:
00264   portVectorNode *next;
00265   portVectorNode *prev;
00266   int key;
00267   port label;
00268 };
00269 
00270 /**************************************************************\
00271 *                                                              *
00272 * class portVector                                             *
00273 *                                                              *
00274 * portVector is used to keep track of the order that the       *
00275 * ports of a circuit are to be assigned after the circuit      *
00276 * is calculated.                                               *
00277 *                                                              *
00278 \**************************************************************/
00279 class portVector
00280 {
00281 private:
00282   // The head points to the first node in the list.
00283   portVectorNode *head;
00284 
00285   // The number of ports in the list.
00286   int numnodes;
00287 
00288 public:
00289   // Default constructor creates an empty list.
00290   portVector();
00291 
00292   // Copy constructor creates a complete new copy of the vector v.
00293   portVector(const portVector & v);
00294 
00295   // The destructor must free each node of the list.
00296   ~portVector();
00297  
00298   // Return the number of ports in the list.
00299   int len() const;
00300 
00301   // Return TRUE if the port is already in the list.
00302   int isPresent(port);
00303 
00304   // Add a port to the list.
00305   // Vector will increase in size, and the port will get added to the end.
00306   int add(port p);
00307 
00308   // Remove the most recently added port. Returns the port just removed.
00309   // It is a fatal error to attempt a pop from an empty portVector
00310   port pop();
00311 
00312   // Return port with this index.  Port stays in list.
00313   port get(int index) const;
00314 
00315   // We must overload the = operator because we use dynamic memory
00316   portVector& operator=(const portVector&);
00317 };
00318 
00319 #endif /* CIRCUITADT_H */

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7