- Timestamp:
- 05/29/18 16:32:45 (7 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/mutableparam.cpp
r535 r792 7 7 8 8 #define FIELDSTRUCT MutableParam 9 ParamEntry MutableParam::pe_tab[] =10 { 11 {"clear",0,PARAM_DONTSAVE | PARAM_USERHIDDEN,"remove all properties","p",PROCEDURE(p_clear),},12 {"add",0,PARAM_DONTSAVE | PARAM_USERHIDDEN,"add property (id,type,name,help)","p",PROCEDURE(p_addprop),},13 {"remove",0,PARAM_DONTSAVE | PARAM_USERHIDDEN,"remove property (index)","p",PROCEDURE(p_remprop),},14 {"addGroup",0,PARAM_DONTSAVE | PARAM_USERHIDDEN,"add group (name)","p",PROCEDURE(p_addgroup),},15 {"removeGroup",0,PARAM_DONTSAVE | PARAM_USERHIDDEN,"remove group (index)","p",PROCEDURE(p_remgroup),},16 {"changedProperty",0,PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY,"last changed property #","d",FIELD(changed),},17 {"changedPropertyId",0,PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY,"last changed property id","s",GETONLY(changedname),},9 ParamEntry MutableParam::pe_tab[] = 10 { 11 { "clear", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove all properties", "p", PROCEDURE(p_clear), }, 12 { "add", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "add property (id,type,name,help)", "p", PROCEDURE(p_addprop), }, 13 { "remove", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove property (index)", "p", PROCEDURE(p_remprop), }, 14 { "addGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "add group (name)", "p", PROCEDURE(p_addgroup), }, 15 { "removeGroup", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "remove group (index)", "p", PROCEDURE(p_remgroup), }, 16 { "changedProperty", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "last changed property #", "d", FIELD(changed), }, 17 { "changedPropertyId", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN | PARAM_READONLY, "last changed property id", "s", GETONLY(changedname), }, 18 18 }; 19 19 #undef FIELDSTRUCT 20 20 21 MutableParam::MutableParam(const char*n, const char*g,int gr0)22 :SimpleAbstractParam(this, n),persistgroup0(gr0),grprefix(g)23 { 24 if (persistgroup0)25 addGroup(grprefix,1);26 } 27 28 int MutableParam::findGroup(const SString name, int ignoreprefix)29 { 30 int skipprefix=grprefix.len()?grprefix.len()+2:0;31 for (int i=0;i<groups.size();i++)32 { 33 if (ignoreprefix)21 MutableParam::MutableParam(const char*n, const char*g, int gr0) 22 :SimpleAbstractParam(this, n), persistgroup0(gr0), grprefix(g) 23 { 24 if (persistgroup0) 25 addGroup(grprefix, 1); 26 } 27 28 int MutableParam::findGroup(const SString name, int ignoreprefix) 29 { 30 int skipprefix = grprefix.len() ? grprefix.len() + 2 : 0; 31 for (int i = 0; i < groups.size(); i++) 32 { 33 if (ignoreprefix) 34 34 { 35 const char *noprefix=groupname(i).c_str();36 37 noprefix+=skipprefix;38 if (!strcmp(noprefix,name.c_str())) return i;35 const char *noprefix = groupname(i).c_str(); 36 if ((int)strlen(noprefix) < skipprefix) continue; 37 noprefix += skipprefix; 38 if (!strcmp(noprefix, name.c_str())) return i; 39 39 } 40 40 else 41 if (groupname(i) ==name) return i;42 } 43 return -1;44 } 45 46 int MutableParam::addGroup(const SString& gname, int noprefix)47 { 48 SString tmp;49 if (noprefix)50 tmp=gname;51 else52 { 53 tmp=grprefix;54 if (tmp.len()) tmp+=": ";55 tmp+=gname;56 } 57 groups+=new SString(tmp);58 int position=groups.size()-1;59 ongroupadd.action(position);60 return position;41 if (groupname(i) == name) return i; 42 } 43 return -1; 44 } 45 46 int MutableParam::addGroup(const SString& gname, int noprefix) 47 { 48 SString tmp; 49 if (noprefix) 50 tmp = gname; 51 else 52 { 53 tmp = grprefix; 54 if (tmp.len()) tmp += ": "; 55 tmp += gname; 56 } 57 groups += new SString(tmp); 58 int position = groups.size() - 1; 59 ongroupadd.action(position); 60 return position; 61 61 } 62 62 63 63 void MutableParam::removeGroup(int g) 64 64 { 65 if ((g<0)||(g>=MutableParam::getGroupCount())) return;66 ParamEntry *e;67 for (int i=MutableParam::getPropCount()-1;i>=staticprops;i--)68 { 69 e=entry(i);70 if (g==e->group)71 removeProperty(i);72 } 73 SString *s=(SString *)groups(g);74 if (s) delete s;75 groups-=g;76 ongroupdelete.action(g);77 } 78 79 int MutableParam::grmember(int g, int a)80 { 81 if (g==0)82 { 83 if (getGroupCount()<2)84 return (a<getPropCount())?a:-9999;85 if (a<staticprops) return a;86 a-=staticprops;87 } 88 ParamEntry *e;89 for (int i=staticprops;e=entry(i);i++)90 if (g==e->group)91 if (!a--) return i;92 return -9999;93 } 94 95 int MutableParam::addProperty(ParamEntry *pe, int position)96 { 97 DB(printf("MutableParam::add(%s)\n",pe->id));98 if (position<0)99 position=entries.size()+staticprops;100 entries.insert(position-staticprops,pe);101 102 if (pe->offset)103 pe->flags &= ~MUTPARAM_ALLOCDATA;104 else105 { 106 pe->flags |= MUTPARAM_ALLOCDATA;107 void *d=0;108 switch(pe->type[0])65 if ((g < 0) || (g >= MutableParam::getGroupCount())) return; 66 ParamEntry *e; 67 for (int i = MutableParam::getPropCount() - 1; i >= staticprops; i--) 68 { 69 e = entry(i); 70 if (g == e->group) 71 removeProperty(i); 72 } 73 SString *s = (SString *)groups(g); 74 if (s) delete s; 75 groups -= g; 76 ongroupdelete.action(g); 77 } 78 79 int MutableParam::grmember(int g, int a) 80 { 81 if (g == 0) 82 { 83 if (getGroupCount() < 2) 84 return (a < getPropCount()) ? a : -9999; 85 if (a < staticprops) return a; 86 a -= staticprops; 87 } 88 ParamEntry *e; 89 for (int i = staticprops; e = entry(i); i++) 90 if (g == e->group) 91 if (!a--) return i; 92 return -9999; 93 } 94 95 int MutableParam::addProperty(ParamEntry *pe, int position) 96 { 97 DB(printf("MutableParam::add(%s)\n", pe->id)); 98 if (position < 0) 99 position = entries.size() + staticprops; 100 entries.insert(position - staticprops, pe); 101 102 if (pe->offset) 103 pe->flags &= ~MUTPARAM_ALLOCDATA; 104 else 105 { 106 pe->flags |= MUTPARAM_ALLOCDATA; 107 void *d = 0; 108 switch (pe->type[0]) 109 109 { 110 case 'd': d =new paInt(); *((paInt*)d)=0; break;111 case 'f': d =new double(); *((double*)d)=0; break;112 case 's': d =new SString(); break;113 case 'x': d =new ExtValue(); break;114 case 'o': d =new ExtObject(); break;110 case 'd': d = new paInt(); *((paInt*)d) = 0; break; 111 case 'f': d = new double(); *((double*)d) = 0; break; 112 case 's': d = new SString(); break; 113 case 'x': d = new ExtValue(); break; 114 case 'o': d = new ExtObject(); break; 115 115 } 116 pe->offset=(intptr_t)d;117 } 118 onadd.action(position);119 return position;116 pe->offset = (intptr_t)d; 117 } 118 onadd.action(position); 119 return position; 120 120 } 121 121 122 122 ParamEntry * MutableParam::removeProperty(ParamEntry *pe) 123 123 { 124 int index=entries.find(pe);125 if (index>=0) return removeProperty(index); else return pe;124 int index = entries.find(pe); 125 if (index >= 0) return removeProperty(index); else return pe; 126 126 } 127 127 128 128 ParamEntry * MutableParam::removeProperty(int i) 129 129 { 130 ParamEntry *pe=(ParamEntry *)entries(i-staticprops);131 DB(printf("MutableParam::remove(%d)\n",i));132 void *d=(void*)pe->offset;133 if (d && (pe->flags & MUTPARAM_ALLOCDATA))134 switch(pe->type[0])135 130 ParamEntry *pe = (ParamEntry *)entries(i - staticprops); 131 DB(printf("MutableParam::remove(%d)\n", i)); 132 void *d = (void*)pe->offset; 133 if (d && (pe->flags & MUTPARAM_ALLOCDATA)) 134 switch (pe->type[0]) 135 { 136 136 case 'd': delete (paInt*)d; break; 137 137 case 'f': delete (double*)d; break; … … 139 139 case 'x': delete (ExtValue*)d; break; 140 140 case 'o': delete (ExtObject*)d; break; 141 } 142 entries -= i - staticprops; 143 if (pe->flags & MUTPARAM_ALLOCENTRY) 144 { 145 if (pe->name) free((void*)pe->name); 146 if (pe->id) free((void*)pe->id); 147 if (pe->help) free((void*)pe->help); 148 if (pe->type) free((void*)pe->type); 149 delete pe; 150 } 151 ondelete.action(i); 152 return pe; 153 } 154 155 void MutableParam::clear(int everything) 156 { 157 DB(printf("MutableParam::clear\n")); 158 for (int i = entries.size() - 1; i >= 0; i--) 159 removeProperty(i + staticprops); 160 int lastgroup = (everything || (persistgroup0 == 0)) ? 0 : 1; 161 for (int i = groups.size() - 1; i >= lastgroup; i--) 162 removeGroup(i); 163 } 164 165 void MutableParam::p_clear(ExtValue *args, ExtValue *ret) 166 { 167 clear(); 168 } 169 170 int MutableParam::addProperty(void* data, const char* id, const char* type, const char* name, const char* help, int flags, int group, int position) 171 { 172 if ((!id) && (!type)) return -1; 173 if (!isValidTypeDescription(type)) return -1; 174 ParamEntry *pe = new ParamEntry(); 175 pe->fun1 = 0; pe->fun2 = 0; 176 pe->group = (paInt)group; 177 pe->flags = (paInt)(flags | MUTPARAM_ALLOCENTRY); 178 pe->offset = (intptr_t)data; 179 pe->id = strdup(id); 180 pe->type = strdup(type); 181 pe->name = name ? strdup(name) : 0; 182 pe->help = help ? strdup(help) : 0; 183 return addProperty(pe, position); 184 } 185 186 void MutableParam::p_addprop(ExtValue *args, ExtValue *ret) 187 { 188 int i = addProperty(0, args[2].getString().c_str(), args[1].getString().c_str(), args[0].getString().c_str()); 189 ret->setInt(i); 190 } 191 192 void MutableParam::p_remprop(ExtValue *args, ExtValue *ret) 193 { 194 removeProperty(args[0].getInt()); 195 } 196 197 void MutableParam::p_addgroup(ExtValue *args, ExtValue *ret) 198 { 199 int i = addGroup(args[0].getString()); 200 ret->setInt(i); 201 } 202 203 void MutableParam::p_remgroup(ExtValue *args, ExtValue *ret) 204 { 205 removeGroup(args[0].getInt()); 206 } 207 208 void MutableParam::notify(int id) 209 { 210 changed = id; 211 onactivate.action(id); 212 } 213 214 int MutableParam::setInt(int i, paInt v) 215 { 216 int ret = SimpleAbstractParam::setInt(i, v); 217 if (ret & PSET_CHANGED) notify(i); 218 return ret; 219 } 220 221 int MutableParam::setDouble(int i, double v) 222 { 223 int ret = SimpleAbstractParam::setDouble(i, v); 224 if (ret & PSET_CHANGED) notify(i); 225 return ret; 226 } 227 228 int MutableParam::setString(int i, const SString &v) 229 { 230 int ret = SimpleAbstractParam::setString(i, v); 231 if (ret & PSET_CHANGED) notify(i); 232 return ret; 233 } 234 235 int MutableParam::setObject(int i, const ExtObject &v) 236 { 237 int ret = SimpleAbstractParam::setObject(i, v); 238 if (ret & PSET_CHANGED) notify(i); 239 return ret; 240 } 241 242 int MutableParam::setExtValue(int i, const ExtValue &v) 243 { 244 int ret = SimpleAbstractParam::setExtValue(i, v); 245 if (ret & PSET_CHANGED) notify(i); 246 return ret; 247 } 248 249 void MutableParam::call(int i, ExtValue* args, ExtValue *ret) 250 { 251 if (i < staticprops) return SimpleAbstractParam::call(i, args, ret); 252 notify(i); 253 } 254 255 /////////////////// 256 257 void ParamSaver::clear() 258 { 259 for (int i = 0; i < store.size(); i += 2) 260 { 261 SString *n = (SString*)store(i); 262 ExtValue *v = (ExtValue*)store(i + 1); 263 delete n; 264 delete v; 265 } 266 store.clear(); 267 } 268 269 void ParamSaver::loadFrom(ParamInterface& p) 270 { 271 int N = p.getPropCount(); 272 for (int i = 0; i < N; i++) 273 { 274 if (shouldLoad(p, i)) 275 { 276 ExtValue v; 277 p.get(i, v); 278 store += new SString(p.id(i)); 279 store += new ExtValue(v); 141 280 } 142 entries-=i-staticprops;143 if (pe->flags & MUTPARAM_ALLOCENTRY)144 {145 if (pe->name) free((void*)pe->name);146 if (pe->id) free((void*)pe->id);147 if (pe->help) free((void*)pe->help);148 if (pe->type) free((void*)pe->type);149 delete pe;150 }151 ondelete.action(i);152 return pe;153 }154 155 void MutableParam::clear(int everything)156 {157 DB(printf("MutableParam::clear\n"));158 for (int i=entries.size()-1;i>=0;i--)159 removeProperty(i+staticprops);160 int lastgroup=(everything || (persistgroup0==0))?0:1;161 for (int i=groups.size()-1;i>=lastgroup;i--)162 removeGroup(i);163 }164 165 void MutableParam::p_clear(ExtValue *args,ExtValue *ret)166 { clear(); }167 168 int MutableParam::addProperty(void* data,const char* id,const char* type,const char* name,const char* help,int flags,int group,int position)169 {170 if ((!id)&&(!type)) return -1;171 if (!isValidTypeDescription(type)) return -1;172 ParamEntry *pe=new ParamEntry();173 pe->fun1=0; pe->fun2=0;174 pe->group=(paInt)group;175 pe->flags=(paInt)(flags | MUTPARAM_ALLOCENTRY);176 pe->offset=(intptr_t)data;177 pe->id=strdup(id);178 pe->type=strdup(type);179 pe->name=name?strdup(name):0;180 pe->help=help?strdup(help):0;181 return addProperty(pe,position);182 }183 184 void MutableParam::p_addprop(ExtValue *args,ExtValue *ret)185 {186 int i=addProperty(0,args[2].getString().c_str(),args[1].getString().c_str(),args[0].getString().c_str());187 ret->setInt(i);188 }189 190 void MutableParam::p_remprop(ExtValue *args,ExtValue *ret)191 {192 removeProperty(args[0].getInt());193 }194 195 void MutableParam::p_addgroup(ExtValue *args,ExtValue *ret)196 {197 int i=addGroup(args[0].getString());198 ret->setInt(i);199 }200 201 void MutableParam::p_remgroup(ExtValue *args,ExtValue *ret)202 {203 removeGroup(args[0].getInt());204 }205 206 void MutableParam::notify(int id)207 {208 changed=id;209 onactivate.action(id);210 }211 212 int MutableParam::setInt(int i,paInt v)213 {214 int ret=SimpleAbstractParam::setInt(i,v);215 if (ret & PSET_CHANGED) notify(i);216 return ret;217 }218 219 int MutableParam::setDouble(int i,double v)220 {221 int ret=SimpleAbstractParam::setDouble(i,v);222 if (ret & PSET_CHANGED) notify(i);223 return ret;224 }225 226 int MutableParam::setString(int i,const SString &v)227 {228 int ret=SimpleAbstractParam::setString(i,v);229 if (ret & PSET_CHANGED) notify(i);230 return ret;231 }232 233 int MutableParam::setObject(int i,const ExtObject &v)234 {235 int ret=SimpleAbstractParam::setObject(i,v);236 if (ret & PSET_CHANGED) notify(i);237 return ret;238 }239 240 int MutableParam::setExtValue(int i,const ExtValue &v)241 {242 int ret=SimpleAbstractParam::setExtValue(i,v);243 if (ret & PSET_CHANGED) notify(i);244 return ret;245 }246 247 void MutableParam::call(int i,ExtValue* args,ExtValue *ret)248 {249 if (i<staticprops) return SimpleAbstractParam::call(i,args,ret);250 notify(i);251 }252 253 ///////////////////254 255 void ParamSaver::clear()256 {257 for(int i=0;i<store.size();i+=2)258 {259 SString *n=(SString*)store(i);260 ExtValue *v=(ExtValue*)store(i+1);261 delete n;262 delete v;263 }264 store.clear();265 }266 267 void ParamSaver::loadFrom(ParamInterface& p)268 {269 int N=p.getPropCount();270 for(int i=0;i<N;i++)271 {272 if (shouldLoad(p,i))273 {274 ExtValue v;275 p.get(i,v);276 store+=new SString(p.id(i));277 store+=new ExtValue(v);278 }279 281 } 280 282 } … … 282 284 void ParamSaver::saveTo(MutableParam& p) 283 285 { 284 for(int i=0;i<store.size();i+=2)285 { 286 SString *n=(SString*)store(i);287 int prop=p.findId(n->c_str());288 if (prop<0)289 prop=p.addProperty(0,n->c_str(),"x",0,0,0,0,-1);290 p.setExtValue(prop,*(ExtValue*)store(i+1));291 } 292 } 286 for (int i = 0; i < store.size(); i += 2) 287 { 288 SString *n = (SString*)store(i); 289 int prop = p.findId(n->c_str()); 290 if (prop < 0) 291 prop = p.addProperty(0, n->c_str(), "x", 0, 0, 0, 0, -1); 292 p.setExtValue(prop, *(ExtValue*)store(i + 1)); 293 } 294 } -
cpp/frams/param/mutparamiface.h
r286 r792 9 9 #include "param.h" 10 10 11 class MutableParamInterface : public virtual ParamInterface11 class MutableParamInterface : public virtual ParamInterface 12 12 { 13 13 public: 14 Callback onadd;15 Callback ondelete;16 Callback onchange;17 Callback ongroupadd;18 Callback ongroupdelete;19 Callback ongroupchange;20 Callback onactivate;14 Callback onadd; 15 Callback ondelete; 16 Callback onchange; 17 Callback ongroupadd; 18 Callback ongroupdelete; 19 Callback ongroupchange; 20 Callback onactivate; 21 21 }; 22 22 -
cpp/frams/param/mutparamlist.cpp
r286 r792 8 8 struct ParamInfo 9 9 { 10 ParamInterface *pi;11 MutableParamInterface *mpi;12 CallbackNode *anode,*dnode,*ganode,*gdnode,*cnode,*gcnode,*panode;13 int firstprop, firstgroup;14 int propcount, groupcount;10 ParamInterface *pi; 11 MutableParamInterface *mpi; 12 CallbackNode *anode, *dnode, *ganode, *gdnode, *cnode, *gcnode, *panode; 13 int firstprop, firstgroup; 14 int propcount, groupcount; 15 15 }; 16 16 17 17 ParamInfo* MutableParamList::getParamInfo(int i) 18 18 { 19 return (ParamInfo*)list(i); 20 } 21 22 void MutableParamList::addPI(int pos,ParamInfo *pi) 23 { 24 int propcount=pi->propcount; 25 int groupcount=pi->groupcount; 26 if (pos==0) 27 { pi->firstprop=0; pi->firstgroup=0; } 28 else 29 { 30 ParamInfo *prev_pi=getParamInfo(pos-1); 31 pi->firstprop=prev_pi->firstprop+prev_pi->propcount; 32 pi->firstgroup=prev_pi->firstgroup+prev_pi->groupcount; 33 } 34 list.insert(pos,pi); 35 pi->propcount=0; 36 pi->groupcount=0; 37 for (int i=0;i<groupcount;i++) 38 { 39 pi->groupcount=i+1; 40 adjustPI(pos+1,0,1); 41 ongroupadd.action(pi->firstgroup+i); 42 } 43 for (int i=0;i<propcount;i++) 44 { 45 pi->propcount=i+1; 46 adjustPI(pos+1,1,0); 47 onadd.action(pi->firstprop+i); 48 } 49 if (pi->mpi) 50 { 51 pi->anode=pi->mpi->onadd.add(STATRICKCALLBACK(this,&MutableParamList::onPropAdd,pi)); 52 pi->ganode=pi->mpi->ongroupadd.add(STATRICKCALLBACK(this,&MutableParamList::onGroupAdd,pi)); 53 pi->dnode=pi->mpi->ondelete.add(STATRICKCALLBACK(this,&MutableParamList::onPropDelete,pi)); 54 pi->gdnode=pi->mpi->ongroupdelete.add(STATRICKCALLBACK(this,&MutableParamList::onGroupDelete,pi)); 55 pi->cnode=pi->mpi->onchange.add(STATRICKCALLBACK(this,&MutableParamList::onPropChange,pi)); 56 pi->gcnode=pi->mpi->ongroupchange.add(STATRICKCALLBACK(this,&MutableParamList::onGroupChange,pi)); 57 pi->panode=pi->mpi->onactivate.add(STATRICKCALLBACK(this,&MutableParamList::onPropActivate,pi)); 19 return (ParamInfo*)list(i); 20 } 21 22 void MutableParamList::addPI(int pos, ParamInfo *pi) 23 { 24 int propcount = pi->propcount; 25 int groupcount = pi->groupcount; 26 if (pos == 0) 27 { 28 pi->firstprop = 0; 29 pi->firstgroup = 0; 30 } 31 else 32 { 33 ParamInfo *prev_pi = getParamInfo(pos - 1); 34 pi->firstprop = prev_pi->firstprop + prev_pi->propcount; 35 pi->firstgroup = prev_pi->firstgroup + prev_pi->groupcount; 36 } 37 list.insert(pos, pi); 38 pi->propcount = 0; 39 pi->groupcount = 0; 40 for (int i = 0; i < groupcount; i++) 41 { 42 pi->groupcount = i + 1; 43 adjustPI(pos + 1, 0, 1); 44 ongroupadd.action(pi->firstgroup + i); 45 } 46 for (int i = 0; i < propcount; i++) 47 { 48 pi->propcount = i + 1; 49 adjustPI(pos + 1, 1, 0); 50 onadd.action(pi->firstprop + i); 51 } 52 if (pi->mpi) 53 { 54 pi->anode = pi->mpi->onadd.add(STATRICKCALLBACK(this, &MutableParamList::onPropAdd, pi)); 55 pi->ganode = pi->mpi->ongroupadd.add(STATRICKCALLBACK(this, &MutableParamList::onGroupAdd, pi)); 56 pi->dnode = pi->mpi->ondelete.add(STATRICKCALLBACK(this, &MutableParamList::onPropDelete, pi)); 57 pi->gdnode = pi->mpi->ongroupdelete.add(STATRICKCALLBACK(this, &MutableParamList::onGroupDelete, pi)); 58 pi->cnode = pi->mpi->onchange.add(STATRICKCALLBACK(this, &MutableParamList::onPropChange, pi)); 59 pi->gcnode = pi->mpi->ongroupchange.add(STATRICKCALLBACK(this, &MutableParamList::onGroupChange, pi)); 60 pi->panode = pi->mpi->onactivate.add(STATRICKCALLBACK(this, &MutableParamList::onPropActivate, pi)); 58 61 } 59 62 } … … 61 64 int MutableParamList::findPI(ParamInfo *pi) 62 65 { 63 return list.find((void*)pi);66 return list.find((void*)pi); 64 67 } 65 68 66 69 int MutableParamList::findPI(ParamInterface *p) 67 70 { 68 ParamInfo *pi;69 for(int i=0;pi=(ParamInfo*)list(i);i++)70 if ((!pi->mpi)&&(pi->pi==p)) return i;71 return -1;71 ParamInfo *pi; 72 for (int i = 0; pi = (ParamInfo*)list(i); i++) 73 if ((!pi->mpi) && (pi->pi == p)) return i; 74 return -1; 72 75 } 73 76 74 77 int MutableParamList::findPI(MutableParamInterface *p) 75 78 { 76 ParamInfo *pi;77 for(int i=0;pi=(ParamInfo*)list(i);i++)78 if ((pi->mpi)&&(pi->mpi==p)) return i;79 return -1;80 } 81 82 void MutableParamList::adjustPI(int firstPI, int addprop,int addgroup)83 { 84 ParamInfo *pi;85 for (int i=firstPI;pi=getParamInfo(i);i++)86 { 87 pi->firstprop+=addprop;88 pi->firstgroup+=addgroup;79 ParamInfo *pi; 80 for (int i = 0; pi = (ParamInfo*)list(i); i++) 81 if ((pi->mpi) && (pi->mpi == p)) return i; 82 return -1; 83 } 84 85 void MutableParamList::adjustPI(int firstPI, int addprop, int addgroup) 86 { 87 ParamInfo *pi; 88 for (int i = firstPI; pi = getParamInfo(i); i++) 89 { 90 pi->firstprop += addprop; 91 pi->firstgroup += addgroup; 89 92 } 90 93 } … … 92 95 void MutableParamList::removePI(int pi_index) 93 96 { 94 if (pi_index<0) return;95 ParamInfo *pi=getParamInfo(pi_index);96 for (int i=pi->propcount-1;i>=0;i--)97 { 98 pi->propcount=i;99 adjustPI(pi_index+1,-1,0);100 ondelete.action(i);101 } 102 for (int i=pi->groupcount-1;i>=0;i--)103 { 104 pi->groupcount=i;105 adjustPI(pi_index+1,0,-1);106 ongroupdelete.action(i);107 } 108 list-=(pi_index);109 if (pi->mpi)110 { 111 pi->mpi->onadd.remove(pi->anode);112 pi->mpi->ongroupadd.remove(pi->ganode);113 pi->mpi->ondelete.remove(pi->dnode);114 pi->mpi->ongroupdelete.remove(pi->gdnode);115 pi->mpi->onchange.remove(pi->cnode);116 pi->mpi->ongroupchange.remove(pi->gcnode);117 pi->mpi->onactivate.remove(pi->panode);118 } 119 delete pi;97 if (pi_index < 0) return; 98 ParamInfo *pi = getParamInfo(pi_index); 99 for (int i = pi->propcount - 1; i >= 0; i--) 100 { 101 pi->propcount = i; 102 adjustPI(pi_index + 1, -1, 0); 103 ondelete.action(i); 104 } 105 for (int i = pi->groupcount - 1; i >= 0; i--) 106 { 107 pi->groupcount = i; 108 adjustPI(pi_index + 1, 0, -1); 109 ongroupdelete.action(i); 110 } 111 list -= (pi_index); 112 if (pi->mpi) 113 { 114 pi->mpi->onadd.remove(pi->anode); 115 pi->mpi->ongroupadd.remove(pi->ganode); 116 pi->mpi->ondelete.remove(pi->dnode); 117 pi->mpi->ongroupdelete.remove(pi->gdnode); 118 pi->mpi->onchange.remove(pi->cnode); 119 pi->mpi->ongroupchange.remove(pi->gcnode); 120 pi->mpi->onactivate.remove(pi->panode); 121 } 122 delete pi; 120 123 } 121 124 122 125 MutableParamList::~MutableParamList() 123 126 { 124 for (int i=list.size()-1;i>=0;i--) 127 for (int i = list.size() - 1; i >= 0; i--) 128 removePI(i); 129 } 130 131 void MutableParamList::onPropAdd(void* data, intptr_t i) 132 { 133 ParamInfo *pi = (ParamInfo*)data; 134 pi->propcount++; 135 int j = findPI(pi); 136 if (j >= 0) 137 adjustPI(j + 1, 1, 0); 138 onadd.action(pi->firstprop + i); 139 } 140 141 void MutableParamList::onPropDelete(void* data, intptr_t i) 142 { 143 ParamInfo *pi = (ParamInfo*)data; 144 pi->propcount--; 145 int j = findPI(pi); 146 if (j >= 0) 147 adjustPI(j + 1, -1, 0); 148 ondelete.action(pi->firstprop + i); 149 } 150 151 void MutableParamList::onPropChange(void* data, intptr_t i) 152 { 153 ParamInfo *pi = (ParamInfo*)data; 154 onchange.action(pi->firstprop + i); 155 } 156 157 void MutableParamList::onPropActivate(void* data, intptr_t i) 158 { 159 ParamInfo *pi = (ParamInfo*)data; 160 onactivate.action(pi->firstprop + i); 161 } 162 163 void MutableParamList::onGroupAdd(void* data, intptr_t i) 164 { 165 ParamInfo *pi = (ParamInfo*)data; 166 pi->groupcount++; 167 int j = findPI(pi); 168 if (j >= 0) 169 adjustPI(j + 1, 0, 1); 170 ongroupadd.action(pi->firstgroup + i); 171 } 172 173 void MutableParamList::onGroupDelete(void* data, intptr_t i) 174 { 175 ParamInfo *pi = (ParamInfo*)data; 176 pi->groupcount--; 177 int j = findPI(pi); 178 if (j >= 0) 179 adjustPI(j + 1, 0, -1); 180 ongroupdelete.action(pi->firstgroup + i); 181 } 182 183 void MutableParamList::onGroupChange(void* data, intptr_t i) 184 { 185 ParamInfo *pi = (ParamInfo*)data; 186 ongroupchange.action(pi->firstgroup + i); 187 } 188 189 void MutableParamList::insert(int pos, MutableParamInterface *p) 190 { 191 ParamInfo *pi = new ParamInfo(); 192 pi->pi = (ParamInterface*)p; 193 pi->mpi = p; 194 pi->propcount = p->getPropCount(); 195 pi->groupcount = p->getGroupCount(); 196 addPI(pos, pi); 197 } 198 199 void MutableParamList::insert(int pos, ParamInterface *p) 200 { 201 ParamInfo *pi = new ParamInfo(); 202 pi->pi = p; 203 pi->mpi = 0; 204 pi->propcount = p->getPropCount(); 205 pi->groupcount = p->getGroupCount(); 206 addPI(pos, pi); 207 } 208 209 210 void MutableParamList::operator+=(ParamInterface *p) 211 { 212 insert(list.size(), p); 213 } 214 215 void MutableParamList::operator+=(MutableParamInterface *p) 216 { 217 insert(list.size(), p); 218 } 219 220 221 void MutableParamList::operator-=(ParamInterface *p) 222 { 223 int i = findPI(p); 125 224 removePI(i); 126 225 } 127 226 128 void MutableParamList::onPropAdd(void* data,intptr_t i)129 {130 ParamInfo *pi=(ParamInfo*)data;131 pi->propcount++;132 int j=findPI(pi);133 if (j>=0)134 adjustPI(j+1,1,0);135 onadd.action(pi->firstprop+i);136 }137 138 void MutableParamList::onPropDelete(void* data,intptr_t i)139 {140 ParamInfo *pi=(ParamInfo*)data;141 pi->propcount--;142 int j=findPI(pi);143 if (j>=0)144 adjustPI(j+1,-1,0);145 ondelete.action(pi->firstprop+i);146 }147 148 void MutableParamList::onPropChange(void* data,intptr_t i)149 {150 ParamInfo *pi=(ParamInfo*)data;151 onchange.action(pi->firstprop+i);152 }153 154 void MutableParamList::onPropActivate(void* data,intptr_t i)155 {156 ParamInfo *pi=(ParamInfo*)data;157 onactivate.action(pi->firstprop+i);158 }159 160 void MutableParamList::onGroupAdd(void* data,intptr_t i)161 {162 ParamInfo *pi=(ParamInfo*)data;163 pi->groupcount++;164 int j=findPI(pi);165 if (j>=0)166 adjustPI(j+1,0,1);167 ongroupadd.action(pi->firstgroup+i);168 }169 170 void MutableParamList::onGroupDelete(void* data,intptr_t i)171 {172 ParamInfo *pi=(ParamInfo*)data;173 pi->groupcount--;174 int j=findPI(pi);175 if (j>=0)176 adjustPI(j+1,0,-1);177 ongroupdelete.action(pi->firstgroup+i);178 }179 180 void MutableParamList::onGroupChange(void* data,intptr_t i)181 {182 ParamInfo *pi=(ParamInfo*)data;183 ongroupchange.action(pi->firstgroup+i);184 }185 186 void MutableParamList::insert(int pos,MutableParamInterface *p)187 {188 ParamInfo *pi=new ParamInfo();189 pi->pi=(ParamInterface*)p;190 pi->mpi=p;191 pi->propcount=p->getPropCount();192 pi->groupcount=p->getGroupCount();193 addPI(pos,pi);194 }195 196 void MutableParamList::insert(int pos,ParamInterface *p)197 {198 ParamInfo *pi=new ParamInfo();199 pi->pi=p;200 pi->mpi=0;201 pi->propcount=p->getPropCount();202 pi->groupcount=p->getGroupCount();203 addPI(pos,pi);204 }205 206 207 void MutableParamList::operator+=(ParamInterface *p)208 {209 insert(list.size(),p);210 }211 212 void MutableParamList::operator+=(MutableParamInterface *p)213 {214 insert(list.size(),p);215 }216 217 218 void MutableParamList::operator-=(ParamInterface *p)219 {220 int i=findPI(p);221 removePI(i);222 }223 224 227 void MutableParamList::operator-=(MutableParamInterface *p) 225 228 { 226 int i=findPI(p);227 removePI(i);229 int i = findPI(p); 230 removePI(i); 228 231 } 229 232 230 233 void MutableParamList::operator-=(int i) 231 234 { 232 removePI(i);235 removePI(i); 233 236 } 234 237 235 238 int MutableParamList::getGroupCount() 236 239 { 237 int count=0;238 FOREACH(ParamInfo*,pi,list)239 count+=pi->groupcount;240 return count;240 int count = 0; 241 FOREACH(ParamInfo*, pi, list) 242 count += pi->groupcount; 243 return count; 241 244 } 242 245 243 246 int MutableParamList::getPropCount() 244 247 { 245 int count=0;246 FOREACH(ParamInfo*,pi,list)247 count+=pi->propcount;248 return count;249 } 250 251 int MutableParamList::getSubParam(int i, ParamInterface **sub_p,int *sub_i)252 { 253 int n;254 FOREACH(ParamInfo*,pi,list)255 { 256 if (i<(n=pi->propcount))248 int count = 0; 249 FOREACH(ParamInfo*, pi, list) 250 count += pi->propcount; 251 return count; 252 } 253 254 int MutableParamList::getSubParam(int i, ParamInterface **sub_p, int *sub_i) 255 { 256 int n; 257 FOREACH(ParamInfo*, pi, list) 258 { 259 if (i < (n = pi->propcount)) 257 260 { 258 *sub_p=pi->pi;259 *sub_i=i;260 return 1;261 *sub_p = pi->pi; 262 *sub_i = i; 263 return 1; 261 264 } 262 i-=n;263 } 264 return 0;265 } 266 267 int MutableParamList::getSubGroup(int i, ParamInterface **sub_p,int *sub_i)268 { 269 int n;270 FOREACH(ParamInfo*,pi,list)271 { 272 if (i<(n=pi->groupcount))265 i -= n; 266 } 267 return 0; 268 } 269 270 int MutableParamList::getSubGroup(int i, ParamInterface **sub_p, int *sub_i) 271 { 272 int n; 273 FOREACH(ParamInfo*, pi, list) 274 { 275 if (i < (n = pi->groupcount)) 273 276 { 274 *sub_p=pi->pi;275 *sub_i=i;276 return 1;277 *sub_p = pi->pi; 278 *sub_i = i; 279 return 1; 277 280 } 278 i-=n;279 } 280 return 0;281 i -= n; 282 } 283 return 0; 281 284 } 282 285 … … 289 292 } 290 293 291 FUN(const char*, id,0)292 FUN(const char*, name,0)293 FUN(const char*, type,0)294 FUN(const char*, help,0)295 FUN(int, flags,0)296 FUN(SString, getString,SString())297 FUN(paInt, getInt,0)298 FUN(double, getDouble,0)299 FUN(ExtValue, getExtValue,ExtValue((paInt)0))300 FUN(ExtObject, getObject,ExtObject())294 FUN(const char*, id, 0) 295 FUN(const char*, name, 0) 296 FUN(const char*, type, 0) 297 FUN(const char*, help, 0) 298 FUN(int, flags, 0) 299 FUN(SString, getString, SString()) 300 FUN(paInt, getInt, 0) 301 FUN(double, getDouble, 0) 302 FUN(ExtValue, getExtValue, ExtValue((paInt)0)) 303 FUN(ExtObject, getObject, ExtObject()) 301 304 302 305 int MutableParamList::group(int i) 303 306 { 304 int n;305 int g=0;306 FOREACH(ParamInfo*,pi,list)307 { 308 if (i<(n=pi->propcount))309 return g + pi->pi->group(i);310 g+=pi->groupcount;311 i-=n;312 } 313 return 0;307 int n; 308 int g = 0; 309 FOREACH(ParamInfo*, pi, list) 310 { 311 if (i < (n = pi->propcount)) 312 return g + pi->pi->group(i); 313 g += pi->groupcount; 314 i -= n; 315 } 316 return 0; 314 317 } 315 318 … … 322 325 } 323 326 324 FUN2(int, setInt,paInt)325 FUN2(int, setDouble,double)326 FUN2(int, setString,const SString &)327 FUN2(int, setObject,const ExtObject &)328 FUN2(int, setExtValue,const ExtValue &)329 330 void MutableParamList::call(int i, ExtValue* args,ExtValue *ret)331 { 332 int j; ParamInterface *pi;333 if (!getSubParam(i,&pi,&j)) return;334 pi->call(j,args,ret);327 FUN2(int, setInt, paInt) 328 FUN2(int, setDouble, double) 329 FUN2(int, setString, const SString &) 330 FUN2(int, setObject, const ExtObject &) 331 FUN2(int, setExtValue, const ExtValue &) 332 333 void MutableParamList::call(int i, ExtValue* args, ExtValue *ret) 334 { 335 int j; ParamInterface *pi; 336 if (!getSubParam(i, &pi, &j)) return; 337 pi->call(j, args, ret); 335 338 } 336 339 337 340 const char *MutableParamList::grname(int i) 338 341 { 339 int j; ParamInterface *pi;340 if (!getSubGroup(i,&pi,&j)) return 0;341 return pi->grname(j);342 } 343 344 int MutableParamList::grmember(int gi, int i)345 { 346 int n;347 int count=0;348 FOREACH(ParamInfo*,pi,list)349 { 350 if (gi<(n=pi->groupcount))342 int j; ParamInterface *pi; 343 if (!getSubGroup(i, &pi, &j)) return 0; 344 return pi->grname(j); 345 } 346 347 int MutableParamList::grmember(int gi, int i) 348 { 349 int n; 350 int count = 0; 351 FOREACH(ParamInfo*, pi, list) 352 { 353 if (gi < (n = pi->groupcount)) 351 354 { 352 int prop=pi->pi->grmember(gi,i);353 if (prop>=pi->propcount) return -9999;354 return count+prop;355 int prop = pi->pi->grmember(gi, i); 356 if (prop >= pi->propcount) return -9999; 357 return count + prop; 355 358 } 356 count+=pi->propcount;357 gi-=n;358 } 359 return -9999;359 count += pi->propcount; 360 gi -= n; 361 } 362 return -9999; 360 363 } 361 364 362 365 void MutableParamList::clear() 363 366 { 364 for (int i=list.size()-1;i>=0;i--)365 operator-=(i);366 } 367 for (int i = list.size() - 1; i >= 0; i--) 368 operator-=(i); 369 } -
cpp/frams/param/mutparamlist.h
r286 r792 12 12 struct ParamInfo; 13 13 14 class MutableParamList : public virtual ParamInterface, public MutableParamInterface14 class MutableParamList : public virtual ParamInterface, public MutableParamInterface 15 15 { 16 SList list;17 const char *objname;18 int getSubParam(int i,ParamInterface **sub_p,int *sub_i);19 int getSubGroup(int i,ParamInterface **sub_p,int *sub_i);16 SList list; 17 const char *objname; 18 int getSubParam(int i, ParamInterface **sub_p, int *sub_i); 19 int getSubGroup(int i, ParamInterface **sub_p, int *sub_i); 20 20 21 ParamInfo* getParamInfo(int i);22 void addPI(int pos,ParamInfo *pi);23 int findPI(ParamInfo *pi);24 int findPI(ParamInterface *p);25 int findPI(MutableParamInterface *p);26 void adjustPI(int firstPI,int addprop,int addgroup);27 void removePI(int pi_index);21 ParamInfo* getParamInfo(int i); 22 void addPI(int pos, ParamInfo *pi); 23 int findPI(ParamInfo *pi); 24 int findPI(ParamInterface *p); 25 int findPI(MutableParamInterface *p); 26 void adjustPI(int firstPI, int addprop, int addgroup); 27 void removePI(int pi_index); 28 28 29 29 #define STATRICKCLASS MutableParamList 30 STCALLBACKDEF(onPropAdd);31 STCALLBACKDEF(onPropDelete);32 STCALLBACKDEF(onGroupAdd);33 STCALLBACKDEF(onGroupDelete);34 STCALLBACKDEF(onPropChange);35 STCALLBACKDEF(onGroupChange);36 STCALLBACKDEF(onPropActivate);30 STCALLBACKDEF(onPropAdd); 31 STCALLBACKDEF(onPropDelete); 32 STCALLBACKDEF(onGroupAdd); 33 STCALLBACKDEF(onGroupDelete); 34 STCALLBACKDEF(onPropChange); 35 STCALLBACKDEF(onGroupChange); 36 STCALLBACKDEF(onPropActivate); 37 37 #undef STATRICKCLASS 38 38 39 39 public: 40 40 41 void firePropChange(int i) {onchange.action(i);}42 void fireGroupChange(int i) {ongroupchange.action(i);}41 void firePropChange(int i) { onchange.action(i); } 42 void fireGroupChange(int i) { ongroupchange.action(i); } 43 43 44 MutableParamList(const char* n=0,const char* d=0):objname(n),description(d) {}45 ~MutableParamList();44 MutableParamList(const char* n = 0, const char* d = 0) :objname(n), description(d) {} 45 ~MutableParamList(); 46 46 47 void operator+=(ParamInterface *p);48 void operator-=(ParamInterface *p);49 void operator+=(MutableParamInterface *p);50 void operator-=(MutableParamInterface *p);51 void insert(int i,ParamInterface *p);52 void insert(int i,MutableParamInterface *p);53 void operator-=(int i);47 void operator+=(ParamInterface *p); 48 void operator-=(ParamInterface *p); 49 void operator+=(MutableParamInterface *p); 50 void operator-=(MutableParamInterface *p); 51 void insert(int i, ParamInterface *p); 52 void insert(int i, MutableParamInterface *p); 53 void operator-=(int i); 54 54 55 /** remove all sub params */56 void clear();55 /** remove all sub params */ 56 void clear(); 57 57 58 const char* getName() {return objname;}59 const char* description;60 const char* getDescription() {return description;}58 const char* getName() { return objname; } 59 const char* description; 60 const char* getDescription() { return description; } 61 61 62 int getGroupCount();63 int getPropCount();62 int getGroupCount(); 63 int getPropCount(); 64 64 65 const char *id(int i);66 const char *name(int i);67 const char *type(int i);68 const char *help(int i);69 int flags(int i);70 int group(int i);71 void call(int i,ExtValue* args,ExtValue *ret);72 const char *grname(int i);65 const char *id(int i); 66 const char *name(int i); 67 const char *type(int i); 68 const char *help(int i); 69 int flags(int i); 70 int group(int i); 71 void call(int i, ExtValue* args, ExtValue *ret); 72 const char *grname(int i); 73 73 74 int grmember(int gi,int n);74 int grmember(int gi, int n); 75 75 76 SString getString(int);77 paInt getInt(int);78 double getDouble(int);79 ExtValue getExtValue(int);80 ExtObject getObject(int);76 SString getString(int); 77 paInt getInt(int); 78 double getDouble(int); 79 ExtValue getExtValue(int); 80 ExtObject getObject(int); 81 81 82 int setInt(int,paInt);83 int setDouble(int,double);84 int setString(int,const SString &);85 int setObject(int,const ExtObject&);86 int setExtValue(int,const ExtValue&);82 int setInt(int, paInt); 83 int setDouble(int, double); 84 int setString(int, const SString &); 85 int setObject(int, const ExtObject&); 86 int setExtValue(int, const ExtValue&); 87 87 }; 88 88 89 89 #endif 90 91 92 93 94 95 96 97 -
cpp/frams/param/paramobj.cpp
r490 r792 23 23 24 24 ParamEntry* ParamObject::makeParamTab(ParamInterface *pi, bool stripgroups, bool stripproc, 25 26 { 27 // flagsexclude_data - skip while calculating data offsets28 // flagsexclude_tab - skip while creating paramtab29 // usually _data==_tab, but vmneuron public properties need _data=0 and _tab=PARAM_USERHIDDEN (data object has all fields, paramtab skips private fields)25 int firstprop, int maxprops, bool dupentries, int flagsexclude_data, int flagsexclude_tab, bool addnew, const char* rename, bool readonly_into_userreadonly) 26 { 27 // flagsexclude_data - skip while calculating data offsets 28 // flagsexclude_tab - skip while creating paramtab 29 // usually _data==_tab, but vmneuron public properties need _data=0 and _tab=PARAM_USERHIDDEN (data object has all fields, paramtab skips private fields) 30 30 ParamEntry *tab, *t; 31 31 int i, n, offset; … … 72 72 for (i = firstprop; i < pi->getPropCount(); i++) 73 73 { 74 const char* type =pi->type(i);74 const char* type = pi->type(i); 75 75 if ((!stripproc) || (strchr("dfsox", type[0]))) 76 76 { 77 paInt flag =pi->flags(i);77 paInt flag = pi->flags(i); 78 78 int tmp_offset; 79 79 if ((!flagsexclude_data) || (!(flag&flagsexclude_data))) 80 80 { 81 if (type[0] =='p')82 tmp_offset =0;81 if (type[0] == 'p') 82 tmp_offset = 0; 83 83 else 84 84 { 85 85 tmp_offset = offset; 86 86 if (type[0] != 'x') tmp_offset += (((char*)&ex.data[0]) - ((char*)&ex)); 87 87 offset += sizeof(ExtValue); 88 88 } 89 89 } 90 90 91 91 if ((!flagsexclude_tab) || (!(flag&flagsexclude_tab))) 92 92 { 93 t->offset =tmp_offset;93 t->offset = tmp_offset; 94 94 t->group = (paInt)(stripgroups ? 0 : pi->group(i)); 95 95 t->flags = (paInt)flag; 96 96 if (readonly_into_userreadonly && (t->flags & PARAM_READONLY)) 97 t->flags =(t->flags & ~PARAM_READONLY) | PARAM_USERREADONLY;97 t->flags = (t->flags & ~PARAM_READONLY) | PARAM_USERREADONLY; 98 98 t->fun1 = 0; 99 99 t->fun2 = 0; … … 185 185 { 186 186 if (!tab) return NULL; 187 int n =tab->flags, used_fields=0;188 for (ParamEntry *t =tab+tab->group; n > 0; n--, t++)189 if (strchr("dfsox", t->type[0]))187 int n = tab->flags, used_fields = 0; 188 for (ParamEntry *t = tab + tab->group; n > 0; n--, t++) 189 if (strchr("dfsox", t->type[0])) 190 190 used_fields++; 191 191 192 if (used_fields ==0) return NULL;192 if (used_fields == 0) return NULL; 193 193 ParamObject *obj = new(used_fields)ParamObject(used_fields, tab); // new(n): allocate n fields ; ParamObject(n,...): tell the object it has n fields 194 194 ExtValue *v = &obj->fields[0]; 195 n =tab->flags;196 for (ParamEntry *t =tab+tab->group; n > 0; n--, t++)195 n = tab->flags; 196 for (ParamEntry *t = tab + tab->group; n > 0; n--, t++) 197 197 switch (*t->type) 198 198 { … … 201 201 case 's': v->setString(SString::empty()); v++; break; 202 202 case 'o': 203 203 { 204 204 ExtObject new_obj; 205 205 if (t->flags & PARAM_OBJECTSET) 206 { 207 ParamInterface *cls = ExtValue::findDeserializableClass(t->type + 1); 208 if (cls) 206 209 { 207 ParamInterface *cls=ExtValue::findDeserializableClass(t->type+1);208 if (cls)210 int new_fun = cls->findId("new"); 211 if (new_fun >= 0) 209 212 { 210 int new_fun = cls->findId("new"); 211 if (new_fun>=0) 212 { 213 ExtValue dummy,new_value; 213 ExtValue dummy, new_value; 214 214 cls->call(new_fun, &dummy, &new_value); 215 new_obj=new_value.getObject(); 216 } 215 new_obj = new_value.getObject(); 217 216 } 218 217 } 218 } 219 219 v->setObject(new_obj); 220 220 v++; 221 221 } 222 222 break; 223 223 case 'x': v++; break; -
cpp/frams/param/paramobj.h
r745 r792 53 53 ParamObject::freeObject(obj2); 54 54 */ 55 static ParamEntry* makeParamTab(ParamInterface *pi, bool stripgroups = 0, bool stripproc = 0, int firstprop = 0, int maxprops = 9999, bool dupentries = false, int flagsexclude_data = 0, int flagsexclude_tab = 0, bool addnew = false, const char* rename = NULL, bool readonly_into_userreadonly=false);55 static ParamEntry* makeParamTab(ParamInterface *pi, bool stripgroups = 0, bool stripproc = 0, int firstprop = 0, int maxprops = 9999, bool dupentries = false, int flagsexclude_data = 0, int flagsexclude_tab = 0, bool addnew = false, const char* rename = NULL, bool readonly_into_userreadonly = false); 56 56 57 57 /** deallocate paramtab obtained from makeParamTab() */ -
cpp/frams/param/paramtabobj.cpp
r478 r792 7 7 int ParamTab::measureTab(const ParamEntry *pe) 8 8 { 9 int i=0;10 while(pe->id) {i++;pe++;}11 return i;9 int i = 0; 10 while (pe->id) { i++; pe++; } 11 return i; 12 12 } 13 13 14 14 void ParamTab::resize(int s) 15 15 { 16 if (s==siz) return;17 tab=(ParamEntry*)realloc(tab,sizeof(ParamEntry)*(s+1));18 siz=s;16 if (s == siz) return; 17 tab = (ParamEntry*)realloc(tab, sizeof(ParamEntry)*(s + 1)); 18 siz = s; 19 19 } 20 20 21 int ParamTab::add(const ParamEntry* p, int count)21 int ParamTab::add(const ParamEntry* p, int count) 22 22 { 23 if (count<0) count=measureTab(p);24 resize(siz+count);25 memmove(tab+siz-count,p,sizeof(ParamEntry)*count);26 memset(tab+siz,0,sizeof(ParamEntry));27 if (siz>0) tab[0].flags=(paInt)(siz-tab[0].group);28 return siz-1;23 if (count < 0) count = measureTab(p); 24 resize(siz + count); 25 memmove(tab + siz - count, p, sizeof(ParamEntry)*count); 26 memset(tab + siz, 0, sizeof(ParamEntry)); 27 if (siz > 0) tab[0].flags = (paInt)(siz - tab[0].group); 28 return siz - 1; 29 29 } 30 30 31 void ParamTab::remove(int i, int count)31 void ParamTab::remove(int i, int count) 32 32 { 33 memmove(tab+i,tab+i+count,sizeof(ParamEntry)*count);34 resize(siz-count);35 memset(tab+siz,0,sizeof(ParamEntry));36 if (siz>0) tab[0].flags=(paInt)(siz-tab[0].group);33 memmove(tab + i, tab + i + count, sizeof(ParamEntry)*count); 34 resize(siz - count); 35 memset(tab + siz, 0, sizeof(ParamEntry)); 36 if (siz > 0) tab[0].flags = (paInt)(siz - tab[0].group); 37 37 } 38 -
cpp/frams/param/paramtabobj.h
r286 r792 10 10 class ParamTab 11 11 { 12 ParamEntry *tab;13 int siz;14 void init() {siz=0; tab=(ParamEntry*)calloc(sizeof(ParamEntry),1);}15 void resize(int s);16 int measureTab(const ParamEntry *pe);12 ParamEntry *tab; 13 int siz; 14 void init() { siz = 0; tab = (ParamEntry*)calloc(sizeof(ParamEntry), 1); } 15 void resize(int s); 16 int measureTab(const ParamEntry *pe); 17 17 18 19 ParamTab(const ParamEntry* pe=0,int maxcount=-1) {init(); if (pe) add(pe,maxcount);}20 ParamTab(const ParamTab& src) {init(); add(src);}21 ~ParamTab() {clear();}18 public: 19 ParamTab(const ParamEntry* pe = 0, int maxcount = -1) { init(); if (pe) add(pe, maxcount); } 20 ParamTab(const ParamTab& src) { init(); add(src); } 21 ~ParamTab() { clear(); } 22 22 23 int size() const {return siz;}24 ParamEntry* getParamTab() const {return tab;}25 ParamEntry* operator()() const {return tab;}23 int size() const { return siz; } 24 ParamEntry* getParamTab() const { return tab; } 25 ParamEntry* operator()() const { return tab; } 26 26 27 /** @return position of the last added entry */28 int add(const ParamEntry*,int count=1);29 int add(const ParamTab& src) {return add(src.getParamTab(), src.size());}30 void remove(int i,int count=1);31 void clear() {resize(-1);}27 /** @return position of the last added entry */ 28 int add(const ParamEntry*, int count = 1); 29 int add(const ParamTab& src) { return add(src.getParamTab(), src.size()); } 30 void remove(int i, int count = 1); 31 void clear() { resize(-1); } 32 32 }; 33 33
Note: See TracChangeset
for help on using the changeset viewer.