1 // Copyright (c) 2012 Dennco Project
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.
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.
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/>.
17 // Created by tkawata on 12/11/2011.
20 #ifndef __INCLUDE_TKCONTAINER__
21 #define __INCLUDE_TKCONTAINER__
35 typedef std::map<std::string, TKCell*> TKCellMap;
36 typedef std::map<std::string, TKCellCode*> TKCellCodeMap;
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;
46 static const std::string CELLCODENAME_EMPTY;
48 static TKContainer* createContainer();
51 virtual ~TKContainer();
53 const TKCellMap* getCells() { return &mCells; }
54 const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
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);
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();
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);
77 virtual void setValue(std::string key, float value) = 0;
78 inline virtual float getValue(std::string key) const = 0;
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;
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; }
92 TKCellMap mInpInterfaceCells;
93 TKCellMap mOutInterfaceCells;
94 TKCellMap mNonInterfaceCells;
95 TKCellCodeMap mCellCodes;
96 std::string mContainerRootPath;
98 TKCellCode *mEmptyCellClass;