NCL Composer  0.1.5
 All Classes Functions Variables Pages
IPlugin.h
1 /* Copyright (c) 2011 Telemidia/PUC-Rio.
2  * All rights reserved. This program and the accompanying materials
3  * are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors:
8  * Telemidia/PUC-Rio - initial API and implementation
9  */
10 #ifndef IPLUGIN_H
11 #define IPLUGIN_H
12 
13 #include <QObject>
14 #include <QMutexLocker>
15 #include <QMutex>
16 
17 #include "../model/Entity.h"
18 #include "../model/Project.h"
19 #include "../modules/LanguageControl.h"
20 using namespace composer::core::model;
21 
22 namespace composer {
23  namespace extension {
38 class COMPOSERCORESHARED_EXPORT IPlugin : public QObject {
39 
40  Q_OBJECT
41 
42 protected:
45 
50  QMutex mutex;
51  ILanguageProfile *languageProfile;
52 
53 public:
54  inline QString getPluginInstanceID() {
55  return this->pluginInstanceID;
56  }
57 
58  inline void setPluginInstanceID(QString pluginInstID)
59  {
60  this->pluginInstanceID = pluginInstID;
61  }
62 
63  inline void setLanguageProfile(ILanguageProfile *languageProfile)
64  {
65  this->languageProfile = languageProfile;
66  }
67 
68  inline ILanguageProfile *getLanguageProfile()
69  {
70  return this->languageProfile;
71  }
72 
78  inline void setProject(Project *project)
79  {
80  QMutexLocker locker(&mutex);
81  this->project = project;
82  }
83 
90  inline Project* getProject()
91  {
92  QMutexLocker locker(&mutex);
93  return this->project;
94  }
95 
97 
104  virtual QWidget* getWidget() { return NULL; }
105 
118  virtual bool saveSubsession() { return true; }
119 
120 public slots:
129  virtual void init() /* = 0; */ { }
130 
142  virtual void updateFromModel() /*= 0*/{}
143 
150  virtual void onEntityAdded(QString pluginID, Entity *entity) /*= 0*/
151  {
152  (void) pluginID;
153  (void) entity;
154  }
155 
163  virtual void onEntityChanged(QString pluginID, Entity *entity) /*= 0*/
164  {
165  (void) pluginID;
166  (void) entity;
167  }
168 
173  // virtual void onEntityAboutToRemove(Entity *) = 0;
181  virtual void onEntityRemoved( QString pluginID, QString entityID) /*= 0*/
182  {
183  (void) pluginID;
184  (void) entityID;
185  }
186 
193  virtual void errorMessage(QString error) /*= 0*/
194  {
195  (void) error;
196  }
197 
198 signals:
207  void addEntity( QString type, QString parentEntityId,
208  QMap<QString,QString>& atts, bool force);
216  void setAttributes( Entity *entity, QMap<QString,QString> atts,
217  bool force);
226  void removeEntity(Entity * entity, bool force);
227 
235  void setListenFilter(const QStringList &entityTypes);
236 
251  void sendBroadcastMessage(const char* msg, void *obj);
252 
262  void setPluginData(QByteArray data);
263 
269  void setCurrentProjectAsDirty();
270 
271 };
272 
273 } } //end namespace
274 
275 #endif // IPLUGIN_H