OSDN Git Service

[dennco] integrated engine related changes from denncoCreator
authortkawata <tkawata@users.sourceforge.jp>
Fri, 19 Oct 2012 17:29:20 +0000 (02:29 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Fri, 19 Oct 2012 17:29:20 +0000 (02:29 +0900)
16 files changed:
Source/DNContainerBuilder.cpp
Source/DNEngine.cpp
Source/DNEngine.h
Source/DNServerHTTP.cpp
Source/QtScript/dnqscellcode.cpp
Source/QtScript/dnqscontainer.cpp
Source/QtScript/dnqscontainer.h
Source/TKAxon.cpp
Source/TKAxon.h
Source/TKAxonTerminal.h
Source/TKCell.cpp
Source/TKCell.h
Source/TKCellCode.h
Source/TKContainer.cpp
Source/TKContainer.h
Source/TKReceptor.h

index 9360d2e..f6fa6d7 100644 (file)
@@ -31,7 +31,7 @@
 #include "TKDebug.h"
 #include "DNGlobal.h"
 
-DNContainerBuilder::DNContainerBuilder(TKContainer *container) : mContainer(container) 
+DNContainerBuilder::DNContainerBuilder(TKContainer *container) : mContainer(container)
 {
     
 }
@@ -45,7 +45,7 @@ bool DNContainerBuilder::buildContainerFromXHTML(const char* docRoot)
 {
     mLock.lock();
     
-    mContainer->setContentPath(std::string(docRoot));
+    mContainer->setContainerRootPath(std::string(docRoot));
 
     DNDirectory directory(docRoot);
     const DNFileList *flist = directory.getFileList("html|htm|xml|xhtml");
@@ -166,6 +166,7 @@ void DNContainerBuilder::defineConnection(const char *path, std::string origine,
 
 void DNContainerBuilder::parseXHTML(const char *docRoot, const char *path)
 {
+    mContainer->beganParsePage(docRoot, path);
     DNXML *xml = DNXML::createXMLFromFile(docRoot, path);
     DNXMLElement *element = xml->getRoot();
     
@@ -303,4 +304,5 @@ void DNContainerBuilder::parseXHTML(const char *docRoot, const char *path)
     if (xml)
         delete xml;
     
+    mContainer->endedParsePage(docRoot, path);
 }
index 8af523b..d00828e 100644 (file)
@@ -365,10 +365,10 @@ bool DNEngine::doClientSetRequest(const char* path, float value)
     return result;
 }
 
-std::string DNEngine::getContentPath()
+std::string DNEngine::getContainerRootPath()
 {
     if (mContainer)
-        return mContainer->getContentPath();
+        return mContainer->getContainerRootPath();
     else
         return "";
 }
index 93977d2..afe809f 100644 (file)
@@ -52,7 +52,7 @@ public:
     bool        doClientSetRequest(const char* path, const char* value);
     bool        doClientSetRequest(const char* path, float value);
 
-    std::string getContentPath();
+    std::string getContainerRootPath();
     std::string getUIPath();
     
     bool        isValid() { return mValid; }
index d93d424..49df25f 100644 (file)
@@ -282,7 +282,7 @@ void DNServerHTTP::doBadRequest(std::string errorMsg)
 
 std::string DNServerHTTP::getContentPath()
 {
-    return mEngine->getContentPath();
+    return mEngine->getContainerRootPath();
 }
 /*
 //static
index d55a04b..ceae239 100644 (file)
@@ -58,7 +58,7 @@ DNQSCellCode::DNQSCellCode(std::string name, std::string cellapi, DNQSContainer
         scriptEngine->clearExceptions();
 
         std::string message = "Failed to construct Cell code : ";
-        message += getName();
+        message += getFQNName();
         message += "\n";
         if (errorStatement.length()>0)
         {
@@ -76,7 +76,7 @@ DNQSCellCode::DNQSCellCode(std::string name, std::string cellapi, DNQSContainer
     if (mCellCodeConstructor.isNull() || mCellCodeConstructor.isUndefined() || ! mCellCodeConstructor.isValid())
     {
         std::string message = "Failed to construct Cell code : ";
-        message.append(getName()).append("\n");
+        message.append(getFQNName()).append("\n");
         message.append("The constructor is invalid.");
         dnNotifyError("Initialization failed", message);
         return;
@@ -98,7 +98,7 @@ TKCellCodeInstance* DNQSCellCode::createCellCodeInstance(TKCell *owner, const vo
         std::string message = "Failed to construct Cell code '";
         message.append(owner->getName());
         message.append("'  cellcode:");
-        message.append(getName()).append("\n");
+        message.append(getFQNName()).append("\n");
         message.append("Cell code invalid");
         dnNotifyError("Initialization failed", message);
         return NULL;
@@ -119,7 +119,7 @@ TKCellCodeInstance* DNQSCellCode::createCellCodeInstance(TKCell *owner, const vo
         std::string message = "Failed to construct Cell code '";
         message.append(owner->getName()).append("'\n");
         message.append("cellcode:");
-        message.append(getName()).append("\n");
+        message.append(getFQNName()).append("\n");
         message.append("Error Message:").append(errorString.toStdString());
         dnNotifyError("Initialization failed", message);
         return NULL;
@@ -158,7 +158,7 @@ TKCellCodeInstance* DNQSCellCode::createCellCodeInstance(TKCell *owner, const vo
             message += owner->getName();
             message += "'\n";
             message += "cellcode:";
-            message += getName();
+            message += getFQNName();
             message += "\n";
             if (errorStatement.length()>0)
             {
index 9820b05..2b143fe 100644 (file)
@@ -96,7 +96,7 @@ void DNQSContainer::setValue(std::string key, float value)
     mQSGlobalObject.setProperty(QString::fromStdString(key), QScriptValue(value));
 }
 
-float DNQSContainer::getValue(std::string key)
+float DNQSContainer::getValue(std::string key) const
 {
     QScriptValue v = mQSGlobalObject.property(QString::fromStdString(key));
     if (v.isNumber())
index b1da392..c411557 100644 (file)
@@ -31,7 +31,7 @@ public:
     virtual ~DNQSContainer();
 
     virtual void    setValue(std::string key, float value);
-    virtual float   getValue(std::string key);
+    virtual float   getValue(std::string key) const;
 
     inline QScriptEngine*   getScriptEngine() { return mQSEngine; }
     inline QScriptValue     getScriptGlobalObject() { return mQSGlobalObject; }
index a0501e3..6adb5d1 100644 (file)
@@ -35,7 +35,7 @@ TKAxon::~TKAxon()
     mTerminals.clear();                
 }
 
-float TKAxon::getValue()
+float TKAxon::getValue() const
 {
     DNLocker locker(&mLock);
 
index a5e941c..a55b620 100644 (file)
@@ -34,8 +34,8 @@ public:
        TKAxon(TKCell *theOwner);
     virtual ~TKAxon();
        TKAxonTerminal* addTerminal();
-    TKCell*         getOwner() { return mOwner; }
-    float           getValue();
+    TKCell*         getOwner() const { return mOwner; }
+    float           getValue() const;
     void            setValue(float value);
 
 protected:
@@ -44,7 +44,7 @@ protected:
 private:
     float  mValue;
     TKCell *mOwner;
-    TKLock mLock;
+    mutable TKLock mLock;
 };
 
 #endif 
index 053810b..caded5e 100644 (file)
@@ -29,14 +29,14 @@ public:
        TKAxonTerminal(TKAxon *theOwner) : mOwner(theOwner), mTarget(0) {}
     virtual ~TKAxonTerminal() {}
 
-       void    setTarget(TKReceptor *theReceptor) {mTarget = theReceptor;}
+    void    setTarget(TKReceptor *theReceptor) {mTarget = theReceptor;}
     void    release(TKReceptor *receptor);
     
     bool    isConnected() { return mTarget != 0; }
     TKAxon* getOwner() { return mOwner; }
     float   getValue();
        
-private:
+protected:
        TKAxon      *mOwner;
        TKReceptor  *mTarget;
 
index ed693d1..7f5a31b 100644 (file)
@@ -57,7 +57,7 @@ void TKCell::init()
         mAxon = mContainer->axonFactory(this);
 }
 
-float TKCell::getAxonValue()
+float TKCell::getAxonValue() const
 {
     if (!mAxon)
         return 0.0;
@@ -73,6 +73,9 @@ void  TKCell::setAxonValue(float value)
 
 bool TKCell::setCellCode(TKCellCode *code, const void *data)
 {
+    if (mCellCodeInstance)
+        delete mCellCodeInstance;
+
     mCellCodeInstance = code->createCellCodeInstance(this, data);
     return mCellCodeInstance != NULL;
 }
index 8c4ed71..62e8eb9 100644 (file)
@@ -39,16 +39,16 @@ public:
 
     void init();
 
-    std::string             getName() { return mName; }
-    float                   getAxonValue();
+    std::string             getName() const { return mName; }
+    float                   getAxonValue() const;
     void                    setAxonValue(float value);
 
-    const TKReceptorMap*    getReceptors() { return &mReceptors; }
+    const TKReceptorMap*    getReceptors() const { return &mReceptors; }
 
     virtual bool            setCellCode(TKCellCode *code, const void *data);
 
     bool                    connectTo(std::string connectionName, TKCell *targetReceptor);
-    inline TKContainer*     getContainer() { return mContainer; }
+    inline TKContainer*     getContainer() const { return mContainer; }
     bool                    isInterface() { return mCanInterface; }
 
     virtual bool            doTick(float time) = 0;
index d8ce32b..3e9f14a 100644 (file)
@@ -21,7 +21,6 @@
 #define __INCLUDE_TKCELLCODE__
 
 #include <string>
-#include <vector>
 
 class TKReceptor;
 class TKContainer;
@@ -31,16 +30,16 @@ class TKCellCodeInstance;
 class TKCellCode
 {
 public:
-    TKCellCode(std::string theName, std::string theCellAPIName) : mName(theName), mCellAPIName(theCellAPIName) {}
+    TKCellCode(std::string theFQNName, std::string theCellAPIName) : mFQNName(theFQNName), mCellAPIName(theCellAPIName) {}
     virtual ~TKCellCode() {}
     
-    std::string getName() { return mName; }
-    std::string getCellAPIName() { return mCellAPIName; }
+    std::string getFQNName() const { return mFQNName; }
+    std::string getCellAPIName() const { return mCellAPIName; }
 
        virtual TKCellCodeInstance* createCellCodeInstance(TKCell *owner, const void *data) = 0;
 
-private:
-    std::string mName;
+protected:
+    std::string mFQNName;
     std::string mCellAPIName;
 };
 
index ae91abd..d4bbe89 100644 (file)
@@ -29,6 +29,7 @@ const std::string TKContainer::CELLTYPE_JSBASIC      = "B";
 const std::string TKContainer::CELLTYPE_OUT          = "O";
 const std::string TKContainer::CELLTYPE_IN           = "I";
 const std::string TKContainer::CELLTYPE_BASICSTORAGE = "BS";
+const std::string TKContainer::CELLCODENAME_EMPTY    = "_DNEMPTY";
 
 TKContainer::TKContainer() : mStorage(NULL), mEmptyCellClass(NULL)
 {
@@ -36,7 +37,7 @@ TKContainer::TKContainer() : mStorage(NULL), mEmptyCellClass(NULL)
 
 void TKContainer::init()
 {
-    mEmptyCellClass = addCellCode("_DNEMPTY",CELLTYPE_JSBASIC,"");
+    mEmptyCellClass = addCellCode(CELLCODENAME_EMPTY,CELLTYPE_JSBASIC,"");
 }
 
 TKContainer::~TKContainer()
index 09e6480..af46ce5 100644 (file)
@@ -43,6 +43,8 @@ public:
     static const std::string CELLTYPE_IN;
     static const std::string CELLTYPE_BASICSTORAGE;
 
+    static const std::string CELLCODENAME_EMPTY;
+
     static TKContainer* createContainer();
     virtual void init();
 
@@ -51,8 +53,8 @@ public:
     const TKCellMap* getCells() { return &mCells; }
     const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
 
-    void        setContentPath(std::string contentPath) { mContentPath = contentPath; }
-    std::string getContentPath() { return mContentPath; }
+    void        setContainerRootPath(std::string containerPath) { mContainerRootPath = containerPath; }
+    std::string getContainerRootPath() { return mContainerRootPath; }
     bool        setDataStore(std::string storagePath);
     DNStorage*  getDataStore() { return mStorage; }
     bool        releaseDataStore();
@@ -69,7 +71,7 @@ public:
     virtual TKCellCode*     addCellCode(std::string theName, std::string theAPIType, std::string code);
 
     virtual void            setValue(std::string key, float value) = 0;
-    inline virtual float    getValue(std::string key) = 0;
+    inline virtual float    getValue(std::string key) const = 0;
 
     virtual TKCell*         cellFactory(std::string location, std::string name, std::string type, bool canInterface = true) = 0;
     virtual TKAxon*         axonFactory(TKCell *theOwner) = 0;
@@ -77,12 +79,15 @@ public:
     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0;
     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code) = 0;
 
+    virtual void            beganParsePage(const char *docRoot, const char *path) {}
+    virtual void            endedParsePage(const char *docRoot, const char *path) {}
+
 protected:
     TKContainer();
     TKCellMap       mCells;
     TKCellMap       mInterfaceCells;
     TKCellCodeMap   mCellCodes;
-    std::string     mContentPath;
+    std::string     mContainerRootPath;
     DNStorage       *mStorage;
     TKCellCode      *mEmptyCellClass;
 
index 939dfd1..58ad661 100644 (file)
@@ -29,13 +29,12 @@ public:
        TKReceptor(TKCell *theOwner) : mOwner(theOwner), mTerminal(0) {}
     virtual ~TKReceptor() {}
 
-       void        setTarget(TKAxonTerminal *theTerminal);
+    void        setTarget(TKAxonTerminal *theTerminal);
     float       getValue();
-    
                
-private:
+protected:
        TKCell *mOwner;
        TKAxonTerminal *mTerminal;
 };
 
-#endif
\ No newline at end of file
+#endif