OSDN Git Service

93ebe34aec3f62f73907b1e9e230b8ff9fbe0497
[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 "TKAxonTerminal.h"
21 #include "TKLock.h"
22 #include "DNUtils.h"
23
24 TKAxon::TKAxon(TKCell *theOwner) : mValue(0.0), mOwner(theOwner)
25 {
26 }
27
28 TKAxon::~TKAxon()
29 {
30     for ( std::vector<TKAxonTerminal*>::iterator it = mTerminals.begin(); it != mTerminals.end(); ++it ) {
31         delete *it;
32     }
33     mTerminals.clear();         
34 }
35
36 float TKAxon::getValue()
37 {
38     DNLocker locker(&mLock);
39
40     return mValue;
41 }
42
43 void TKAxon::setValue(float value)
44 {
45     DNLocker locker(&mLock);
46
47     mValue = value;
48 }
49
50 TKAxonTerminal* TKAxon::addTerminal()
51 {
52         TKAxonTerminal *terminal = new TKAxonTerminal(this);
53         
54         if (terminal)
55         {
56         mTerminals.push_back(terminal);
57         }
58         return terminal;
59 }