OSDN Git Service

[denncoCreator] fixed a crash bug.
[dennco/denncoCreator.git] / Source / engine / layer1 / TKContainer.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 12/11/2011.
18 //
19
20 #ifndef __INCLUDE_TKCONTAINER__
21 #define __INCLUDE_TKCONTAINER__
22
23 #include "TKLock.h"
24
25 #include <string>
26 #include <map>
27
28 class TKCell;
29 class TKReceptor;
30 class TKAxon;
31 class TKAxonTerminal;
32 class TKCellCode;
33 class DNStorage;
34
35 typedef std::map<std::string, TKCell*> TKCellMap;
36 typedef std::map<std::string, TKCellCode*> TKCellCodeMap;
37
38 class TKContainer
39 {
40 public:
41     static const std::string CELLTYPE_JSBASIC;
42     static const std::string CELLTYPE_OUT;
43     static const std::string CELLTYPE_IN;
44     static const std::string CELLTYPE_BASICSTORAGE;
45     static const std::string CELLTYPE_PLUGIN_IN;
46     static const std::string CELLTYPE_PLUGIN_OUT;
47
48     static const std::string CELLCODENAME_EMPTY;
49
50     static TKContainer* createContainer();
51     virtual void init();
52
53     virtual ~TKContainer();
54
55     const TKCellMap* getCells() { return &mCells; }
56     const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
57
58     void        setContainerRootPath(std::string containerPath) { mContainerRootPath = containerPath; }
59     std::string getContainerRootPath() { return mContainerRootPath; }
60     bool        setDataStore(std::string storagePath);
61     DNStorage*  getDataStore() { return mStorage; }
62     bool        releaseDataStore();
63     TKCell*     getCell(std::string theFQNName);
64     TKCell*     getInputInterfaceCell(std::string theFQNName);
65     TKCell*     getOutputInterfaceCell(std::string theFQNName);
66     TKCellCode* getCellCode(std::string theCellCodeName);
67
68     virtual bool    doInit();
69     virtual bool    doTickInputInterfaces(float time);
70     virtual bool    doTickOutputInterfaces(float time);
71     virtual bool    doTickSignalScan(float time);
72     virtual bool    doTickFullScan(float time);
73     virtual bool    doDestroy();
74
75     virtual TKCell*         addCell(std::string theLocation, std::string theName, std::string type, std::string customScript);
76     virtual TKCell*         addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript);
77     virtual TKCellCode*     addCellCode(std::string theName, std::string theAPIType, std::string code);
78
79     virtual void            setValue(std::string key, float value) = 0;
80     inline virtual float    getValue(std::string key) const = 0;
81
82     virtual TKCell*         cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut) = 0;
83     virtual TKCell*         pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut) = 0;
84     virtual TKAxon*         axonFactory(TKCell *theOwner) = 0;
85     virtual TKReceptor*     receptorFactory(TKCell *theOwner) = 0;
86     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0;
87     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code) = 0;
88
89     virtual void            beganParsePage(const char *docRoot, const char *path) { (void)docRoot; (void)path; }
90     virtual void            endedParsePage(const char *docRoot, const char *path) { (void)docRoot; (void)path; }
91
92 protected:
93     TKContainer();
94     TKCellMap       mCells;
95     TKCellMap       mInpInterfaceCells;
96     TKCellMap       mOutInterfaceCells;
97     TKCellMap       mNonInterfaceCells;
98     TKCellCodeMap   mCellCodes;
99     std::string     mContainerRootPath;
100     DNStorage       *mStorage;
101     TKCellCode      *mEmptyCellClass;
102
103 private:
104     TKLock          mLock;
105 };
106 #endif