Last change
on this file since 100 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.2 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 "neurofactory.h" |
---|
6 | #include "sstring.h" |
---|
7 | #include "param.h" |
---|
8 | #include "neuroimpl.h" |
---|
9 | #include NEURO_IMPL_FILES |
---|
10 | |
---|
11 | int NeuroFactory::used=0; |
---|
12 | |
---|
13 | NeuroImpl* NeuroFactory::createNeuroImpl(NeuroClass *nc) |
---|
14 | { |
---|
15 | if (!nc) return 0; |
---|
16 | if (!nc->active) return 0; |
---|
17 | NeuroImpl* ni=(NeuroImpl*)nc->impl; |
---|
18 | if (!ni) return 0; |
---|
19 | ni=ni->makeNew(); |
---|
20 | if (ni) ni->neuroclass=nc; |
---|
21 | return ni; |
---|
22 | } |
---|
23 | |
---|
24 | NeuroImpl* NeuroFactory::setImplementation(const SString& classname,NeuroImpl *ni,bool deleteold) |
---|
25 | { |
---|
26 | NeuroClass *nc=Neuro::getClass(classname); |
---|
27 | if (!nc) return ni; |
---|
28 | return setImplementation(nc,ni,deleteold); |
---|
29 | } |
---|
30 | |
---|
31 | NeuroImpl* NeuroFactory::setImplementation(NeuroClass *nc,NeuroImpl *ni,bool deleteold) |
---|
32 | { |
---|
33 | NeuroImpl* old_ni=(NeuroImpl*)nc->impl; |
---|
34 | nc->impl=ni; |
---|
35 | if (deleteold && old_ni) delete old_ni; |
---|
36 | return old_ni; |
---|
37 | } |
---|
38 | |
---|
39 | #include NEURO_CLS_FACTORY |
---|
40 | |
---|
41 | void NeuroFactory::setImplementation() |
---|
42 | { |
---|
43 | if (!used) |
---|
44 | { |
---|
45 | SETIMPLEMENTATION |
---|
46 | } |
---|
47 | used++; |
---|
48 | } |
---|
49 | |
---|
50 | void NeuroFactory::freeImplementation() |
---|
51 | { |
---|
52 | used--; |
---|
53 | if (!used) |
---|
54 | { |
---|
55 | for(int i=0;i<Neuro::getClassCount();i++) |
---|
56 | setImplementation(Neuro::getClass(i),0); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
Note: See
TracBrowser
for help on using the repository browser.