PowerCircuit.h

Go to the documentation of this file.
00001 /*
00002  * PowerCircuit.h
00003  *
00004  *  Created on: 23.03.2011
00005  *      Authors: Juern, ArminW
00006  */
00007 
00008 
00064 #ifndef POWERCIRCUIT_H_
00065 #define POWERCIRCUIT_H_
00066 
00067 namespace PC
00068 {
00069 
00070 /*
00071  * Forward declarations of the main classes
00072  */
00073 class PowerCircuit;
00074 class Marking;
00075 class Node;
00076 
00089 class Node
00090 {
00091 public:
00092         PowerCircuit*           pc;
00093         int                                     id;
00094 
00095                                                 Node(): pc(NULL), id(-1) {}
00096                                                 Node(PowerCircuit* p, int i): pc(p), id(i) {}
00097         bool                            isReduced();
00098         bool                            isDefined();
00099         Node                            clone();
00100         int                                     getOrder();
00101         Marking                         getSuccessorMarking();
00102         bool                            operator==(Node n);
00103 
00104 };
00105 
00132 class Marking
00133 {
00134 public:
00135         PowerCircuit*           pc;
00136         int                                     id;
00137 
00138                                                 Marking(): pc(NULL), id(-1) {}
00139                                                 Marking(PowerCircuit* p, int i);
00140                                                 Marking(const Marking& m);
00141                                                 Marking& operator= (const Marking& rhs);
00142                                                 ~Marking();
00143 
00144         bool                            isReduced();
00145         Marking                         clone();
00146         Marking                         copy();
00147         std::list<Node>         getNodes();
00148         int                                     getSign(Node n);
00149         Marking                         operator++(int dummy);
00150         Marking                         operator-();
00151         Marking                         operator+(const Marking& m);
00152         Marking                         operator&(const Marking& m);
00153         bool                            operator<(const Marking& m);
00154         bool                            operator>(const Marking& m);
00155         bool                            operator<=(const Marking& m);
00156         bool                            operator>=(const Marking& m);
00157         bool                            operator==(const Marking& m);
00158         bool                            operator!=(const Marking& m);
00159         bool                            isSuccessorMarking();
00160         bool                            isDefined();
00161         Node                            getIncidentNode();
00162         Node                            getSmallestNode();
00163 };
00164 
00170 class PowerCircuit
00171 {
00172 private:
00173         // Internal helper methods (these are mostly called by the classes Node and Marking)
00174 
00175         virtual void                    incMarkingRefCount(const Marking& mark) = 0;
00176         virtual void                    decMarkingRefCount(Marking& mark) = 0;
00177 
00178         virtual Marking                 addMarkings(const Marking& m1, const Marking&  m2) = 0;
00179         virtual Marking                 invMarking(const Marking& m) = 0;
00180         virtual Marking                 incMarking(const Marking& m) = 0;
00181         virtual Marking                 intersectMarkings(const Marking& m1, const Marking&  m2) = 0;
00182         virtual Marking                 cloneMarking(const Marking& m) = 0;
00183         virtual Node                    cloneNode(Node n) = 0;
00184         virtual Marking                 copyMarking(const Marking& m) = 0;
00185         virtual bool                    isMarkingReduced(const Marking& m) const = 0;
00186         virtual int                             compareMarkings(const Marking& m1, const Marking&  m2) = 0;
00187         virtual int                             getRedNodeOrd(Node n) = 0;
00188         virtual int                             getNodeSignInMarking(Node n, const Marking&  m) const = 0;
00189         virtual bool                    isSuccessorMarking(const Marking& m) const = 0;
00190         virtual Node                    getIncidentNode(const Marking& m) = 0;
00191         virtual Node                    getSmallestNodeInMarking(const Marking& m) = 0;
00192         virtual Marking                 getSuccMarking(Node n) = 0;
00193 
00194 
00195         friend class Node;
00196         friend class Marking;
00197 
00198 public:
00199         // Construction and destruction
00200                                                         PowerCircuit() {}
00201         virtual                                 ~PowerCircuit() {}
00202 
00203 
00204         // Operations on power circuit
00205 
00209         virtual void                    reduce() = 0;
00210 
00216         virtual void                    reduce(std::vector<Node>& nodeVector, std::vector<Marking>& markingVector) = 0;
00217 
00221         virtual Marking                 createMarking(int i = 0) = 0;
00222 
00226         virtual Marking                 createMarking(const std::list<Node>& nodes) = 0;
00227 
00231         virtual Marking                 createMarking(const std::list<Node>& nodeList, const std::list<int>& signList) = 0;
00232 
00237         virtual Marking                 createMarkingFromNodes(unsigned int numNodes, ...);
00238 
00242         virtual Node                    createNode(const Marking& succ) = 0;
00243 
00251         virtual void                    connect(const Marking& m, const Marking&  p) = 0;
00252 
00256         virtual void                    connectInv(const Marking& m, const Marking&  p) = 0;
00257 
00262         virtual void                    remove(const Marking& m) = 0;
00263 
00268         virtual Node                    getReducedNode(unsigned int ord) = 0;
00269 
00273         virtual std::list<Node> getNodes() = 0;
00274 
00278         virtual std::list<Marking>      getMarkings() = 0;
00279 
00283         virtual std::list<Node> getMarkingNodes(const Marking& m)  = 0;
00284 
00290         virtual PowerCircuit*   clone(std::vector<Marking>& markingsToClone) = 0;
00291 
00292         virtual void                    draw(std::string filename, Marking highlight1 = Marking(), Marking highlight2 = Marking(), Marking highlight3 = Marking(), Marking highlight4 = Marking(), Marking highlight5 = Marking(), Marking highlight6 = Marking(), Marking highlight7 = Marking(), Marking highlight8 = Marking(), Marking highlight9 = Marking());
00293 
00294         // Statistical data of this power circuit
00295         int                                     getNumEdges();
00296         int                                     getNumNodes();
00297         int                                     getNumMarkings();
00298 
00302         virtual void                    printStatistics(std::ostream& os = std::cout);
00303 
00307         virtual void                    print(std::ostream& os= std::cout) = 0;
00308 };
00309 
00310 }
00311 
00312 #endif /* POWERCIRCUIT_H_ */
00313 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Mon Sep 26 18:43:45 2011 for CRyptography And Groups (CRAG) by  doxygen 1.6.1