1 #ifndef __ABSTRACTBLOCK_H__
\r
2 #define __ABSTRACTBLOCK_H__
\r
8 #include "AbstractInterface.h"
\r
9 class AbstractInterface;
\r
10 class BlockParameter;
\r
12 #define AB_TO_REF(ptr) ((ReferenceBlock*)ptr)
\r
13 #define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr)
\r
14 #define AB_TO_GRP(ptr) ((GroupBlock*)ptr)
\r
16 using namespace std;
\r
19 class AbstractBlock {
\r
24 AbstractBlock(const QString& _name);
\r
25 virtual ~AbstractBlock();
\r
28 inline QString getName() { return name; }
\r
29 inline int nbParameters() { return params.size(); }
\r
30 inline QList<BlockParameter *> getParameters() { return params; }
\r
31 inline QList<AbstractInterface*> getInputs() { return inputs; }
\r
32 inline QList<AbstractInterface*> getOutputs() { return outputs; }
\r
33 inline QList<AbstractInterface*> getBidirs() { return bidirs; }
\r
34 QList<BlockParameter *> getUserParameters();
\r
35 QList<BlockParameter *> getGenericParameters();
\r
36 QList<BlockParameter *> getPortParameters();
\r
37 QList<BlockParameter *> getWishboneParameters();
\r
38 inline AbstractBlock* getParent() { return parent; }
\r
39 inline bool getPatternComputed() { return patternComputed; }
\r
42 void setName(const QString& str);
\r
43 virtual void setParent(AbstractBlock* _parent);
\r
44 inline void setPatternComputed(bool state) { patternComputed = state; }
\r
47 virtual bool isReferenceBlock();
\r
48 virtual bool isFunctionalBlock();
\r
49 virtual bool isGroupBlock();
\r
50 virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)
\r
51 virtual bool isTopGroupBlock();
\r
52 bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely
\r
53 bool isWBConfigurable();
\r
56 virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull
\r
58 void addParameter(BlockParameter *param);
\r
59 void addInterface(AbstractInterface *inter);
\r
60 void removeInterface(AbstractInterface *inter);
\r
61 void removeAllInterfaces();
\r
62 void defineBlockParam(BlockParameter *param);
\r
64 QList<AbstractInterface *> getInterfaces(int direction = AbstractInterface::AnyDirection, int purpose = AbstractInterface::AnyPurpose);
\r
65 QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data
\r
66 QList<AbstractInterface *> getDataOutputs(); //! 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
73 virtual bool checkInputPatternCompatibility() = 0;
\r
74 virtual bool computeOutputPattern(int nbExec = -1) = 0;
\r
82 QList<BlockParameter *> params;
\r
85 QList<AbstractInterface*> inputs;
\r
86 QList<AbstractInterface*> outputs;
\r
87 QList<AbstractInterface*> bidirs;
\r
92 bool patternComputed;
\r
94 // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents
\r
95 AbstractBlock* parent;
\r
98 #endif // __ABSTRACTBLOCK_H__
\r