source: cpp/frams/neuro/neurolibrary.cpp @ 258

Last change on this file since 258 was 197, checked in by Maciej Komosinski, 11 years ago

GDK used by developers since 1999, distributed on the web since 2002

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include "neurolibrary.h"
6#include <frams/param/param.h>
7#include <frams/model/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
29SString NeuroLibrary::getClassName(int classindex)
30{
31NeuroClass *cl=getClass(classindex);
32return cl? cl->getName() : SString();
33}
34
35NeuroClass *NeuroLibrary::addClass(NeuroClass *cls,bool replace)
36{
37NeuroClass *old=findClass(cls->getName());
38if (old)
39        {
40        if (replace)
41                {
42                classes-=old;
43                classes+=cls;
44                }
45        }
46else
47        classes+=cls;
48return old;
49}
50
51void NeuroLibrary::addStandardClasses()
52{
53#include NEURO_CLS_LIBRARY
54}
55
56NeuroLibrary::NeuroLibrary()
57{
58addStandardClasses();
59}
60
61NeuroLibrary::~NeuroLibrary()
62{
63FOREACH(NeuroClass*,cl,classes)
64        delete cl;
65}
66
67void NeuroLibrary::removeClass(int i)
68{
69classes-=i;
70}
71
72void NeuroLibrary::clear()
73{
74while(getClassCount()>0)
75        removeClass(getClassCount()-1);
76}
77
Note: See TracBrowser for help on using the repository browser.