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

model/topos/SSetTopology.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: SSetTopology.h,v 1.7 2003/01/24 10:05:04 hall Exp $
00008 
00009  Purpose : 
00010 
00011  * #end# ************************************************************* */
00012 
00013 #ifndef SSETTOPOLOGY_H
00014 #define SSETTOPOLOGY_H
00015 
00016 // system header files
00017 #include <iostream>
00018 
00019 #include <LEDA/array.h>
00020 #include <LEDA/h_array.h>
00021 #include <LEDA/list.h>
00022 
00023 #ifndef leda_list_item
00024 #define leda_list_item list_item
00025 #endif
00026 
00027 // project header files
00028 #include "STopology.h"
00029 #include "SSetTopologyMod.h"
00030 #include "../SPassiveMachinesMod.h"
00031 
00032 
00033 // ------------------------------------------------------------
00034 class SSetTopEntry {
00035 public:
00036   int ID, card, pos;
00037   SSetTopEntry() : ID(0), card(0), pos(-1) {};
00038   SSetTopEntry(int i, int c, int p) : ID(i), card(c), pos(p) {};
00039 
00040   friend std::istream &operator>>(std::istream &i, SSetTopEntry &e) { return i; };
00041   friend std::ostream &operator<<(std::ostream &o, const SSetTopEntry &e) { return o; };
00042 };
00043 // ------------------------------------------------------------
00052 class SSetTopology : public virtual STopology {
00053   TYPEINFO0(SSetTopology,"set")
00054   friend class SSetTopologyMod;
00055 public:
00059   SSetTopology(int cardinality);
00062   virtual ~SSetTopology() {}
00063   
00066   virtual STopologyMod &getModifier() 
00067     { return _mod; };
00068   
00073   virtual int getCount() const { return _cardinality; };
00074 
00079   virtual int getIDAt(int pos) const { return _positions[pos]; };
00080 
00087   virtual int getPos(int ID) const { return _IDtoEntry[ID]->pos; };
00088 
00093   virtual bool isPosFree(int pos) const { return _free.size() > 0; };
00094 
00098   virtual leda_list<int> getFreePos() const { return _free; };
00099 
00104   virtual bool canEmbedAt(const STopology &top, int pos) const;
00105 
00111   virtual leda_list<int> canEmbedAt(const STopology &top) const;
00112 
00118   virtual void embed(const STopology& top, int pos, int ID);
00119 
00123   virtual void remove(int ID);
00124 
00125   virtual bool fitsInto(const STopology *top) const
00126     { return (_cardinality <= top->getCount()); }
00127 
00128 private:
00129   int _cardinality;
00130   leda_list<SSetTopEntry> _tops;  // currently allocated topologies
00131   leda_array<int> _positions; // -1 if the position is free
00132   leda_h_array<int, SSetTopEntry*> _IDtoEntry;
00133   leda_list<int> _free;   // the positions in a SSetTop are irelevant ->
00134         // the list contains as many zeros as there are
00135         // free positions
00136   static leda_list<int> _zeroList;  // this list contains one zero
00137   static leda_list<int> _emptyList; // this list is empty
00138   static SSetTopEntry _defaultEntry;
00139 
00140   SSetTopologyMod _mod;
00141 
00142   // all embeddings are lost after a call to this funtion
00143   void setSize(int cardinality);
00144 };
00145 // ------------------------------------------------------------
00146 
00147 #endif //SSETTOPOLOGY_H
00148 
00149 
00150 
00151 
00152 
00153 

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