OSDN Git Service

\[denncoCreator\] implemented remove page / cell functionality and several refactoring.
[dennco/denncoCreator.git] / Source / dccontainer.h
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Sep-30, 2012.
18 //
19 #ifndef DCCONTAINER_H
20 #define DCCONTAINER_H
21
22 #include "TKContainer.h"
23
24 class TKCell;
25 class TKCellCode;
26 class DCCell;
27 class DCCellCode;
28 class DCScene;
29 class DCContent;
30 class DCVComponent;
31 class DCUIGraphicsScene;
32
33 #include "dcvcomponent.h"
34
35 #include <QList>
36 #include <QString>
37
38 class DCContainer : public TKContainer
39 {
40     DCContent       *d_content;
41     DCScene         *d_scene;
42
43     std::string     d_factoryCachedLocation;
44     DCVCRefHolder   d_factoryCachedPageObject;
45
46     QString         d_workDirRoot;
47     QString         d_workDirCellRoot;
48     QString         d_workDirCellCodeRoot;
49
50 public:
51     DCContainer();
52     virtual ~DCContainer();
53
54     virtual TKCell*         addCell(std::string theLocation, std::string theName, std::string type, std::string customScript);
55     virtual TKCell*         addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript);
56     virtual TKCellCode*     addCellCode(std::string theName, std::string theAPIType, std::string code);
57
58     virtual TKCell*         cellFactory(std::string location, std::string name, std::string type, bool canInterface = true);
59     virtual TKAxon*         axonFactory(TKCell *theOwner);
60     virtual TKReceptor*     receptorFactory(TKCell *theOwner);
61     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner);
62     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code);
63
64     /*
65      * remove cell code from container and the page (DCVCPage) belonging.
66      * The cells which use the deleting cell code will have empty cell code after this.
67      * This expected to only be called from command classes which are defined in dceditcommands.h
68      */
69     bool                    removeCellCode(DCCellCode *cellcode);
70
71     /*
72      * remove cell from container and the page (DCVCPage) belonging.
73      * All the axon terminals connected to this cell will also be removed after this.
74      * This expected to only be called from command classes which are defined in dceditcommands.h
75      */
76     bool                    removeCell(DCCell *cell);
77     //
78     DCContent*              getContent() const { return d_content; }
79     DCScene*                getScene() const { return d_scene; }
80     QList<DCVComponent*>    getSelectedCellObjects() const;
81     virtual float           getValue(std::string key) const { return 0; }
82
83     TKCellCode*             getEmptyCellCodeClass() const { return mEmptyCellClass; }
84     bool                    isScriptableCell(DCCell *cell);
85
86     //
87     void                    setContent(DCContent *content);
88
89     void                    unselectCellObjectAll();
90
91     virtual void            setValue(std::string key, float value) {}
92
93     virtual void            beganParsePage(const char *docRoot, const char *path);
94     virtual void            endedParsePage(const char *docRoot, const char *path);
95
96     void                    beganBuildContainer();
97     void                    endedBuildContainer();
98
99     bool                    saveCustomScriptToWorkFile(TKCell *cell, std::string customScript);
100     bool                    saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code);
101
102     QString                 readCustomScriptFromWorkFile(const DCCell *cell);
103     QString                 readCellCodeScriptFromFile(const DCCellCode *cellcode);
104
105 };
106
107 #endif // DCCONTAINER_H