DCContainer();
virtual ~DCContainer();
+ bool getIsModified() const;
+
+ DCContent* getContent() const { return d_content; }
+ DCScene* getScene() const { return d_scene; }
+ QList<DCVComponent*> getSelectedCellObjects() const;
+ virtual float getValue(std::string key) const { Q_UNUSED(key); return 0; }
+
+ TKCellCode* getEmptyCellCodeClass() const { return mEmptyCellClass; }
+ bool isScriptableCell(DCCell *cell) const;
+
+ QString getWorkFilePathForCustomScript(const DCCell *cell) const;
+ QString getWorkFilePathForCellCode(const DCCellCode *cellcode) const;
+
virtual TKCell* addCell(std::string theLocation, std::string theName, std::string type, std::string customScript);
virtual TKCell* addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript);
virtual TKCellCode* addCellCode(std::string theName, std::string theAPIType, std::string code);
- virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterface = true);
+ virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut);
virtual TKAxon* axonFactory(TKCell *theOwner);
virtual TKReceptor* receptorFactory(TKCell *theOwner);
virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner);
virtual TKCellCode* cellCodeFactory(std::string name, std::string cellapi, std::string code);
- /*
- * remove cell code from container and the page (DCVCPage) belonging.
+ /**
+ * @brief remove cell from container and the page (DCVCPage) belonging.
+ * @param cell
+ *
+ * All the axon terminals connected to this cell will also be removed after this.
+ * This expected to only be called from command classes which are defined in dceditcommands.h
+ *
+ * @return true for success, false for failure
+ */
+ bool removeCell(DCCell *cell);
+
+ /**
+ * @brief remove cell code from container and the page (DCVCPage) belonging.
+ * @param cellcode
+ *
* The cells which use the deleting cell code will have empty cell code after this.
* This expected to only be called from command classes which are defined in dceditcommands.h
+ *
+ * @return true for success, false for failure
*/
bool removeCellCode(DCCellCode *cellcode);
- /*
- * remove cell from container and the page (DCVCPage) belonging.
- * All the axon terminals connected to this cell will also be removed after this.
- * This expected to only be called from command classes which are defined in dceditcommands.h
+ /**
+ * @brief movePage
+ *
+ * @param oldContainerBasedPathName
+ * @param newContainerBasedPathName
+ *
+ * Change the name / path for a container file.
+ * All cells, cell codes and connections are updated accordingly.
+ * This expected to be called from command classes which are defined in dceditcommands.h
+ *
+ * @return pointer to a page object for the new file path or NULL when this failed.
*/
- bool removeCell(DCCell *cell);
- //
- DCContent* getContent() const { return d_content; }
- DCScene* getScene() const { return d_scene; }
- QList<DCVComponent*> getSelectedCellObjects() const;
- virtual float getValue(std::string key) const { return 0; }
+ DCVCPage* movePage(const QString &oldContainerBasedPathName, const QString &newContainerBasedPathName);
+
+ /**
+ * @brief change the path information of a cell.
+ * @param cell
+ * @param pageNewContainerBasedPathName
+ *
+ * @note This will be called from DCVCCell::changePageBelonging().
+ * This shouldn't be directly called from other methods.
+ * @return
+ */
+ bool moveCell(DCCell*cell, const QString& pageNewContainerBasedPathName);
+
+ /**
+ * @brief change the path information of a cell code.
+ * @param cellcode
+ * @param pageNewContainerBasedPathName
+ *
+ * @note This will be called from DCVCCellCode::changePageBelonging().
+ * This shouldn't be directly called from other methods.
+ * @return
+ */
+ bool moveCellCodeClass(DCCellCode*cellcode, const QString& pageNewContainerBasedPathName);
- TKCellCode* getEmptyCellCodeClass() const { return mEmptyCellClass; }
- bool isScriptableCell(DCCell *cell);
+ bool renameCell(DCCell *cell, const QString& newName);
+
+ bool renameCellCodeClass(DCCellCode *cellcode, const QString& newName);
- //
void setContent(DCContent *content);
void unselectCellObjectAll();
- virtual void setValue(std::string key, float value) {}
+ virtual void setValue(std::string key, float value) { Q_UNUSED(key); Q_UNUSED(value);}
virtual void beganParsePage(const char *docRoot, const char *path);
virtual void endedParsePage(const char *docRoot, const char *path);
void beganBuildContainer();
void endedBuildContainer();
- bool saveCustomScriptToWorkFile(TKCell *cell, std::string customScript);
- bool saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code);
+ bool saveCustomScriptToWorkFile(const DCCell *cell, std::string customScript);
+ bool saveClassScriptToWorkFile(const DCCellCode *cellCode, std::string code);
+
+ QString sysFilePathToContainerBasedPath(const QString& sysFilePath);
+ QString containerBasedPathToSysFilePath(const QString& containerBasedPath);
QString readCustomScriptFromWorkFile(const DCCell *cell);
QString readCellCodeScriptFromFile(const DCCellCode *cellcode);
+ /***************************************************************************
+ * Cell type rules
+ **************************************************************************/
+
+ /**
+ * @brief return the avaiable cell types as the list of QString
+ * @return
+ */
+ QList<QString> getAvailableCellTypes() const;
+
+ QList<QString> getAvailableScriptableCellTypes() const;
+
+ /**
+ * @brief check if given cell type can have script
+ * @param type
+ * @return true if the given cell type can have script, false if no script avaiable for the cell type.
+ */
+ bool getIsScriptable(const QString& type) const;
+
+ /**
+ * @brief return if the cell type can accept receptors.
+ * The cell which inputs value from external can not receive value from internal cells.
+ * @param type
+ * @return
+ */
+ bool getIsReceptorAvailable(const QString& type) const;
+
};
#endif // DCCONTAINER_H