OSDN Git Service

[denncoCreator] alpha 2.0 - wrap up
[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
46     static const std::string CELLCODENAME_EMPTY;
47
48     static TKContainer* createContainer();
49     virtual void init();
50
51     virtual ~TKContainer();
52
53     const TKCellMap* getCells() { return &mCells; }
54     const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
55
56     void        setContainerRootPath(std::string containerPath) { mContainerRootPath = containerPath; }
57     std::string getContainerRootPath() { return mContainerRootPath; }
58     bool        setDataStore(std::string storagePath);
59     DNStorage*  getDataStore() { return mStorage; }
60     bool        releaseDataStore();
61     TKCell*     getCell(std::string theFQNName);
62     TKCell*     getInputInterfaceCell(std::string theFQNName);
63     TKCell*     getOutputInterfaceCell(std::string theFQNName);
64     TKCellCode* getCellCode(std::string theCellCodeName);
65
66     virtual bool    doInit();
67     virtual bool    doTickInputInterfaces(float time);
68     virtual bool    doTickOutputInterfaces(float time);
69     virtual bool    doTickSignalScan(float time);
70     virtual bool    doTickFullScan(float time);
71     virtual bool    doDestroy();
72
73     virtual TKCell*         addCell(std::string theLocation, std::string theName, std::string type, std::string customScript);
74     virtual TKCell*         addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript);
75     virtual TKCellCode*     addCellCode(std::string theName, std::string theAPIType, std::string code);
76
77     virtual void            setValue(std::string key, float value) = 0;
78     inline virtual float    getValue(std::string key) const = 0;
79
80     virtual TKCell*         cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut) = 0;
81     virtual TKAxon*         axonFactory(TKCell *theOwner) = 0;
82     virtual TKReceptor*     receptorFactory(TKCell *theOwner) = 0;
83     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0;
84     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code) = 0;
85
86     virtual void            beganParsePage(const char *docRoot, const char *path) { (void)docRoot; (void)path; }
87     virtual void            endedParsePage(const char *docRoot, const char *path) { (void)docRoot; (void)path; }
88
89 protected:
90     TKContainer();
91     TKCellMap       mCells;
92     TKCellMap       mInpInterfaceCells;
93     TKCellMap       mOutInterfaceCells;
94     TKCellMap       mNonInterfaceCells;
95     TKCellCodeMap   mCellCodes;
96     std::string     mContainerRootPath;
97     DNStorage       *mStorage;
98     TKCellCode      *mEmptyCellClass;
99
100 private:
101     TKLock          mLock;
102 };
103 #endif