source: cpp/frams/param/paramtrans.h @ 729

Last change on this file since 729 was 729, checked in by Maciej Komosinski, 6 years ago

mutableparam_test added: demonstrates usage of ParamTransaction? and dynamic properties and groups

File size: 2.5 KB
Line 
1#ifndef _PARAMTRANS_H_
2#define _PARAMTRANS_H_
3
4#include "mutparamiface.h"
5#include "param.h"
6
7class TwoWayMap
8{
9SListTempl<int> map,invmap;
10void printList(const SListTempl<int>&);
11public:
12void reset(int size);
13int get(int pos);
14int invget(int pos);
15void insert(int pos);
16void remove(int pos);
17void print();
18int size() {return map.size();}
19int invsize() {return invmap.size();}
20};
21
22/** wrapper for MutableParamInterface providing constant property#'s.
23    \warn group membership can change if the property is removed!
24
25    properties handling:
26    - adding and removing will not change property count and property#
27    - the description (ParamInterface::id/name/type) of the removed property is always "?"
28    - group membership of the removed property is always 0
29    - requests for property# are redirected to the new property# or ignored
30    groups handling:
31    - group count is constant
32    - accessing group name of the removed group will return "?"
33    - removed properties are moved to group 0
34 */
35class ParamTransaction: public ParamInterface
36{
37MutableParamInterface &par;
38bool changed,grchanged;
39CallbackNode *panode,*pdnode,*pcnode,*ganode,*gdnode,*gcnode;
40
41#define STATRICKCLASS ParamTransaction
42STCALLBACKDEF(onPropAdd);
43STCALLBACKDEF(onPropDelete);
44STCALLBACKDEF(onGroupAdd);
45STCALLBACKDEF(onGroupDelete);
46STCALLBACKDEF(onPropChange);
47STCALLBACKDEF(onGroupChange);
48#undef STATRICKCLASS
49
50TwoWayMap propmap,groupmap;
51
52void resetMaps();
53
54  public:
55ParamTransaction(MutableParamInterface &mpi);
56~ParamTransaction();
57
58void reset();
59bool propChanged() {return changed;}
60bool groupChanged() {return grchanged;}
61
62int propertyPosition(int prop);
63int groupPosition(int group);
64
65int getGroupCount() {return groupmap.invsize();}
66int getPropCount() {return propmap.invsize();}
67const char * getName() {return par.getName();}
68
69const char * id(int);
70const char * name(int);
71const char * type(int);
72const char * help(int);
73int flags(int);
74int group(int);
75const char * grname(int);
76int grmember(int, int);
77void call(int, class ExtValue *, class ExtValue *);
78class SString getString(int);
79paInt getInt(int);
80double getDouble(int);
81class ExtObject getObject(int);
82class ExtValue getExtValue(int);
83int setInt(int, paInt);
84int setDouble(int, double);
85int setString(int, const class SString &);
86int setObject(int, const class ExtObject &);
87int setExtValue(int, const class ExtValue &);
88
89void print()
90        {printf("props(");propmap.print();printf(") groups(");groupmap.print();printf(")\n");}
91};
92
93#endif
Note: See TracBrowser for help on using the repository browser.