source: cpp/gdk/neurofactory.cpp @ 81

Last change on this file since 81 was 81, checked in by Maciej Komosinski, 11 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
11int NeuroFactory::used=0;
12
13NeuroImpl* NeuroFactory::createNeuroImpl(NeuroClass *nc)
14{
15if (!nc) return 0;
16if (!nc->active) return 0;
17NeuroImpl* ni=(NeuroImpl*)nc->impl;
18if (!ni) return 0;
19ni=ni->makeNew();
20if (ni) ni->neuroclass=nc;
21return ni;
22}
23
24NeuroImpl* NeuroFactory::setImplementation(const SString& classname,NeuroImpl *ni,bool deleteold)
25{
26NeuroClass *nc=Neuro::getClass(classname);
27if (!nc) return ni;
28return setImplementation(nc,ni,deleteold);
29}
30
31NeuroImpl* NeuroFactory::setImplementation(NeuroClass *nc,NeuroImpl *ni,bool deleteold)
32{
33NeuroImpl* old_ni=(NeuroImpl*)nc->impl;
34nc->impl=ni;
35if (deleteold && old_ni) delete old_ni;
36return old_ni;
37}
38
39#include NEURO_CLS_FACTORY
40
41void NeuroFactory::setImplementation()
42{
43if (!used)
44        {
45        SETIMPLEMENTATION
46        }
47used++;
48}
49
50void NeuroFactory::freeImplementation()
51{
52used--;
53if (!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.