1 #ifndef __DISPATCHER_H__
2 #define __DISPATCHER_H__
15 class AbstractBoxItem;
22 class FunctionalBlock;
23 #include "Exception.h"
32 * \brief The Dispatcher class
33 * The Dispatcher class represents the control part (in MVC) of the application. It relays
34 * user's interactions with the GUI into model's modifications and feeds back them onto the view.
40 * \brief The Context enum
41 * Some methods are called while creating a design from scratch or when loading
42 * a desgin from a project file previously saved. Thus, their behavior may change
43 * according to the situation. Context is used to specifiy the situation.
44 * Must be always specified.
46 enum Context {AnyContext = 0, Design = 1, Load = 2 };
48 Dispatcher(Parameters* _params,
51 GroupWidget* loadProject(const QString& filename);
55 bool isCurrentProject;
57 /**************************
59 *************************/
61 GroupScene* getSceneById(int id);
62 GroupScene* getSceneByName(QString name);
63 BoxItem* getBoxItemById(int id);
64 GroupItem* getGroupItemById(int id);
65 InterfaceItem* getInterfaceItemById(int id);
66 inline GroupWidget* getCurrentGroup() { return currentGroupWidget; }
67 inline int getNumberOfScenes() { return groupList.length(); }
69 void showRaiseWindow(Context context, BoxItem *item);
70 void showRstClkIface(Context context, AbstractBoxItem *item);
71 void showWishboneIface(Context context, AbstractBoxItem *item);
72 void unselectAllItems(Context context, int direction=0);
73 void setCurrentGroupWidget(Context context, GroupWidget *win);
74 void changeConnectionMode(Context context, int mode = -1);
75 void setSceneCounter(Context context, int value);
78 GroupWidget* createTopScene(Context context, double mainClock = 0.0);
79 GroupWidget* createChildScene(Context context, GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
80 void destroyScene(Context context, GroupScene* scene);
81 GroupWidget *addNewEmptyGroup(Context context, GroupScene *scene, bool show = true);
82 void addNewFullGroup(Context context);
84 /**************************
86 *************************/
88 QMap<int, QString> getAllGroupNames();
92 void generateVHDL(Context context) throw(Exception);
94 /**************************
96 *************************/
97 void addBlock(Context context, int idCategory, int idBlock, int idScene, QHash<QString,int> clkRstToGen );
98 void addClkRstGenBlock(Context context, double frequency);
99 void removeBoxItem(Context context, BoxItem* item);
100 void duplicateBoxItem(Context context, BoxItem* item);
101 void renameFunctionalBlock(Context context, BoxItem* item);
102 void generateBlockVHDL(Context context, BoxItem* item);
103 void renameGroupBlock(Context context, GroupItem* item);
104 void renameStimuliItem(Context context, StimuliItem* item);
105 void removeStimuliItem(Context context, StimuliItem* item);
106 void duplicateStimuliItem(Context context, StimuliItem* item);
111 * \brief connectInterToGroup
112 * \param item item is always owned by a BoxItem
114 * This method is called only when the user right clicks on an InterfaceItem (that belongs
115 * to a BoxItem and if it is NOT connected to an InterfaceItem of the GroupItem) and chooses
116 * connect to group in the contextual menu.
117 * Thus, parameter item is always owned by a BoxItem
119 void connectInterToGroup(Context context, InterfaceItem* item);
121 * \brief removeFunctionalInterface
122 * \param item item is always owned by a BoxItem
124 * This method is called only when the user right clicks on an InterfaceItem (that belongs
125 * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
126 * Thus, parameter item is always owned by a BoxItem
128 void removeFunctionalInterface(Context context, InterfaceItem* item);
130 * \brief removeGroupInterface
131 * \param item item is always owned by a GroupItem
133 * This method is called only when the user right clicks on an InterfaceItem (that belongs
134 * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu.
135 * Thus, parameter item is always owned by a GroupItem
137 void removeGroupInterface(Context context, InterfaceItem* item);
138 void duplicateInterfaceItem(Context context, InterfaceItem* item);
139 void showProperties(Context context, InterfaceItem *inter);
140 void renameInterface(Context context, InterfaceItem* item);
141 void showPatterns(Context context, InterfaceItem* item);
142 void showModifier(Context context, InterfaceItem* item);
143 void removeModifier(Context context, InterfaceItem* item);
146 bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
147 void removeAllBlockConnections(Context context, AbstractBoxItem *item);
148 void removeConnection(Context context, ConnectionItem *conn);
149 void connectBoxItemClock(Context context, BoxItem* item, QString clkName, int idGen = 0) throw(Exception);
150 void connectBoxItemReset(Context context, BoxItem* item, QString rstName, int idGen = 0) throw(Exception);
151 void connectStimuliItemClock(Context context, StimuliItem* item, QString clkName, int idGen = 0) throw(Exception);
152 void connectStimuliItemReset(Context context, StimuliItem* item, QString rstName, int idGen = 0) throw(Exception);
156 void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs
159 void showBlocksLibrary();
162 void closeCurrentProject();
169 // attributes that corresponds to the views
170 MainWindow* mainWindow;
171 QList<GroupWidget*> groupList;
172 GroupWidget* currentGroupWidget;
173 GroupWidget *topGroupWidget;
175 static int sceneCounter;
178 #endif // __DISPATCHER_H__