[729] | 1 | #ifndef _PARAMTRANS_H_
|
---|
| 2 | #define _PARAMTRANS_H_
|
---|
| 3 |
|
---|
| 4 | #include "mutparamiface.h"
|
---|
| 5 | #include "param.h"
|
---|
| 6 |
|
---|
| 7 | class TwoWayMap
|
---|
| 8 | {
|
---|
[731] | 9 | SListTempl<int> map, invmap;
|
---|
| 10 | void printList(const SListTempl<int>&);
|
---|
[729] | 11 | public:
|
---|
[731] | 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(); }
|
---|
[729] | 20 | };
|
---|
| 21 |
|
---|
| 22 | /** wrapper for MutableParamInterface providing constant property#'s.
|
---|
[731] | 23 | \warn group membership can change if the property is removed!
|
---|
[729] | 24 |
|
---|
[731] | 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 | */
|
---|
| 35 | class ParamTransaction : public ParamInterface
|
---|
[729] | 36 | {
|
---|
[731] | 37 | MutableParamInterface ∥
|
---|
| 38 | bool changed, grchanged;
|
---|
| 39 | CallbackNode *panode, *pdnode, *pcnode, *ganode, *gdnode, *gcnode;
|
---|
[729] | 40 |
|
---|
| 41 | #define STATRICKCLASS ParamTransaction
|
---|
[731] | 42 | STCALLBACKDEF(onPropAdd);
|
---|
| 43 | STCALLBACKDEF(onPropDelete);
|
---|
| 44 | STCALLBACKDEF(onGroupAdd);
|
---|
| 45 | STCALLBACKDEF(onGroupDelete);
|
---|
| 46 | STCALLBACKDEF(onPropChange);
|
---|
| 47 | STCALLBACKDEF(onGroupChange);
|
---|
[729] | 48 | #undef STATRICKCLASS
|
---|
| 49 |
|
---|
[731] | 50 | TwoWayMap propmap, groupmap;
|
---|
[729] | 51 |
|
---|
[731] | 52 | void resetMaps();
|
---|
[729] | 53 |
|
---|
[731] | 54 | public:
|
---|
| 55 | ParamTransaction(MutableParamInterface &mpi);
|
---|
| 56 | ~ParamTransaction();
|
---|
[729] | 57 |
|
---|
[731] | 58 | void reset();
|
---|
| 59 | bool propChanged() { return changed; }
|
---|
| 60 | bool groupChanged() { return grchanged; }
|
---|
[729] | 61 |
|
---|
[731] | 62 | int propertyPosition(int prop);
|
---|
| 63 | int groupPosition(int group);
|
---|
[729] | 64 |
|
---|
[731] | 65 | int getGroupCount() { return groupmap.invsize(); }
|
---|
| 66 | int getPropCount() { return propmap.invsize(); }
|
---|
| 67 | const char * getName() { return par.getName(); }
|
---|
[729] | 68 |
|
---|
[731] | 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 &);
|
---|
[729] | 88 |
|
---|
[731] | 89 | void print()
|
---|
| 90 | {
|
---|
| 91 | printf("props(");
|
---|
| 92 | propmap.print();
|
---|
| 93 | printf(") groups(");
|
---|
| 94 | groupmap.print();
|
---|
| 95 | printf(")\n");
|
---|
| 96 | }
|
---|
[729] | 97 | };
|
---|
| 98 |
|
---|
| 99 | #endif
|
---|