#include "TKDebug.h"
#include "DNGlobal.h"
-DNContainerBuilder::DNContainerBuilder(TKContainer *container) : mContainer(container)
+DNContainerBuilder::DNContainerBuilder(TKContainer *container) : mContainer(container)
{
}
{
mLock.lock();
- mContainer->setContentPath(std::string(docRoot));
+ mContainer->setContainerRootPath(std::string(docRoot));
DNDirectory directory(docRoot);
const DNFileList *flist = directory.getFileList("html|htm|xml|xhtml");
void DNContainerBuilder::parseXHTML(const char *docRoot, const char *path)
{
+ mContainer->beganParsePage(docRoot, path);
DNXML *xml = DNXML::createXMLFromFile(docRoot, path);
DNXMLElement *element = xml->getRoot();
if (xml)
delete xml;
+ mContainer->endedParsePage(docRoot, path);
}
return result;
}
-std::string DNEngine::getContentPath()
+std::string DNEngine::getContainerRootPath()
{
if (mContainer)
- return mContainer->getContentPath();
+ return mContainer->getContainerRootPath();
else
return "";
}
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; }
std::string DNServerHTTP::getContentPath()
{
- return mEngine->getContentPath();
+ return mEngine->getContainerRootPath();
}
/*
//static
scriptEngine->clearExceptions();
std::string message = "Failed to construct Cell code : ";
- message += getName();
+ message += getFQNName();
message += "\n";
if (errorStatement.length()>0)
{
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;
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;
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;
message += owner->getName();
message += "'\n";
message += "cellcode:";
- message += getName();
+ message += getFQNName();
message += "\n";
if (errorStatement.length()>0)
{
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())
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; }
mTerminals.clear();
}
-float TKAxon::getValue()
+float TKAxon::getValue() const
{
DNLocker locker(&mLock);
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:
private:
float mValue;
TKCell *mOwner;
- TKLock mLock;
+ mutable TKLock mLock;
};
#endif
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;
mAxon = mContainer->axonFactory(this);
}
-float TKCell::getAxonValue()
+float TKCell::getAxonValue() const
{
if (!mAxon)
return 0.0;
bool TKCell::setCellCode(TKCellCode *code, const void *data)
{
+ if (mCellCodeInstance)
+ delete mCellCodeInstance;
+
mCellCodeInstance = code->createCellCodeInstance(this, data);
return mCellCodeInstance != NULL;
}
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;
#define __INCLUDE_TKCELLCODE__
#include <string>
-#include <vector>
class TKReceptor;
class TKContainer;
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;
};
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)
{
void TKContainer::init()
{
- mEmptyCellClass = addCellCode("_DNEMPTY",CELLTYPE_JSBASIC,"");
+ mEmptyCellClass = addCellCode(CELLCODENAME_EMPTY,CELLTYPE_JSBASIC,"");
}
TKContainer::~TKContainer()
static const std::string CELLTYPE_IN;
static const std::string CELLTYPE_BASICSTORAGE;
+ static const std::string CELLCODENAME_EMPTY;
+
static TKContainer* createContainer();
virtual void init();
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();
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;
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;
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