OSDN Git Service

[dennco] integrated engine related changes from denncoCreator
[dennco/dennco.git] / Source / 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*     getInterfaceCell(std::string theFQNName);
63     TKCellCode* getCellCode(std::string theCellCodeName);
64
65     bool        doInit();
66     bool        doTick(float time);
67     bool        doDestroy();
68
69     virtual TKCell*         addCell(std::string theLocation, std::string theName, std::string type, std::string customScript);
70     virtual TKCell*         addCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string customScript);
71     virtual TKCellCode*     addCellCode(std::string theName, std::string theAPIType, std::string code);
72
73     virtual void            setValue(std::string key, float value) = 0;
74     inline virtual float    getValue(std::string key) const = 0;
75
76     virtual TKCell*         cellFactory(std::string location, std::string name, std::string type, bool canInterface = true) = 0;
77     virtual TKAxon*         axonFactory(TKCell *theOwner) = 0;
78     virtual TKReceptor*     receptorFactory(TKCell *theOwner) = 0;
79     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0;
80     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code) = 0;
81
82     virtual void            beganParsePage(const char *docRoot, const char *path) {}
83     virtual void            endedParsePage(const char *docRoot, const char *path) {}
84
85 protected:
86     TKContainer();
87     TKCellMap       mCells;
88     TKCellMap       mInterfaceCells;
89     TKCellCodeMap   mCellCodes;
90     std::string     mContainerRootPath;
91     DNStorage       *mStorage;
92     TKCellCode      *mEmptyCellClass;
93
94 private:
95     TKLock          mLock;
96 };
97 #endif