Last change
on this file since 95 was
81,
checked in by Maciej Komosinski, 12 years ago
|
improved parsing of properties (e.g. in f0 genotypes)
|
-
Property svn:eol-style set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // This file is a part of the Framsticks GDK library. |
---|
2 | // Copyright (C) 2002-2011 Szymon Ulatowski. See LICENSE.txt for details. |
---|
3 | // Refer to http://www.framsticks.com/ for further information. |
---|
4 | |
---|
5 | #include "neurolibrary.h" |
---|
6 | #include "param.h" |
---|
7 | #include "modelparts.h" |
---|
8 | |
---|
9 | NeuroLibrary NeuroLibrary::staticlibrary; |
---|
10 | |
---|
11 | int NeuroLibrary::findClassIndex(const SString & classname, bool activeonly) |
---|
12 | { |
---|
13 | NeuroClass* cl; |
---|
14 | for(int i=0;cl=(NeuroClass*)classes(i);i++) |
---|
15 | { |
---|
16 | if (activeonly && !cl->active) continue; |
---|
17 | if (classname == cl->getName()) return i; |
---|
18 | } |
---|
19 | return -1; |
---|
20 | } |
---|
21 | |
---|
22 | NeuroClass* NeuroLibrary::findClass(const SString & classname, bool activeonly) |
---|
23 | { |
---|
24 | int i=findClassIndex(classname,activeonly); |
---|
25 | if (i<0) return 0; |
---|
26 | return getClass(i); |
---|
27 | } |
---|
28 | |
---|
29 | NeuroClass *NeuroLibrary::addClass(NeuroClass *cls,bool replace) |
---|
30 | { |
---|
31 | NeuroClass *old=findClass(cls->getName()); |
---|
32 | if (old) |
---|
33 | { |
---|
34 | if (replace) |
---|
35 | { |
---|
36 | classes-=old; |
---|
37 | classes+=cls; |
---|
38 | } |
---|
39 | } |
---|
40 | else |
---|
41 | classes+=cls; |
---|
42 | return old; |
---|
43 | } |
---|
44 | |
---|
45 | void NeuroLibrary::addStandardClasses() |
---|
46 | { |
---|
47 | #include NEURO_CLS_LIBRARY |
---|
48 | } |
---|
49 | |
---|
50 | NeuroLibrary::NeuroLibrary() |
---|
51 | { |
---|
52 | addStandardClasses(); |
---|
53 | } |
---|
54 | |
---|
55 | NeuroLibrary::~NeuroLibrary() |
---|
56 | { |
---|
57 | FOREACH(NeuroClass*,cl,classes) |
---|
58 | delete cl; |
---|
59 | } |
---|
60 | |
---|
61 | void NeuroLibrary::removeClass(int i) |
---|
62 | { |
---|
63 | classes-=i; |
---|
64 | } |
---|
65 | |
---|
66 | void NeuroLibrary::clear() |
---|
67 | { |
---|
68 | while(getClassCount()>0) |
---|
69 | removeClass(getClassCount()-1); |
---|
70 | } |
---|
71 | |
---|
Note: See
TracBrowser
for help on using the repository browser.