]> AND Private Git Repository - blast.git/blob - AbstractBlock.h
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
started to include patterns in implementation
[blast.git] / AbstractBlock.h
1 #ifndef __ABSTRACTBLOCK_H__\r
2 #define __ABSTRACTBLOCK_H__\r
3 \r
4 #include <iostream>\r
5 \r
6 #include <QtCore>\r
7 \r
8 class AbstractInterface;\r
9 class BlockParameter;\r
10 \r
11 #define AB_TO_REF(ptr) ((ReferenceBlock*)ptr)\r
12 #define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr)\r
13 #define AB_TO_GRP(ptr) ((GroupBlock*)ptr)\r
14 \r
15 using namespace std;\r
16 using namespace Qt;\r
17 \r
18 class AbstractBlock {\r
19 \r
20 public:  \r
21       \r
22   AbstractBlock();\r
23   AbstractBlock(const QString& _name);\r
24   virtual ~AbstractBlock();\r
25 \r
26   // getters\r
27   inline QString getName() { return name; }\r
28   inline int nbParameters() { return params.size(); }\r
29   inline QList<BlockParameter *> getParameters() { return params; }\r
30   inline QList<AbstractInterface*> getInputs() { return inputs; }\r
31   inline QList<AbstractInterface*> getOutputs() { return outputs; }\r
32   inline QList<AbstractInterface*> getBidirs() { return bidirs; }\r
33   QList<BlockParameter *> getUserParameters();\r
34   QList<BlockParameter *> getGenericParameters();\r
35   QList<BlockParameter *> getPortParameters();\r
36   QList<BlockParameter *> getWishboneParameters();\r
37   inline AbstractBlock* getParent() { return parent; }\r
38   inline QList<int> getProductionCounter() { return productionCounter; }\r
39   inline int getDelta() { return delta; }\r
40   \r
41   // setters\r
42   void setName(const QString& str);\r
43   virtual void setParent(AbstractBlock* _parent);\r
44   inline void setProductionCounter(QList<int> pattern) { productionCounter = pattern; }\r
45   inline void setDelta(int _delta) { delta = _delta; }\r
46 \r
47   // testers\r
48   virtual bool isReferenceBlock();\r
49   virtual bool isFunctionalBlock();\r
50   virtual bool isGroupBlock();\r
51   virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)\r
52   virtual bool isTopGroupBlock();\r
53   bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely\r
54   bool isWBConfigurable();\r
55 \r
56   // others\r
57   virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull   \r
58 \r
59   void addParameter(BlockParameter *param);\r
60   void addInterface(AbstractInterface *inter);\r
61   void removeInterface(AbstractInterface *inter);\r
62   void removeAllInterfaces();\r
63   void defineBlockParam(BlockParameter *param);\r
64 \r
65   QList<AbstractInterface *> getInterfaces(); //! return all interfaces\r
66   QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data\r
67   QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control\r
68   QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control\r
69   AbstractInterface* getIfaceFromName(QString name);\r
70   BlockParameter* getParameterFromName(QString name);\r
71 \r
72   // patterns\r
73   virtual void computeOutputPattern(int nbExec = -1) = 0;\r
74   \r
75 protected:\r
76 \r
77 \r
78   QString name;\r
79 \r
80   // parameters\r
81   QList<BlockParameter *> params;\r
82 \r
83   // interfaces\r
84   QList<AbstractInterface*> inputs;\r
85   QList<AbstractInterface*> outputs;\r
86   QList<AbstractInterface*> bidirs;\r
87   \r
88   // others\r
89   \r
90   // patterns\r
91   QList<int> productionCounter; //! only usefull for output interfaces\r
92   int delta;\r
93   \r
94   // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents\r
95   AbstractBlock* parent;\r
96 };\r
97 \r
98 #endif // __ABSTRACTBLOCK_H__\r