📄 axonnode.cpp
字号:
/*************************************************************************** axonnode.cpp - description ------------------- copyright : (C) 2004 by Matt Grover email : mgrover@amygdala.org ***************************************************************************//*************************************************************************** * * * 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 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include "axonnode.h"#include "synapse.h"#include "network.h"#include "factory.h"#include <string>#include <iostream>using namespace Amygdala;using namespace std;AxonNode::AxonNode(AmTimeInt _delay, unsigned int synapseSize, unsigned int nodeSize): delay(_delay), synSize((unsigned short)synapseSize), header(0), synOffset(0), size(nodeSize){ offset = (unsigned short)(delay/Network::TimeStepSize());}AxonNode::~AxonNode(){}void AxonNode::AddSynapse(Synapse* syn){ if (!header) { if (!synSize || !size) { throw new string("Either the node size or the synapse size of this synapse is set to 0"); } // no space for the synapses has been allocated yet. // allocate space and copy syn into the first slot void* synHead = new char[synSize*size]; LOGGER(6, "Allocated " << synSize*size << " bytes at " << synHead) syn->Clone(synHead); LOGGER(6, "Setting header to " << synHead) header = static_cast<Synapse*>(synHead); synOffset = (unsigned int)synSize; LOGGER(6, "Setting synOffset to " << synOffset) return; } LOGGER(6, "header " << header << ", offset " << synOffset) LOGGER(6, "Preparing to clone synapse at " << header+synOffset) syn->Clone((void*)((unsigned int)header+synOffset)); synOffset += (unsigned int)synSize; LOGGER(6, "Setting synOffset to " << synOffset)}// TODO: Get this working -- needed for Network.AxonNodeIterator AxonNode::Begin(){ LOGGER(6, "Setting up AxonNodeIterator") AxonNodeIterator itr(header, synSize, size); return itr;}AxonNodeIterator::AxonNodeIterator(Synapse* head, unsigned int synapseSize, unsigned int count): synHead(head), offset(0), synSize(synapseSize), synCount(count){}AxonNodeIterator::~AxonNodeIterator(){}Synapse* AxonNodeIterator::operator++(int){ if (offset >= synCount) { return 0; } Synapse* s = (Synapse*)((unsigned int)synHead+(offset*synSize)); ++offset; return s;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -