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
40 inline int getTraversalLevel() { return traversalLevel; }
\r
43 void setName(const QString& str);
\r
44 virtual void setParent(AbstractBlock* _parent);
\r
45 inline void setPatternComputed(bool state) { patternComputed = state; }
\r
46 inline void resetTraversalLevel() { traversalLevel = -1; }
\r
47 inline void setTraversalLevel(int level) { traversalLevel = level; }
\r
50 virtual bool isReferenceBlock();
\r
51 virtual bool isFunctionalBlock();
\r
52 virtual bool isGroupBlock();
\r
53 virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)
\r
54 virtual bool isTopGroupBlock();
\r
55 bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely
\r
56 bool isWBConfigurable();
\r
59 virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull
\r
61 void addParameter(BlockParameter *param);
\r
62 void addInterface(AbstractInterface *inter);
\r
63 void removeInterface(AbstractInterface *inter);
\r
64 void removeAllInterfaces();
\r
65 void defineBlockParam(BlockParameter *param);
\r
67 QList<AbstractInterface *> getInterfaces(int direction = AbstractInterface::AnyDirection, int purpose = AbstractInterface::AnyPurpose);
\r
68 QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data
\r
69 QList<AbstractInterface *> getDataOutputs(); //! return all inputs of type data
\r
70 QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control
\r
71 QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control
\r
72 AbstractInterface* getIfaceFromName(QString name);
\r
73 BlockParameter* getParameterFromName(QString name);
\r
76 virtual void checkInputPatternCompatibility() throw(Exception) = 0;
\r
77 virtual void computeOutputPattern(int nbExec = -1) throw(Exception) = 0;
\r
78 virtual void computeAdmittanceDelays() throw(Exception) = 0;
\r
86 QList<BlockParameter *> params;
\r
89 QList<AbstractInterface*> inputs;
\r
90 QList<AbstractInterface*> outputs;
\r
91 QList<AbstractInterface*> bidirs;
\r
96 bool patternComputed;
\r
97 int traversalLevel; // the level (0, 1, ...) during the traversal of the graph
\r
99 // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents
\r
100 AbstractBlock* parent;
\r
103 #endif // __ABSTRACTBLOCK_H__
\r