NCL Composer  0.1.5
 All Classes Functions Variables Pages
Project.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 DOCUMENT_H
11 #define DOCUMENT_H
12 
13 #include "../util/ComposerCoreControl_global.h"
14 
15 #include <QObject>
16 #include <QList>
17 #include <QStack>
18 
19 namespace composer {
20  namespace core {
21  class PluginControl;
22  class MessageControl;
23  class ProjectControl;
24  class ProjectReader;
25  namespace util {
26  class EditCommand;
27  class AddCommand;
28  class DeleteCommand;
29  }
30 } } //end namespace
31 
32 #include "../model/exception/ParentNotFound.h"
33 #include "../model/exception/EntityNotFound.h"
34 #include "../util/Utilities.h"
35 using namespace composer::core::util;
36 
37 #include "Entity.h"
38 using namespace composer::core::model;
39 
40 namespace composer {
41  namespace core {
42  namespace model {
43 
48 class COMPOSERCORESHARED_EXPORT Project : public Entity
49 {
50  Q_OBJECT
51 
52  // The following classes are "reliable" and can acess the
53  // private and protected members of Document.
54  friend class composer::core::PluginControl;
55  friend class composer::core::MessageControl;
56  friend class composer::core::ProjectControl;
57  friend class composer::core::ProjectReader;
58 
62 
63 public:
69  Entity* getEntityById(QString _id);
75  QList<Entity*> getEntitiesbyType(QString _type);
76 
82  QString getLocation();
88  QString getProjectId();
89 
93  LanguageType getProjectType();
99  QByteArray getPluginData(QString pluginId);
100 
104  QString generateUniqueNCLId(const QString &tagname);
105  QList<Entity*> getEntityByAttrId(const QString &id);
106 
107  bool isDirty();
108 
109 private:
110  QMutex *lockEntities;
111  QMutex lockLocation;
112  QMap<QString, Entity*> entities;
113  QMap<QString, QByteArray> pluginData;
115  QString projectLocation;
116  QString projectName;
117  LanguageType projectType;
119  bool dirty;
120 
121 protected:
127  explicit Project(QObject *parent = 0);
134  Project(QMap<QString,QString> &atts, QObject *parent = 0);
142  Project(QString uniqueId, QMap<QString,QString> &atts, QObject *parent = 0);
146  ~Project();
147 
153  void setLocation(QString location);
160  void setProjectType(LanguageType type);
161 
162 
163  QString model;
170  void setModelString(const QString &model) {this->model = model;}
176  QString getModelString() {return this->model;}
177 
192  bool addEntity(Entity* entity, QString parentId)
194 
201  bool setPluginData(QString pluginId, const QByteArray data);
202 
217  bool removeEntity(Entity* entity, bool appendChild)
218  throw (EntityNotFound);
219 
224  QString toString();
225 
230  void setDirty(bool isDirty);
231 
232 signals:
233  void dirtyProject(bool isDirty);
234 };
235 
236 } } } //end namespace
237 
238 #endif // DOCUMENT_H