Last change
on this file since 50 was
5,
checked in by sz, 16 years ago
|
added the GDK (Genotype Development Kit)
|
File size:
1.2 KB
|
Rev | Line | |
---|
[5] | 1 | // This file is a part of Framsticks GDK library. |
---|
| 2 | // Copyright (C) 2002-2006 Szymon Ulatowski. See LICENSE.txt for details. |
---|
| 3 | // Refer to http://www.frams.alife.pl/ for further information. |
---|
| 4 | |
---|
| 5 | #include "neurofactory.h" |
---|
| 6 | #include "sstring.h" |
---|
| 7 | #include "param.h" |
---|
| 8 | #include "neuroimpl.h" |
---|
| 9 | #include "neuroimplfiles.h" |
---|
| 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 | return ni->makeNew(); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | NeuroImpl* NeuroFactory::setImplementation(const SString& classname,NeuroImpl *ni,bool deleteold) |
---|
| 23 | { |
---|
| 24 | NeuroClass *nc=Neuro::getClass(classname); |
---|
| 25 | if (!nc) return ni; |
---|
| 26 | return setImplementation(nc,ni,deleteold); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | NeuroImpl* NeuroFactory::setImplementation(NeuroClass *nc,NeuroImpl *ni,bool deleteold) |
---|
| 30 | { |
---|
| 31 | NeuroImpl* old_ni=(NeuroImpl*)nc->impl; |
---|
| 32 | nc->impl=ni; |
---|
| 33 | if (deleteold && old_ni) delete old_ni; |
---|
| 34 | return old_ni; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | #include "neuroimplfiles.h" |
---|
| 38 | #include "neurocls-factory.h" |
---|
| 39 | |
---|
| 40 | void NeuroFactory::setImplementation() |
---|
| 41 | { |
---|
| 42 | if (!used) |
---|
| 43 | { |
---|
| 44 | SETIMPLEMENTATION |
---|
| 45 | } |
---|
| 46 | used++; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | void NeuroFactory::freeImplementation() |
---|
| 50 | { |
---|
| 51 | used--; |
---|
| 52 | if (!used) |
---|
| 53 | { |
---|
| 54 | for(int i=0;i<Neuro::getClassCount();i++) |
---|
| 55 | setImplementation(Neuro::getClass(i),0); |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | |
---|
Note: See
TracBrowser
for help on using the repository browser.