source: cpp/gdk/neurofactory.cpp @ 66

Last change on this file since 66 was 66, checked in by Maciej Komosinski, 13 years ago

set 'eol-style' to 'native'

  • 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 "neuroimplfiles.h"
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 "neuroimplfiles.h"
40#include "neurocls-factory.h"
41
42void NeuroFactory::setImplementation()
43{
44if (!used)
45        {
46        SETIMPLEMENTATION
47        }
48used++;
49}
50
51void NeuroFactory::freeImplementation()
52{
53used--;
54if (!used)
55        {
56        for(int i=0;i<Neuro::getClassCount();i++)
57                setImplementation(Neuro::getClass(i),0);
58        }
59}
60
Note: See TracBrowser for help on using the repository browser.