OSDN Git Service

Checked-in DNServer implementation. Still working on.
authortkawata <takuji.kawata@gmail.com>
Sun, 29 Jan 2012 12:11:10 +0000 (21:11 +0900)
committertkawata <takuji.kawata@gmail.com>
Sun, 29 Jan 2012 12:11:10 +0000 (21:11 +0900)
21 files changed:
Source/DNContainerServer.cpp [deleted file]
Source/DNEngine.cpp [new file with mode: 0644]
Source/DNEngine.h [moved from Source/DNContainerServer.h with 61% similarity]
Source/DNServer.cpp [new file with mode: 0644]
Source/DNServer.h [new file with mode: 0644]
Source/DNServerImpl.h [new file with mode: 0644]
Source/DNSimpleWebServerImpl.cpp [new file with mode: 0644]
Source/DNSimpleWebServerImpl.h [new file with mode: 0644]
Source/TKCell.cpp
Source/TKCell.h
Source/TKContainer.cpp
Source/TKContainer.h
Source/TKJSBasicCell.cpp
Source/TKJSBasicCell.h
Source/TKJSCellBase.h
Source/TKJSContainer.cpp
Source/TKUICell.cpp
Source/TKUICell.h
Source/platform/osx/OSXDNSimpleWebServerImpl.h [new file with mode: 0644]
Source/platform/osx/OSXDNSimpleWebServerImpl.mm [new file with mode: 0644]
dennco.xcodeproj/project.pbxproj

diff --git a/Source/DNContainerServer.cpp b/Source/DNContainerServer.cpp
deleted file mode 100644 (file)
index e1544e9..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-//  Copyright (c) 2012 Dennco Project
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-//
-//  Created by tkawata on 1/6/2012.
-//
-
-#include "TKLock.h"
-#include "TKContainer.h"
-#include "DNContainerServer.h"
-#include "DNTimeKeeper.h"
-
-DNContainerServer::DNContainerServer(TKContainer *container) :
-mContainer(container)
-{
-    
-}
-
-bool DNContainerServer::startServer(int portNumber)
-{
-    
-}
-
-void DNContainerServer::stopServer()
-{
-    
-}
-
-void DNContainerServer::setTickIntervalSec(float interval)
-{
-    
-}
-
-void DNContainerServer::doTickThread()
-{
-    mTickThreadLock.lock();
-    if (mRunning)
-    {
-        //doTickThread is already running.
-        mTickThreadLock.unlock();
-        return;
-    }
-    mRunning = true;
-    mTickThreadLock.unlock();
-
-    
-    DNTimeKeeper *timeKeeper = new DNTimeKeeper();
-    
-    while(mRunning)
-    {
-        mContainer->doTick(timeKeeper->getTickTime());
-        timeKeeper->sleepUntilNextInterval();
-    }
-    
-    delete timeKeeper;
-}
-
-void DNContainerServer::processClientMessage(const char *message)
-{
-    int len = strlen(message);
-    
-    bool isPost = false;
-    const char *p;
-    
-    if (len < 4)
-    {
-        //illegal message
-        return;
-    }
-    if (strncmp(message, "POST", 4) == 0)
-    {
-        //POST message
-        p = message + 4;
-        isPost = true;
-    }
-    else if (strncmp(message, "GET", 3) == 0)
-    {
-        //GET message
-        p = message + 4;
-        isPost = false;
-    }
-    else
-    {
-        //non supported message
-        return;
-    }
-    
-    while (p)
-    {
-        
-        p++;
-    }
-}
-
-
diff --git a/Source/DNEngine.cpp b/Source/DNEngine.cpp
new file mode 100644 (file)
index 0000000..d207758
--- /dev/null
@@ -0,0 +1,115 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/28/2012.
+//
+
+
+#include "TKLock.h"
+#include "TKContainer.h"
+#include "TKUICell.h"
+#include "DNTimeKeeper.h"
+#include "DNServer.h"
+#include "DNEngine.h"
+
+static void clientRequestHandler(DNEngine *engine, DNClientRequest* request)
+{
+    if (engine)
+    {
+        engine->doClientRequest(request);
+    }
+}
+
+DNEngine::DNEngine(TKContainer *container) :
+mContainer(container),mIsRunning(false),mPortNumber(9025),mServer(NULL)
+{
+    mTimeKeeper = new DNTimeKeeper();
+
+}
+
+
+bool DNEngine::startServer(int portNumber)
+{
+    if (mServer && mServer->isRunning())
+    {
+        mServer->stop();
+        delete mServer;
+        mServer = NULL;
+    }
+    mServer = new DNServer(this, portNumber, clientRequestHandler);
+    if (mServer)
+    {
+        mServer->start();
+    }
+    return true;
+}
+
+void DNEngine::stopServer()
+{
+    if (mServer && mServer->isRunning())
+    {
+        mServer->stop();
+        delete mServer;
+        mServer = NULL;
+    }    
+}
+
+void DNEngine::setTickIntervalSec(float interval)
+{
+    if (mTimeKeeper)
+        mTimeKeeper->setIntevalSec(interval);
+}
+
+void DNEngine::doTickThread()
+{
+    mTickThreadLock.lock();
+    if (mIsRunning)
+    {
+        //doTickThread is already running.
+        mTickThreadLock.unlock();
+        return;
+    }
+    mIsRunning = true;
+    mTickThreadLock.unlock();
+    
+    
+    DNTimeKeeper *timeKeeper = new DNTimeKeeper();
+    
+    while(mIsRunning)
+    {
+        mContainer->doTick(timeKeeper->getTickTime());
+        timeKeeper->sleepUntilNextInterval();
+    }
+    
+    delete timeKeeper;
+}
+
+void DNEngine::doClientRequest(DNClientRequest *request)
+{
+    TKUICell *cell = (TKUICell*)mContainer->getInterfaceCell(request->path);
+    if (cell)
+    {
+        if (request->query)
+        {
+            request->value = cell->getValue();
+        }
+        else
+        {
+            cell->setValue(request->value);
+        }
+    }    
+}
+
similarity index 61%
rename from Source/DNContainerServer.h
rename to Source/DNEngine.h
index 5fcc0f9..144e472 100644 (file)
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 //
-//  Created by tkawata on 1/6/2012.
+//  Created by tkawata on 1/28/2012.
 //
 
-#ifndef dennco_TKContainerServer_h
-#define dennco_TKContainerServer_h
+#ifndef dennco_DNEngine_h
+#define dennco_DNEngine_h
 
 class TKContainer;
-class TKLock;
-class TKTimeKeeper;
+class DNTimeKeeper;
+class DNServer;
+class DNClientRequest;
 
-class DNContainerServer
+#include "TKLock.h"
+
+class DNEngine
 {
 public:
-    DNContainerServer(TKContainer *container);
-
-    bool            startServer(int portNumber);
-    void            stopServer();
+    DNEngine(TKContainer *container);
     
-    void            setTickIntervalSec(float interval);
+    bool        startServer(int portNumber);
+    void        stopServer();
     
-    void            doTickThread();
+    void        setTickIntervalSec(float interval);
+    
+    void        doTickThread();
+    void        doClientRequest(DNClientRequest *request);
     
-    void            processClientMessage(const char *message);
     
 private:
     TKContainer     *mContainer;
     int             mPortNumber;
-    bool            mRunning;
-    TKTimeKeeper    *timeKeeper;
     TKLock          mTickThreadLock;
+    DNServer        *mServer;
+    bool            mIsRunning;
+    DNTimeKeeper    *mTimeKeeper;
+    
     
 };
 
diff --git a/Source/DNServer.cpp b/Source/DNServer.cpp
new file mode 100644 (file)
index 0000000..cbb09cd
--- /dev/null
@@ -0,0 +1,42 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/24/2012.
+//
+
+#include "DNEngine.h"
+#include "DNServer.h"
+#include "DNServerImpl.h"
+
+DNServer::DNServer(DNEngine* engine, unsigned int portNumber, DNClientRequestHandler handler)
+{
+    impl = DNServerImpl::create(engine, portNumber, handler);
+}
+
+bool DNServer::isRunning()
+{
+    return impl->isRunning();
+}
+
+void DNServer::start()
+{
+    impl->start();
+}
+
+void DNServer::stop()
+{
+    impl->stop();
+}
diff --git a/Source/DNServer.h b/Source/DNServer.h
new file mode 100644 (file)
index 0000000..ca673f6
--- /dev/null
@@ -0,0 +1,54 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/24/2012.
+//
+
+#ifndef dennco_DNServer_h
+#define dennco_DNServer_h
+
+#include "TKLock.h"
+
+#include <string>
+
+class DNEngine;
+class DNServerImpl;
+
+class DNClientRequest
+{
+public:
+    bool        query;
+    std::string path;
+    float       value;
+};
+
+typedef void (*DNClientRequestHandler)(DNEngine* dc, DNClientRequest *request);
+
+class DNServer
+{
+public:
+    DNServer(DNEngine*, unsigned int portNumber, DNClientRequestHandler hendler);
+    
+    bool    isRunning();
+    void    start();
+    void    stop();
+
+private:
+    DNServerImpl *impl;
+    
+};
+
+#endif
diff --git a/Source/DNServerImpl.h b/Source/DNServerImpl.h
new file mode 100644 (file)
index 0000000..efa47b8
--- /dev/null
@@ -0,0 +1,38 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/28/2012.
+//
+
+#ifndef dennco_DNServerImpl_h
+#define dennco_DNServerImpl_h
+
+#include "DNServer.h"
+
+class DNEngine;
+
+class DNServerImpl
+{
+public:
+    static DNServerImpl*    create(DNEngine *engine, unsigned int portNumber, DNClientRequestHandler handler);
+    virtual bool            isRunning() = 0;
+    virtual void            start() = 0;
+    virtual void            stop() = 0;
+
+};
+
+
+#endif
diff --git a/Source/DNSimpleWebServerImpl.cpp b/Source/DNSimpleWebServerImpl.cpp
new file mode 100644 (file)
index 0000000..7fdac70
--- /dev/null
@@ -0,0 +1,185 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/28/2012.
+//
+
+#include "DNSimpleWebServerImpl.h"
+
+#include <string>
+
+//static
+DNHTTPRequest* DNSimpleWebServerImpl::parseHttpRequest(const char *message)
+{
+    size_t len = strlen(message);
+    
+    bool isPost = false;
+    bool isValid = true;
+    std::string path;
+    std::string host;
+    int contentLen = 0;
+    std::string postbody;
+    
+    const char *p;
+    if (len < 5)
+    {
+        //illegal message
+        return NULL;
+    }
+    if (strncmp(message, "POST ", 5) == 0)
+    {
+        //POST message
+        p = message + 4;
+        isPost = true;
+    }
+    else if (strncmp(message, "GET ", 4) == 0)
+    {
+        //GET message
+        p = message + 3;
+        isPost = false;
+    }
+    else
+    {
+        //non supported message
+        isValid = false;
+    }
+    
+    //get URI
+    if (isValid)
+    {
+        while (*p && *p == ' ' && *p != '\r' && *p != '\n')
+        {
+            p++;
+        }
+        if (!*p || *p == '\r' || *p == '\n')
+        {
+            isValid = false;
+        }
+        else
+        {
+            const char *s = p;
+            while (*p && *p != ' ' &&  *p != '\r' && *p != '\n')
+                p++;
+            
+            if (*p != ' ' && p - s < 1)
+            {
+                isValid = false;
+            }
+            else
+            {
+                path = std::string(s, p - s);
+            }
+        }
+    }
+    
+    if (isValid)
+    {
+        while(*p)
+        {
+            if (*p == '\n' && *(p-1) == '\r')
+            {
+                break;
+            }
+            p++;
+        }
+        if (!*p)
+            isValid = false;
+    }
+    
+    if (isValid)
+    {
+        p++;
+        const char *hs = p;
+        const char *he = p-1;
+        while (*p)
+        {
+            if (*p == '\n' && *(p-1) == '\r' && *(p-2) == '\n')
+            {
+                he = p;
+            }
+            p++;
+        }
+        
+        p = hs;
+        while(p <= he && *p)
+        {
+            if (*p == ':')
+            {
+                //Host:
+                if (p-hs >= 5 && strncmp("Host", p-4, 4))
+                {
+                    p++;
+                    const char *tmp = p;
+                    while(p <= hs && *p && *p !='\r')
+                    {
+                        p++;
+                    }
+                    if (tmp < p - 1)
+                    {
+                        host = std::string(tmp, p - tmp - 1);
+                    }
+                }
+                
+                //Content-Length:
+                if (p-hs >= 15 && strncmp("Content-Length", p-14,14))
+                {
+                    p++;
+                    const char *tmp = p;
+                    while(p <= hs && *p && *p !='\r')
+                    {
+                        p++;
+                    }
+                    if (tmp < p - 1)
+                    {
+                        contentLen = atoi(std::string(tmp, p - tmp - 1).c_str());
+                    }                    
+                }
+            }
+            
+            p++;
+        }
+        
+        //POST BODY
+        if (isPost && contentLen>0)
+        {
+            int bl = 0;
+            const char *ps = he+1;
+            while (*(ps + bl) && bl < contentLen)
+            {
+                bl++;
+            }
+            
+            postbody = std::string(ps, bl);
+        }
+    }
+    
+    if (isValid)
+    {
+        DNHTTPRequest *request = new DNHTTPRequest();
+        request->isPost = isPost;
+        request->uri = path;
+        if (isPost)
+        {
+            request->postData = postbody;
+        }
+        return request;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
diff --git a/Source/DNSimpleWebServerImpl.h b/Source/DNSimpleWebServerImpl.h
new file mode 100644 (file)
index 0000000..fdc1488
--- /dev/null
@@ -0,0 +1,40 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/28/2012.
+//
+
+#ifndef dennco_DNSimpleWebServer_h
+#define dennco_DNSimpleWebServer_h
+
+#include <string>
+
+#include "DNServerImpl.h"
+
+class DNHTTPRequest
+{
+public:
+    std::string uri;
+    bool        isPost;
+    std::string postData;
+};
+
+class DNSimpleWebServerImpl : public DNServerImpl
+{
+    static DNHTTPRequest*   parseHttpRequest(const char *message);
+};
+
+#endif
index 72dc2e1..61d7d08 100644 (file)
@@ -26,8 +26,8 @@
 #include "TKLog.h"
 #include <string>
 
-TKCell::TKCell(TKContainer *container, std::string location, std::string name)
-: mContainer(container), mAxon(NULL), mCellCode(NULL), mLocation(location), mName(name)
+TKCell::TKCell(TKContainer *container, std::string location, std::string name, bool canIntarface)
+: mContainer(container), mAxon(NULL), mCellCode(NULL), mLocation(location), mName(name), mCanInterface(canIntarface)
 {
     mAxon = new TKAxon(this);
 }
index cc965ff..2e878dd 100644 (file)
@@ -34,7 +34,7 @@ typedef std::map<std::string, TKReceptor*> TKReceptorMap;
 class TKCell
 {
 public:
-       TKCell(TKContainer *container, std::string location, std::string name);
+       TKCell(TKContainer *container, std::string location, std::string name, bool canInterface);
        virtual ~TKCell();
     
     std::string             getName() { return mName; }
@@ -47,6 +47,7 @@ public:
     
        bool                    connectTo(std::string connectionName, TKCell *targetReceptor);
        inline TKContainer*     getContainer() { return mContainer; }
+    bool                    isInterface() { return mCanInterface; }
        
        virtual bool            doTick(float time) = 0;
 
@@ -59,6 +60,7 @@ protected:
        TKAxon                  *mAxon;
        TKReceptorMap           mReceptors;
     TKCellCodeInstance      *mCellCode;
+    bool                    mCanInterface;
 
 };
 
index 2451c13..4d4798a 100644 (file)
@@ -27,6 +27,7 @@ TKContainer::~TKContainer()
         delete it->second;
     }
     mCells.clear();
+    mInterfaceCells.clear();
 }
 
 TKCell* TKContainer::getCell(std::string theFQNName)
@@ -42,6 +43,19 @@ TKCell* TKContainer::getCell(std::string theFQNName)
     }
 }
 
+TKCell* TKContainer::getInterfaceCell(std::string theFQNName)
+{
+    TKCellMap::iterator it = mInterfaceCells.find(theFQNName);
+    if (it == mInterfaceCells.end())
+    {
+        return NULL;
+    }
+    else
+    {
+        return it->second;
+    }
+}
+
 TKCellCode* TKContainer::getCellCode(std::string theCellCodeName)
 {
     TKCellCodeMap::iterator it = mCellCodes.find(theCellCodeName);
index e37897e..49a6281 100644 (file)
@@ -39,6 +39,7 @@ public:
     const TKCellMap* getCells() { return &mCells; } 
     const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
        TKCell* getCell(std::string theFQNName);
+       TKCell* getInterfaceCell(std::string theFQNName);
        TKCellCode* getCellCode(std::string theCellCodeName);
        
        virtual TKCell* createCell(std::string theLocation, std::string theName, TKCellCode *cellCode, std::string startupString) = 0;
@@ -51,6 +52,7 @@ public:
 
 protected:
        TKCellMap       mCells;
+    TKCellMap       mInterfaceCells;
     TKCellCodeMap   mCellCodes;
        
 };
index 1b508e9..9f6d785 100644 (file)
@@ -53,8 +53,8 @@ JSStaticValue jsStaticValueArray[] = {
 
 const char* JSCLASSNAME = "__TKCLASSDEF_TKJSBasicCell";
 
-TKJSBasicCell::TKJSBasicCell(TKJSContainer *container, std::string location, std::string name)
-:TKJSCellBase(container, location, name)
+TKJSBasicCell::TKJSBasicCell(TKJSContainer *container, std::string location, std::string name, bool canInterface)
+:TKJSCellBase(container, location, name, canInterface)
 {
     JSContextRef ctx = ((TKJSContainer*)getContainer())->getJSContext();
     
index 7fe0998..9a76145 100644 (file)
@@ -35,7 +35,7 @@ class TKReceptor;
 class TKJSBasicCell : public TKJSCellBase
 {
 public:
-       TKJSBasicCell(TKJSContainer *container, std::string location, std::string name);
+       TKJSBasicCell(TKJSContainer *container, std::string location, std::string name, bool canIntarface = true);
     virtual ~TKJSBasicCell();
        
        virtual bool                doTick(float time);
index 147adb5..8f1906f 100644 (file)
@@ -32,8 +32,8 @@ class TKJSCellCode;
 class TKJSCellBase : public TKCell
 {
 public:
-       TKJSCellBase(TKJSContainer *container, std::string location, std::string name) 
-    : TKCell((TKContainer*)container, location, name), mJSAPIInstance(0) {}
+       TKJSCellBase(TKJSContainer *container, std::string location, std::string name, bool canInterface
+    : TKCell((TKContainer*)container, location, name, canInterface), mJSAPIInstance(0) {}
     
     JSObjectRef                 getCellAPI() { return mJSAPIInstance; }
     
index 7d5e3a6..a0a5aeb 100644 (file)
@@ -110,8 +110,13 @@ TKCell* TKJSContainer::createCell(std::string theLocation, std::string theName,
        if (cell)
        {
         std::string fqnName = getFQNString(theLocation.c_str(), theName.c_str());
-               mCells.insert( std::map<std::string, TKCell*>::value_type(fqnName, cell));
+               mCells.insert(TKCellMap::value_type(fqnName, cell));
         cell->setCellCode(cellCode,(const void*)startupScript.c_str());
+        
+        if (cell->isInterface())
+        {
+            mInterfaceCells.insert(TKCellMap::value_type(fqnName, cell));
+        }
        }
     else
     {
index 54b1953..562595e 100644 (file)
 //  Created by tkawata on 12/30/2011.
 //
 
+#include "TKReceptor.h"
+#include "TKAxon.h"
 #include "TKUICell.h"
 
+const std::string TKUICell::RECEPTORNAME = "input";
+
+bool TKUICell::doTick(float time)
+{
+    TKReceptorMap::iterator it = mReceptors.find(RECEPTORNAME);
+    if (it != mReceptors.end())
+    {
+        mIsInput = true;
+        TKReceptor *receptor = it->second;
+        float v = receptor->getValue();
+        mAxon->value = v;
+    }
+
+    return true;
+}
+
+void TKUICell::setValue(float value)
+{
+    mAxon->value = value;
+    
+}
+
+float TKUICell::getValue()
+{
+    return mAxon->value;
+}
+
index 4d700fe..20df70e 100644 (file)
 #ifndef dennco_TKUICell_h
 #define dennco_TKUICell_h
 
+#include <string>
+
 #include "TKCell.h"
 
 class TKUICell : public TKCell
 {
 public:
-       TKUICell(TKContainer *container, std::string location, std::string name) : TKCell(container, location, name) {}
+       TKUICell(TKContainer *container, std::string location, std::string name) : TKCell(container, location, name, true) , mIsInput(false) {}
     virtual ~TKUICell() {}
-       virtual bool    doTick(float time) { return true;}
+       virtual bool    doTick(float time);
+    
+    void            setValue(float value);
+    float           getValue();
+    bool            isUIInputCell() { return mIsInput; }
+    
+    const static std::string RECEPTORNAME;
+    
+public:
+    bool            mIsInput;
 };
 
 #endif
diff --git a/Source/platform/osx/OSXDNSimpleWebServerImpl.h b/Source/platform/osx/OSXDNSimpleWebServerImpl.h
new file mode 100644 (file)
index 0000000..710d8ba
--- /dev/null
@@ -0,0 +1,34 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/29/2012.
+//
+
+#ifndef dennco_OSXDNServerImpl_h
+#define dennco_OSXDNServerImpl_h
+
+#include "DNSimpleWebServerImpl.h"
+
+class OSXDNSimpleWebServerImpl : public DNSimpleWebServerImpl
+{
+public:
+    virtual bool            isRunning();
+    virtual void            start();
+    virtual void            stop();
+    
+};
+
+#endif
diff --git a/Source/platform/osx/OSXDNSimpleWebServerImpl.mm b/Source/platform/osx/OSXDNSimpleWebServerImpl.mm
new file mode 100644 (file)
index 0000000..36ca06f
--- /dev/null
@@ -0,0 +1,43 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on 1/29/2012.
+//
+
+
+#include "OSXDNSimpleWebServerImpl.h"
+
+DNServerImpl*    DNServerImpl::create(DNEngine *engine, unsigned int portNumber, DNClientRequestHandler handler)
+{
+    //TODO
+    return NULL;
+}
+
+bool OSXDNSimpleWebServerImpl::isRunning()
+{
+    //TODO
+    return false;
+}
+
+void OSXDNSimpleWebServerImpl::start()
+{
+    //TODO
+}
+
+void OSXDNSimpleWebServerImpl::stop()
+{
+    //TODO
+}
index 7ddd96a..4b2e843 100644 (file)
                7F0E779014B48A3200AFE3A5 /* startup22_2.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F0E778214B4749E00AFE3A5 /* startup22_2.js */; };
                7F0E779114B48A3200AFE3A5 /* startup31_2.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F0E778414B474AA00AFE3A5 /* startup31_2.js */; };
                7F0E779214B48A5A00AFE3A5 /* layer1_2.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F0E776714B461F000AFE3A5 /* layer1_2.js */; };
+               7F2DB0BD14CE2594008030AC /* DNServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F2DB0BC14CE2594008030AC /* DNServer.cpp */; };
                7F2FBB9114AC9D9B004F8FBE /* layer1_1.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F2FBB8A14AC9CB0004F8FBE /* layer1_1.js */; };
                7F2FBB9214AC9D9B004F8FBE /* layer2_1.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F2FBB8C14AC9D31004F8FBE /* layer2_1.js */; };
                7F2FBB9314AC9D9B004F8FBE /* layer3_1.js in Resources */ = {isa = PBXBuildFile; fileRef = 7F2FBB8E14AC9D3A004F8FBE /* layer3_1.js */; };
                7F4C432414AE26730098694B /* SourceViewWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7F4C432314AE26730098694B /* SourceViewWindow.xib */; };
+               7F4C7A0714D50CCD00BDD697 /* OSXDNSimpleWebServerImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7F4C7A0514D50AC400BDD697 /* OSXDNSimpleWebServerImpl.mm */; };
+               7F4C7A0814D5626800BDD697 /* TKUICell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FDCE1C714ACBB68002E3FBF /* TKUICell.cpp */; };
+               7FC8F99D14D3CA1700955C36 /* DNSimpleWebServerImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FC8F99C14D3CA1700955C36 /* DNSimpleWebServerImpl.cpp */; };
+               7FC8F9A414D3DE4100955C36 /* DNEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FC8F9A314D3DE4100955C36 /* DNEngine.cpp */; };
                7FCADFA914B733B60003A23A /* DNContainerBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FCADFA814B733B60003A23A /* DNContainerBuilder.cpp */; };
-               7FCADFAB14B7418F0003A23A /* DNContainerServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FCADFAA14B7418E0003A23A /* DNContainerServer.cpp */; };
                7FCADFAF14B7CA010003A23A /* OSXTKLockImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7FCADFAE14B7CA010003A23A /* OSXTKLockImpl.mm */; };
                7FCADFB014B7CA010003A23A /* OSXTKLockImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7FCADFAE14B7CA010003A23A /* OSXTKLockImpl.mm */; };
                7FCADFB314B7D0540003A23A /* TKLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FCADFB114B7D0530003A23A /* TKLock.cpp */; };
                7F0E778014B4748800AFE3A5 /* startup21_2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = startup21_2.js; sourceTree = "<group>"; };
                7F0E778214B4749E00AFE3A5 /* startup22_2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = startup22_2.js; sourceTree = "<group>"; };
                7F0E778414B474AA00AFE3A5 /* startup31_2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = startup31_2.js; sourceTree = "<group>"; };
+               7F2DB0BC14CE2594008030AC /* DNServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNServer.cpp; sourceTree = "<group>"; };
+               7F2DB0BF14CE25A5008030AC /* DNServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNServer.h; sourceTree = "<group>"; };
                7F2FBB8A14AC9CB0004F8FBE /* layer1_1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = layer1_1.js; sourceTree = "<group>"; };
                7F2FBB8C14AC9D31004F8FBE /* layer2_1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = layer2_1.js; sourceTree = "<group>"; };
                7F2FBB8E14AC9D3A004F8FBE /* layer3_1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = layer3_1.js; sourceTree = "<group>"; };
                7F4C432314AE26730098694B /* SourceViewWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SourceViewWindow.xib; sourceTree = "<group>"; };
+               7F4C7A0414D50AAF00BDD697 /* OSXDNSimpleWebServerImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; path = OSXDNSimpleWebServerImpl.h; sourceTree = "<group>"; };
+               7F4C7A0514D50AC400BDD697 /* OSXDNSimpleWebServerImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSXDNSimpleWebServerImpl.mm; sourceTree = "<group>"; };
+               7FC8F99C14D3CA1700955C36 /* DNSimpleWebServerImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSimpleWebServerImpl.cpp; sourceTree = "<group>"; };
+               7FC8F99F14D3CA2400955C36 /* DNSimpleWebServerImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; path = DNSimpleWebServerImpl.h; sourceTree = "<group>"; };
+               7FC8F9A314D3DE4100955C36 /* DNEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNEngine.cpp; sourceTree = "<group>"; };
+               7FC8F9A514D3DE4900955C36 /* DNEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNEngine.h; sourceTree = "<group>"; };
+               7FC8F9A614D3E22700955C36 /* DNServerImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNServerImpl.h; sourceTree = "<group>"; };
                7FCADFA614B733A00003A23A /* DNContainerBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNContainerBuilder.h; sourceTree = "<group>"; };
                7FCADFA814B733B60003A23A /* DNContainerBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNContainerBuilder.cpp; sourceTree = "<group>"; };
-               7FCADFAA14B7418E0003A23A /* DNContainerServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNContainerServer.cpp; sourceTree = "<group>"; };
                7FCADFAD14B7C9430003A23A /* OSXTKLockImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSXTKLockImpl.h; sourceTree = "<group>"; };
                7FCADFAE14B7CA010003A23A /* OSXTKLockImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSXTKLockImpl.mm; sourceTree = "<group>"; };
                7FCADFB114B7D0530003A23A /* TKLock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TKLock.cpp; sourceTree = "<group>"; };
                7FCADFB214B7D0530003A23A /* TKLockImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKLockImpl.h; sourceTree = "<group>"; };
-               7FCADFB514B7D9270003A23A /* DNContainerServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNContainerServer.h; sourceTree = "<group>"; };
                7FCADFB614B7D96F0003A23A /* DNTimeKeeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNTimeKeeper.h; sourceTree = "<group>"; };
                7FCADFB714B7D9870003A23A /* DNTimeKeeper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNTimeKeeper.cpp; sourceTree = "<group>"; };
                7FCADFBA14B7D9A00003A23A /* DNTimeKeeperImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNTimeKeeperImpl.h; sourceTree = "<group>"; };
                                7F0C584D14B1554E00C1FF4D /* TKConsole.h */,
                                7FCADFA814B733B60003A23A /* DNContainerBuilder.cpp */,
                                7FCADFA614B733A00003A23A /* DNContainerBuilder.h */,
-                               7FCADFAA14B7418E0003A23A /* DNContainerServer.cpp */,
-                               7FCADFB514B7D9270003A23A /* DNContainerServer.h */,
                                7FCADFB714B7D9870003A23A /* DNTimeKeeper.cpp */,
+                               7FC8F9A314D3DE4100955C36 /* DNEngine.cpp */,
+                               7FC8F9A514D3DE4900955C36 /* DNEngine.h */,
                                7FCADFB614B7D96F0003A23A /* DNTimeKeeper.h */,
                                7FCADFBA14B7D9A00003A23A /* DNTimeKeeperImpl.h */,
                                7FCADFC414B86FBE0003A23A /* DNDirectory.cpp */,
                                7FCADFC614B870D80003A23A /* DNDirectoryImpl.h */,
                                7FCADFCA14B875120003A23A /* DNFileList.cpp */,
                                7FCADFC914B874EC0003A23A /* DNFileList.h */,
+                               7F2DB0BC14CE2594008030AC /* DNServer.cpp */,
+                               7F2DB0BF14CE25A5008030AC /* DNServer.h */,
+                               7FC8F9A614D3E22700955C36 /* DNServerImpl.h */,
+                               7FC8F99C14D3CA1700955C36 /* DNSimpleWebServerImpl.cpp */,
+                               7FC8F99F14D3CA2400955C36 /* DNSimpleWebServerImpl.h */,
                                7FCADFCD14B880CF0003A23A /* DNXML.cpp */,
                                7FCADFCC14B880BD0003A23A /* DNXML.h */,
                                7FCADFCF14B8824D0003A23A /* DNXMLImpl.h */,
                                7FCADFD314B893040003A23A /* OSXDNXMLImpl.h */,
                                7FCADFD714B8A2DF0003A23A /* OSXDNDirectoryImpl.mm */,
                                7FCADFD614B8A2C50003A23A /* OSXDNDirectoryImpl.h */,
+                               7F4C7A0414D50AAF00BDD697 /* OSXDNSimpleWebServerImpl.h */,
+                               7F4C7A0514D50AC400BDD697 /* OSXDNSimpleWebServerImpl.mm */,
                        );
                        path = osx;
                        sourceTree = "<group>";
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               7F4C7A0714D50CCD00BDD697 /* OSXDNSimpleWebServerImpl.mm in Sources */,
                                7FEF016E14A879EB00051DED /* main.m in Sources */,
                                7FEF017514A879EB00051DED /* AppDelegate.mm in Sources */,
                                7FEF01AB14A87B4A00051DED /* TKConsole.mm in Sources */,
                                7FDCE1C814ACBB68002E3FBF /* TKUICell.cpp in Sources */,
                                7F0C584B14B1522700C1FF4D /* TKLog.cpp in Sources */,
                                7FCADFA914B733B60003A23A /* DNContainerBuilder.cpp in Sources */,
-                               7FCADFAB14B7418F0003A23A /* DNContainerServer.cpp in Sources */,
                                7FCADFB014B7CA010003A23A /* OSXTKLockImpl.mm in Sources */,
                                7FCADFB414B7D0540003A23A /* TKLock.cpp in Sources */,
                                7FCADFB914B7D9870003A23A /* DNTimeKeeper.cpp in Sources */,
                                7FCADFD214B887800003A23A /* DNXMLElement.cpp in Sources */,
                                7FCADFD514B893170003A23A /* OSXDNXMLImpl.mm in Sources */,
                                7FCADFD814B8A2DF0003A23A /* OSXDNDirectoryImpl.mm in Sources */,
+                               7F2DB0BD14CE2594008030AC /* DNServer.cpp in Sources */,
+                               7FC8F99D14D3CA1700955C36 /* DNSimpleWebServerImpl.cpp in Sources */,
+                               7FC8F9A414D3DE4100955C36 /* DNEngine.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               7F4C7A0814D5626800BDD697 /* TKUICell.cpp in Sources */,
                                7F0C584E14B157DC00C1FF4D /* TKLog.cpp in Sources */,
                                7FEF025214A9448F00051DED /* TKConsole.mm in Sources */,
                                7FEF025614A9448F00051DED /* TKAxon.cpp in Sources */,