source: cpp/frams/param/mutableparam.h @ 339

Last change on this file since 339 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _MUTABLEPARAM_H_
6#define _MUTABLEPARAM_H_
7
8#include "mutparamiface.h"
9#include <frams/util/extvalue.h>
10#include "param.h"
11#include <frams/util/callbacks.h>
12
13class VMachine;
14class VMCode;
15
16class MutableParam: public SimpleAbstractParam, public MutableParamInterface
17{
18static const int staticprops=7;
19static ParamEntry pe_tab[];
20/** group #0 cannot be removed by scripting  */
21int persistgroup0;
22SString grprefix;
23SList entries;
24SList groups;
25int changed;
26ParamEntry *entry(int i) {return (i<staticprops)? pe_tab+i : ((ParamEntry*)entries(i-staticprops));}
27void *getTarget(int i) {return (i<staticprops)? SimpleAbstractParam::getTarget(i) : (void*)entry(i)->offset;}
28void call(int i,ExtValue* args,ExtValue *ret);
29  public:
30void clear(int everything=0);
31int firstMutableIndex() {return staticprops;}
32SString& groupname(int g) {return *((SString*)groups(g));}
33MutableParam(const char*n=0,const char*g=0,int gr0=1);
34void setGroupName(const SString &n,int g=0) {groupname(g)=n;}
35~MutableParam() {clear(1);}
36int getGroupCount() {return groups.size();}
37int getPropCount() {return entries.size()+staticprops;}
38const char *grname(int i) {return (i>=groups.size()) ? 0 : (const char*)groupname(i);}
39int grmember(int g,int a);
40
41int addGroup(const SString& gname,int noprefix=0);
42void removeGroup(int pos);
43
44int findGroup(const SString name,int ignoreprefix=0);
45
46/** @param data pointer to the variable. 0 will allocate new variable
47    @param position -1 = after the last one  */
48int addProperty(void* data,const char* id,const char* type,const char* name,const char* help=0,int flags=0,int group=0,int position=-1);
49
50int addProperty(ParamEntry *pe,int position=-1);
51ParamEntry * removeProperty(ParamEntry *pe);
52ParamEntry * removeProperty(int i);
53
54void notify(int id);
55
56int setInt(int,paInt);
57int setDouble(int,double);
58int setString(int,const SString &);
59int setObject(int,const ExtObject &);
60int setExtValue(int,const ExtValue &);
61
62#define STATRICKCLASS MutableParam
63PARAMPROCDEF(p_clear);
64PARAMPROCDEF(p_addprop);
65PARAMPROCDEF(p_remprop);
66PARAMPROCDEF(p_addgroup);
67PARAMPROCDEF(p_remgroup);
68PARAMGETDEF(changedname) {arg1->setString(id(changed));}
69#undef STATRICKCLASS
70};
71
72class ParamSaver
73{
74SList store;
75  public:
76virtual bool shouldLoad(ParamInterface &pi,int i) {return true;}
77ParamSaver() {}
78ParamSaver(ParamInterface &pi) {loadFrom(pi);}
79~ParamSaver() {clear();}
80void loadFrom(ParamInterface& p);
81void saveTo(MutableParam& p);
82void clear();
83};
84
85
86#endif
Note: See TracBrowser for help on using the repository browser.