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

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

Code formatting

File size: 2.6 KB
Line 
1#ifndef _PARAMTRANS_H_
2#define _PARAMTRANS_H_
3
4#include "mutparamiface.h"
5#include "param.h"
6
7class TwoWayMap
8{
9        SListTempl<int> map, invmap;
10        void printList(const SListTempl<int>&);
11public:
12        void reset(int size);
13        int get(int pos);
14        int invget(int pos);
15        void insert(int pos);
16        void remove(int pos);
17        void print();
18        int size() { return map.size(); }
19        int 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{
37        MutableParamInterface &par;
38        bool changed, grchanged;
39        CallbackNode *panode, *pdnode, *pcnode, *ganode, *gdnode, *gcnode;
40
41#define STATRICKCLASS ParamTransaction
42        STCALLBACKDEF(onPropAdd);
43        STCALLBACKDEF(onPropDelete);
44        STCALLBACKDEF(onGroupAdd);
45        STCALLBACKDEF(onGroupDelete);
46        STCALLBACKDEF(onPropChange);
47        STCALLBACKDEF(onGroupChange);
48#undef STATRICKCLASS
49
50        TwoWayMap propmap, groupmap;
51
52        void resetMaps();
53
54public:
55        ParamTransaction(MutableParamInterface &mpi);
56        ~ParamTransaction();
57
58        void reset();
59        bool propChanged() { return changed; }
60        bool groupChanged() { return grchanged; }
61
62        int propertyPosition(int prop);
63        int groupPosition(int group);
64
65        int getGroupCount() { return groupmap.invsize(); }
66        int getPropCount() { return propmap.invsize(); }
67        const char * getName() { return par.getName(); }
68
69        const char * id(int);
70        const char * name(int);
71        const char * type(int);
72        const char * help(int);
73        int flags(int);
74        int group(int);
75        const char * grname(int);
76        int grmember(int, int);
77        void call(int, class ExtValue *, class ExtValue *);
78        class SString getString(int);
79        paInt getInt(int);
80        double getDouble(int);
81        class ExtObject getObject(int);
82        class ExtValue getExtValue(int);
83        int setInt(int, paInt);
84        int setDouble(int, double);
85        int setString(int, const class SString &);
86        int setObject(int, const class ExtObject &);
87        int setExtValue(int, const class ExtValue &);
88
89        void print()
90        {
91                printf("props(");
92                propmap.print();
93                printf(") groups(");
94                groupmap.print();
95                printf(")\n");
96        }
97};
98
99#endif
Note: See TracBrowser for help on using the repository browser.