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;
45 static const std::string CELLTYPE_PLUGIN_IN;
46 static const std::string CELLTYPE_PLUGIN_OUT;
48 static const std::string CELLCODENAME_EMPTY;
50 static TKContainer* createContainer();
53 virtual ~TKContainer();
55 const TKCellMap* getCells() { return &mCells; }
56 const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
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);
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();
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);
79 virtual void setValue(std::string key, float value) = 0;
80 inline virtual float getValue(std::string key) const = 0;
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;
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; }
95 TKCellMap mInpInterfaceCells;
96 TKCellMap mOutInterfaceCells;
97 TKCellMap mNonInterfaceCells;
98 TKCellCodeMap mCellCodes;
99 std::string mContainerRootPath;
101 TKCellCode *mEmptyCellClass;