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

model/topos/SHypercube.h

Go to the documentation of this file.
00001 /* #start# ***********************************************************
00002 
00003            Scheduling Simulator
00004         Lehrstuhl f"ur Effiziente Algorithmen
00005            Technische Universit"at M"unchen
00006 
00007  File    : $Id: SHypercube.h,v 1.5 2003/01/08 18:57:14 meierb Exp $
00008 
00009  Purpose : 
00010 
00011  RCS-Log:
00012  $Log: SHypercube.h,v $
00013  Revision 1.5  2003/01/08 18:57:14  meierb
00014  added randomized release times
00015 
00016  Revision 1.1.1.1  2002/12/02 22:26:19  meierb
00017  my_schedule
00018 
00019  Revision 1.3  2002/11/09 23:21:58  taeubig
00020  Added std:: for standard namespace,
00021  realtive path corrections for header includes
00022 
00023  Revision 1.2  2002/11/07 12:33:25  taeubig
00024  Added class keyword to friend declaration
00025 
00026  Revision 1.1  2002/08/29 12:59:59  taeubig
00027  Added the sources
00028 
00029  Revision 1.3  2000/06/20 00:03:33  taeubig
00030  Removed minor bugs
00031 
00032  Revision 1.2  2000/05/30 22:39:37  taeubig
00033  Bugs and minor changes
00034 
00035  Revision 1.1  2000/05/29 14:44:27  taeubig
00036  Moved topology related stuff into subdirectory topos
00037 
00038  Revision 1.2  2000/05/29 14:01:26  taeubig
00039  Added SComplexPosition
00040 
00041  Revision 1.1  2000/05/27 00:55:04  taeubig
00042  Added files for hypercube topology
00043 
00044 
00045  * #end# ************************************************************* */
00046 
00047 #ifndef SHYPERCUBE_H
00048 #define SHYPERCUBE_H
00049 
00050 // system header files
00051 #include <iostream>
00052 
00053 #include <LEDA/array.h>
00054 #include <LEDA/h_array.h>
00055 
00056 // project header files
00057 #include "STopology.h"
00058 #include "SHypercubeMod.h"
00059 #include "SHypercubePosition.h"
00060 
00061 // ------------------------------------------------------------
00062 
00063 class SHypercubeEntry {
00064 public:
00065   int _ID, _dim;
00066   const SHypercubePosition *_pos;  // do not forget to delete outside
00067   //SHypercubeEntry() : _ID(0), _dim(0), _pos(NULL) { assert(false); };
00068   SHypercubeEntry(int id, int dim, const SHypercubePosition *pos) :
00069     _ID(id), _dim(dim), _pos(pos) {};
00070 
00071   friend std::istream &operator>>(std::istream &i, SHypercubeEntry &e)
00072     { return i; };
00073   friend std::ostream &operator<<(std::ostream &o, const SHypercubeEntry &e)
00074     { return o; };
00075 };
00076 
00077 // ------------------------------------------------------------
00078 
00079 class SHypercube : public virtual STopology {
00080   TYPEINFO0(SHypercube, "hypercube");
00081   friend class SHypercubeMod;
00082 public:
00086   SHypercube(int dim);
00087 
00090   virtual ~SHypercube() {}
00091 
00094   virtual STopologyMod &getModifier() 
00095     { return _mod; };
00096 
00101   virtual int getCount() const {
00102     int count = 1;
00103     for (int i=0; i<_dim; i++)
00104       count *= 2;
00105     return count;
00106   };
00107   
00111   virtual int getDim() const { return _dim; };
00112 
00117   virtual int getIDAt(int pos) const;
00118   
00123   virtual int getPos(int ID) const;
00124   
00129   virtual bool isPosFree(int pos) const;
00130 
00136   virtual bool canEmbedAt(const STopology &top, int pos) const;
00137   virtual bool canEmbedAt(const SComplexPosition &rHcPos) const;
00138 
00139   // /** @return list of all position where the topology may be embedded */
00140   //   virtual list<int> canEmbedAt(const STopology &top) const {
00141   //     // MISSING IMPLEMENTATION !
00142   //     return _free;
00143   //   }
00144   
00150   virtual void embed(const STopology& top, int pos, int ID)
00151     { assert(false); }
00152   virtual void embed(const STopology& top,
00153          const SComplexPosition *pHcPos, int ID);
00154   
00158   virtual void remove(int ID);
00159   
00162   virtual void clear();
00163 
00164   virtual bool fitsInto(const STopology *top) const {
00165     const SHypercube *hc = dynamic_cast<const SHypercube*>(top);
00166     return (_dim <= hc->getDim());
00167   }
00168 
00169 private:
00170   int _dim;
00171 
00172   SHypercubeMod _mod;
00173   //list<int> _free; 
00174 
00175 protected:
00176   //leda_array<int> _idAtPos;
00177   // Hashing array for getPos
00178   leda_h_array<int, SHypercubeEntry*> _IDtoEntry;
00179   static SHypercubeEntry _defaultEntry;
00180 
00181   void setSize(int dim);
00182 
00183 };
00184 
00185 #endif //SHYPERCUBE_H

Generated on Thu May 22 16:48:09 2003 for Sketch-it! by doxygen1.2.18