source: cpp/gdk/collectionobj.h @ 68

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

added missing sources; updated sources for compatibility with vs2008 and added project files

File size: 2.0 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#ifndef _COLLECTIONOBJ_H_
6#define _COLLECTIONOBJ_H_
7
8#include "param.h"
9#include "extvalue.h"
10#include "hashtable.h"
11#include "3d.h"
12
13/** object collection, indexed by int */
14class VectorObject: public DestrBase
15{
16  public:
17SList data;
18int readonly:1, owndata:1;
19void clear();
20ExtValue *get(int i) {return (ExtValue*)data.get(i);}
21void set(int i,const ExtValue& val);
22
23static Param par;
24VectorObject(Pt3D& pt);
25VectorObject():readonly(0),owndata(1) {}
26~VectorObject() {clear();}
27#define STATRICKCLASS VectorObject
28PARAMPROCDEF(p_clear) {if (readonly) return; clear();}
29PARAMGETDEF(size) {arg1->setInt(data.size());}
30PARAMGETDEF(avg);
31PARAMGETDEF(stdev);
32PARAMPROCDEF(p_remove);
33PARAMPROCDEF(p_get);
34PARAMPROCDEF(p_find);
35PARAMPROCDEF(p_set) {if (!readonly) set(arg1[1].getInt(),arg1[0]);}
36PARAMPROCDEF(p_add) {if (readonly) return; data+=new ExtValue(arg1[0]);arg2->setInt(data.size()-1);}
37PARAMGETDEF(toString);
38#undef STATRICKCLASS
39static void p_new(void*,ExtValue*args,ExtValue*ret)
40        {ret->setObject(ExtObject(&par,new VectorObject));}
41
42ExtObject makeObject()
43        {return ExtObject(&par,this);}
44};
45
46/** object collection, indexed by name */
47class DictionaryObject: public DestrBase
48{
49  public:
50HashTable hash;
51HashEntryIterator it;
52int it_index;
53
54void clear();
55HashEntryIterator* getIndexIterator(int i);
56
57static Param par;
58DictionaryObject():it_index(-1),it(hash) {}
59~DictionaryObject() {clear();}
60#define STATRICKCLASS DictionaryObject
61PARAMPROCDEF(p_clear) {clear();}
62PARAMGETDEF(size) {arg1->setInt(hash.getSize());}
63PARAMPROCDEF(p_remove);
64PARAMPROCDEF(p_get);
65PARAMPROCDEF(p_getKey);
66PARAMPROCDEF(p_set);
67PARAMPROCDEF(p_find);
68PARAMGETDEF(toString);
69#undef STATRICKCLASS
70static void p_new(void*,ExtValue*args,ExtValue*ret)
71        {ret->setObject(ExtObject(&par,new DictionaryObject));} //NOWY KANDYDAT NA BUGA ROKU!!!
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.