OSDN Git Service

refactored for next development phase.
[dennco/dennco.git] / Source / TKAxon.cpp
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on 12/11/2011.
18 //
19 #include "TKAxon.h"
20 #include "TKCell.h"
21 #include "TKContainer.h"
22 #include "TKAxonTerminal.h"
23 #include "TKLock.h"
24 #include "DNUtils.h"
25
26 TKAxon::TKAxon(TKCell *theOwner) : mValue(0.0), mOwner(theOwner)
27 {
28 }
29
30 TKAxon::~TKAxon()
31 {
32     for ( std::vector<TKAxonTerminal*>::iterator it = mTerminals.begin(); it != mTerminals.end(); ++it ) {
33         delete *it;
34     }
35     mTerminals.clear();         
36 }
37
38 float TKAxon::getValue()
39 {
40     DNLocker locker(&mLock);
41
42     return mValue;
43 }
44
45 void TKAxon::setValue(float value)
46 {
47     DNLocker locker(&mLock);
48
49     mValue = value;
50 }
51
52 TKAxonTerminal* TKAxon::addTerminal()
53 {
54     TKAxonTerminal *terminal = mOwner->getContainer()->axonTerminalFactory(this);
55         
56         if (terminal)
57         {
58         mTerminals.push_back(terminal);
59         }
60         return terminal;
61 }