source: cpp/gdk/neurolibrary.cpp @ 98

Last change on this file since 98 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
RevLine 
[64]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.
[5]4
5#include "neurolibrary.h"
6#include "param.h"
7#include "modelparts.h"
8
9NeuroLibrary NeuroLibrary::staticlibrary;
10
11int NeuroLibrary::findClassIndex(const SString & classname, bool activeonly)
12{
13NeuroClass* cl;
14for(int i=0;cl=(NeuroClass*)classes(i);i++)
15        {
16        if (activeonly && !cl->active) continue;
17        if (classname == cl->getName()) return i;
18        }
19return -1;
20}
21
22NeuroClass* NeuroLibrary::findClass(const SString & classname, bool activeonly)
23{
24int i=findClassIndex(classname,activeonly);
25if (i<0) return 0;
26return getClass(i);
27}
28
29NeuroClass *NeuroLibrary::addClass(NeuroClass *cls,bool replace)
30{
31NeuroClass *old=findClass(cls->getName());
32if (old)
33        {
34        if (replace)
35                {
36                classes-=old;
37                classes+=cls;
38                }
39        }
40else
41        classes+=cls;
42return old;
43}
44
45void NeuroLibrary::addStandardClasses()
46{
[81]47#include NEURO_CLS_LIBRARY
[5]48}
49
50NeuroLibrary::NeuroLibrary()
51{
52addStandardClasses();
53}
54
55NeuroLibrary::~NeuroLibrary()
56{
57FOREACH(NeuroClass*,cl,classes)
58        delete cl;
59}
60
61void NeuroLibrary::removeClass(int i)
62{
63classes-=i;
64}
65
66void NeuroLibrary::clear()
67{
68while(getClassCount()>0)
69        removeClass(getClassCount()-1);
70}
71
Note: See TracBrowser for help on using the repository browser.