#include <string>
TKCell::TKCell(TKContainer *container, std::string location, std::string name, bool canIntarface)
-: mContainer(container), mAxon(NULL), mCellCodeInstance(NULL), mLocation(location), mName(name), mCanInterface(canIntarface)
+: mName(name), mLocation(location), mContainer(container), mAxon(NULL), mCellCodeInstance(NULL), mCanInterface(canIntarface)
{
- mAxon = new TKAxon(this);
}
TKCell::~TKCell()
{
if (mCellCodeInstance)
{
- mCellCodeInstance->doDestroy();
delete mCellCodeInstance;
mCellCodeInstance = NULL;
}
- for ( TKReceptorMap::iterator it = mReceptors.begin(); it != mReceptors.end(); ++it ) {
- delete it->second;
- }
+ for ( TKReceptorMap::iterator it = mReceptors.begin(); it != mReceptors.end(); ++it ) {
+ delete it->second;
+ }
mReceptors.clear();
if (mAxon)
}
}
+void TKCell::init()
+{
+ if (!mAxon)
+ mAxon = mContainer->axonFactory(this);
+}
+
float TKCell::getAxonValue()
{
if (!mAxon)
return 0.0;
- return mAxon->value;
+ return mAxon->getValue();
}
void TKCell::setAxonValue(float value)
{
if (!mAxon)
return;
- mAxon->value = value;
+ mAxon->setValue(value);
}
bool TKCell::setCellCode(TKCellCode *code, const void *data)
{
mCellCodeInstance = code->createCellCodeInstance(this, data);
- mCellCodeInstance->doInit();
-
- return true;
+ return mCellCodeInstance != NULL;
}
bool TKCell::connectTo(std::string connectionName, TKCell *targetCell)
{
- TKReceptor *receptor = targetCell->createReceptor(connectionName);
- TKAxonTerminal *terminal = mAxon->addTerminal();
- receptor->setTarget(terminal);
-
- return true;
+ TKReceptor *receptor = targetCell->createReceptor(connectionName);
+ if (receptor)
+ {
+ TKAxonTerminal *terminal = mAxon->addTerminal();
+ receptor->setTarget(terminal);
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
TKReceptor* TKCell::createReceptor(std::string name)
TKReceptorMap::iterator it = mReceptors.find(name);
if (it != mReceptors.end())
{
- receptor = it->second;
+ receptor = NULL;
}
else
{
- receptor = new TKReceptor(this);
+ receptor = mContainer->receptorFactory(this);
if (receptor)
{
mReceptors.insert( TKReceptorMap::value_type( name, receptor ) );
}
}
-
+
return receptor;
}