[3702] | 1 | /*
|
---|
| 2 | * \file Parameters.c
|
---|
| 3 | * \brief: implementation of the Parameters class, derived from DataSet class
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*Headers: {{{1*/
|
---|
| 7 | #ifdef HAVE_CONFIG_H
|
---|
| 8 | #include "config.h"
|
---|
| 9 | #else
|
---|
| 10 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 11 | #endif
|
---|
| 12 |
|
---|
| 13 | #include <vector>
|
---|
| 14 | #include <functional>
|
---|
| 15 | #include <algorithm>
|
---|
| 16 | #include <iostream>
|
---|
| 17 |
|
---|
| 18 | #include "./DataSet.h"
|
---|
| 19 | #include "../shared/shared.h"
|
---|
[3775] | 20 | #include "../include/include.h"
|
---|
[3702] | 21 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 22 |
|
---|
| 23 | using namespace std;
|
---|
| 24 | /*}}}*/
|
---|
| 25 |
|
---|
| 26 | /*Object constructors and destructor*/
|
---|
[3766] | 27 | /*FUNCTION Parameters::Parameters(){{{1*/
|
---|
[3702] | 28 | Parameters::Parameters(){
|
---|
| 29 | return;
|
---|
| 30 | }
|
---|
| 31 | /*}}}*/
|
---|
[3766] | 32 | /*FUNCTION Parameters::Parameters(int in_enum){{{1*/
|
---|
[3702] | 33 | Parameters::Parameters(int in_enum): DataSet(in_enum){
|
---|
| 34 | //do nothing;
|
---|
| 35 | return;
|
---|
| 36 | }
|
---|
| 37 | /*}}}*/
|
---|
[3766] | 38 | /*FUNCTION Parameters::~Parameters(){{{1*/
|
---|
[3702] | 39 | Parameters::~Parameters(){
|
---|
| 40 | return;
|
---|
| 41 | }
|
---|
| 42 | /*}}}*/
|
---|
| 43 |
|
---|
| 44 | /*Object management*/
|
---|
[3766] | 45 | /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{1*/
|
---|
[3732] | 46 | int Parameters::FindParam(bool* pbool,int enum_type){
|
---|
[3702] | 47 |
|
---|
| 48 | /*Go through a dataset, and find a Param* object
|
---|
| 49 | *which parameter name is "name" : */
|
---|
| 50 |
|
---|
| 51 | vector<Object*>::iterator object;
|
---|
| 52 | Param* param=NULL;
|
---|
| 53 |
|
---|
| 54 | int found=0;
|
---|
| 55 |
|
---|
| 56 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 57 |
|
---|
[3766] | 58 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 59 | param=(Param*)(*object);
|
---|
[3702] | 60 |
|
---|
[3766] | 61 | if(param->EnumType()==enum_type){
|
---|
| 62 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 63 | param->GetParameterValue(pbool);
|
---|
| 64 | found=1;
|
---|
| 65 | break;
|
---|
[3702] | 66 | }
|
---|
| 67 | }
|
---|
| 68 | return found;
|
---|
| 69 | }
|
---|
| 70 | /*}}}*/
|
---|
[3766] | 71 | /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{1*/
|
---|
[3702] | 72 | int Parameters::FindParam(int* pinteger,int enum_type){
|
---|
| 73 |
|
---|
| 74 | /*Go through a dataset, and find a Param* object
|
---|
| 75 | *which parameter name is "name" : */
|
---|
| 76 |
|
---|
| 77 | vector<Object*>::iterator object;
|
---|
| 78 | Param* param=NULL;
|
---|
| 79 |
|
---|
| 80 | int found=0;
|
---|
| 81 |
|
---|
| 82 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 83 |
|
---|
[3766] | 84 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 85 | param=(Param*)(*object);
|
---|
[3702] | 86 |
|
---|
[3766] | 87 | if(param->EnumType()==enum_type){
|
---|
| 88 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 89 | param->GetParameterValue(pinteger);
|
---|
| 90 | found=1;
|
---|
| 91 | break;
|
---|
[3702] | 92 | }
|
---|
| 93 | }
|
---|
| 94 | return found;
|
---|
| 95 | }
|
---|
| 96 | /*}}}*/
|
---|
[3766] | 97 | /*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{1*/
|
---|
[3732] | 98 | int Parameters::FindParam(double* pscalar, int enum_type){
|
---|
| 99 |
|
---|
| 100 | /*Go through a dataset, and find a Param* object
|
---|
| 101 | *which parameter name is "name" : */
|
---|
| 102 |
|
---|
| 103 | vector<Object*>::iterator object;
|
---|
| 104 | Param* param=NULL;
|
---|
| 105 |
|
---|
| 106 | int found=0;
|
---|
| 107 |
|
---|
| 108 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 109 |
|
---|
[3766] | 110 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 111 | param=(Param*)(*object);
|
---|
[3732] | 112 |
|
---|
[3766] | 113 | if(param->EnumType()==enum_type){
|
---|
| 114 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 115 | param->GetParameterValue(pscalar);
|
---|
| 116 | found=1;
|
---|
| 117 | break;
|
---|
[3732] | 118 | }
|
---|
| 119 | }
|
---|
| 120 | return found;
|
---|
| 121 | }
|
---|
| 122 | /*}}}*/
|
---|
[3766] | 123 | /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{1*/
|
---|
[3702] | 124 | int Parameters::FindParam(char** pstring,int enum_type){
|
---|
| 125 |
|
---|
| 126 | /*Go through a dataset, and find a Param* object
|
---|
| 127 | *which parameter name is "name" : */
|
---|
| 128 |
|
---|
| 129 | vector<Object*>::iterator object;
|
---|
| 130 | Param* param=NULL;
|
---|
| 131 |
|
---|
| 132 | int found=0;
|
---|
| 133 |
|
---|
| 134 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 135 |
|
---|
[3766] | 136 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 137 | param=(Param*)(*object);
|
---|
[3702] | 138 |
|
---|
[3766] | 139 | if(param->EnumType()==enum_type){
|
---|
| 140 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 141 | param->GetParameterValue(pstring);
|
---|
| 142 | found=1;
|
---|
| 143 | break;
|
---|
[3702] | 144 | }
|
---|
| 145 | }
|
---|
| 146 | return found;
|
---|
| 147 |
|
---|
| 148 | }
|
---|
| 149 | /*}}}*/
|
---|
[3766] | 150 | /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{1*/
|
---|
[3702] | 151 | int Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){
|
---|
| 152 |
|
---|
| 153 | /*Go through a dataset, and find a Param* object
|
---|
| 154 | *which parameter name is "name" : */
|
---|
| 155 |
|
---|
| 156 | vector<Object*>::iterator object;
|
---|
| 157 | Param* param=NULL;
|
---|
| 158 |
|
---|
| 159 | int found=0;
|
---|
| 160 |
|
---|
| 161 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 162 |
|
---|
[3766] | 163 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 164 | param=(Param*)(*object);
|
---|
[3702] | 165 |
|
---|
[3766] | 166 | if(param->EnumType()==enum_type){
|
---|
| 167 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 168 | param->GetParameterValue(pstringarray,pM);
|
---|
| 169 | found=1;
|
---|
| 170 | break;
|
---|
[3702] | 171 | }
|
---|
| 172 | }
|
---|
| 173 | return found;
|
---|
| 174 |
|
---|
| 175 | }
|
---|
| 176 | /*}}}*/
|
---|
[3766] | 177 | /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{1*/
|
---|
[3702] | 178 | int Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){
|
---|
| 179 |
|
---|
| 180 | /*Go through a dataset, and find a Param* object
|
---|
| 181 | *which parameter name is "name" : */
|
---|
| 182 |
|
---|
| 183 | vector<Object*>::iterator object;
|
---|
| 184 | Param* param=NULL;
|
---|
| 185 |
|
---|
| 186 | int found=0;
|
---|
| 187 |
|
---|
| 188 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 189 |
|
---|
[3766] | 190 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 191 | param=(Param*)(*object);
|
---|
[3702] | 192 |
|
---|
[3766] | 193 | if(param->EnumType()==enum_type){
|
---|
| 194 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 195 | param->GetParameterValue(pdoublearray,pM);
|
---|
| 196 | found=1;
|
---|
| 197 | break;
|
---|
[3702] | 198 | }
|
---|
| 199 | }
|
---|
| 200 | return found;
|
---|
| 201 |
|
---|
| 202 | }
|
---|
| 203 | /*}}}*/
|
---|
[3766] | 204 | /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{1*/
|
---|
[3702] | 205 | int Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){
|
---|
| 206 |
|
---|
| 207 | /*Go through a dataset, and find a Param* object
|
---|
| 208 | *which parameter name is "name" : */
|
---|
| 209 |
|
---|
| 210 | vector<Object*>::iterator object;
|
---|
| 211 | Param* param=NULL;
|
---|
| 212 |
|
---|
| 213 | int found=0;
|
---|
| 214 |
|
---|
| 215 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 216 |
|
---|
[3766] | 217 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 218 | param=(Param*)(*object);
|
---|
[3702] | 219 |
|
---|
[3766] | 220 | if(param->EnumType()==enum_type){
|
---|
| 221 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 222 | param->GetParameterValue(pdoublearray,pM,pN);
|
---|
| 223 | found=1;
|
---|
| 224 | break;
|
---|
[3702] | 225 | }
|
---|
| 226 | }
|
---|
| 227 | return found;
|
---|
| 228 |
|
---|
| 229 | }
|
---|
| 230 | /*}}}*/
|
---|
[4855] | 231 | /*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/
|
---|
| 232 | int Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){
|
---|
| 233 |
|
---|
| 234 | /*Go through a dataset, and find a Param* object
|
---|
| 235 | *which parameter name is "name" : */
|
---|
| 236 |
|
---|
| 237 | vector<Object*>::iterator object;
|
---|
| 238 | Param* param=NULL;
|
---|
| 239 |
|
---|
| 240 | int found=0;
|
---|
| 241 |
|
---|
| 242 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 243 |
|
---|
| 244 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 245 | param=(Param*)(*object);
|
---|
| 246 |
|
---|
| 247 | if(param->EnumType()==enum_type){
|
---|
| 248 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 249 | param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
|
---|
| 250 | found=1;
|
---|
| 251 | break;
|
---|
| 252 | }
|
---|
| 253 | }
|
---|
| 254 | return found;
|
---|
| 255 | }
|
---|
| 256 | /*}}}*/
|
---|
[3766] | 257 | /*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/
|
---|
[3702] | 258 | int Parameters::FindParam(Vec* pvec,int enum_type){
|
---|
| 259 |
|
---|
| 260 | /*Go through a dataset, and find a Param* object
|
---|
| 261 | *which parameter name is "name" : */
|
---|
| 262 |
|
---|
| 263 | vector<Object*>::iterator object;
|
---|
| 264 | Param* param=NULL;
|
---|
| 265 |
|
---|
| 266 | int found=0;
|
---|
| 267 |
|
---|
| 268 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 269 |
|
---|
[3766] | 270 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 271 | param=(Param*)(*object);
|
---|
[3702] | 272 |
|
---|
[3766] | 273 | if(param->EnumType()==enum_type){
|
---|
| 274 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 275 | param->GetParameterValue(pvec);
|
---|
| 276 | found=1;
|
---|
| 277 | break;
|
---|
[3702] | 278 | }
|
---|
| 279 | }
|
---|
| 280 | return found;
|
---|
| 281 |
|
---|
| 282 | }
|
---|
| 283 | /*}}}*/
|
---|
[4059] | 284 | /*FUNCTION Parameters::FindParam(Mat* pmat,int enum_type){{{1*/
|
---|
[3702] | 285 | int Parameters::FindParam(Mat* pmat,int enum_type){
|
---|
| 286 |
|
---|
| 287 | /*Go through a dataset, and find a Param* object
|
---|
| 288 | *which parameter name is "name" : */
|
---|
| 289 |
|
---|
| 290 | vector<Object*>::iterator object;
|
---|
| 291 | Param* param=NULL;
|
---|
| 292 |
|
---|
| 293 | int found=0;
|
---|
| 294 |
|
---|
| 295 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 296 |
|
---|
[3766] | 297 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 298 | param=(Param*)(*object);
|
---|
[3702] | 299 |
|
---|
[3766] | 300 | if(param->EnumType()==enum_type){
|
---|
| 301 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 302 | param->GetParameterValue(pmat);
|
---|
| 303 | found=1;
|
---|
| 304 | break;
|
---|
[3702] | 305 | }
|
---|
| 306 | }
|
---|
| 307 | return found;
|
---|
| 308 |
|
---|
| 309 | }
|
---|
| 310 | /*}}}*/
|
---|
[4873] | 311 | /*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{1*/
|
---|
| 312 | int Parameters::FindParam(FILE** pfid,int enum_type){
|
---|
[4059] | 313 |
|
---|
[4873] | 314 | /*Go through a dataset, and find a Param* object
|
---|
| 315 | *which parameter name is "name" : */
|
---|
| 316 |
|
---|
| 317 | vector<Object*>::iterator object;
|
---|
| 318 | Param* param=NULL;
|
---|
| 319 |
|
---|
| 320 | int found=0;
|
---|
| 321 |
|
---|
| 322 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 323 |
|
---|
| 324 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 325 | param=(Param*)(*object);
|
---|
| 326 |
|
---|
| 327 | if(param->EnumType()==enum_type){
|
---|
| 328 | /*Ok, this is the one! Recover the value of this parameter: */
|
---|
| 329 | param->GetParameterValue(pfid);
|
---|
| 330 | found=1;
|
---|
| 331 | break;
|
---|
| 332 | }
|
---|
| 333 | }
|
---|
| 334 | return found;
|
---|
| 335 | }
|
---|
| 336 | /*}}}*/
|
---|
| 337 |
|
---|
[4059] | 338 | /*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{1*/
|
---|
| 339 | void Parameters::SetParam(bool boolean,int enum_type){
|
---|
| 340 |
|
---|
| 341 | Param* param=NULL;
|
---|
| 342 |
|
---|
| 343 | /*first, figure out if the param has already been created: */
|
---|
| 344 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 345 |
|
---|
| 346 | if(param) param->SetValue(boolean); //already exists, just set it.
|
---|
| 347 | else this->AddObject(new BoolParam(enum_type,boolean)); //just add the new parameter.
|
---|
| 348 | }
|
---|
| 349 | /*}}}*/
|
---|
| 350 | /*FUNCTION Parameters::SetParam(int integer,int enum_type);{{{1*/
|
---|
| 351 | void Parameters::SetParam(int integer,int enum_type){
|
---|
| 352 |
|
---|
| 353 | Param* param=NULL;
|
---|
| 354 |
|
---|
| 355 | /*first, figure out if the param has already been created: */
|
---|
| 356 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 357 |
|
---|
| 358 | if(param) param->SetValue(integer); //already exists, just set it.
|
---|
| 359 | else this->AddObject(new IntParam(enum_type,integer)); //just add the new parameter.
|
---|
| 360 | }
|
---|
| 361 | /*}}}*/
|
---|
| 362 | /*FUNCTION Parameters::SetParam(double scalar,int enum_type);{{{1*/
|
---|
| 363 | void Parameters::SetParam(double scalar,int enum_type){
|
---|
| 364 |
|
---|
| 365 | Param* param=NULL;
|
---|
| 366 |
|
---|
| 367 | /*first, figure out if the param has already been created: */
|
---|
| 368 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 369 |
|
---|
| 370 | if(param) param->SetValue(scalar); //already exists, just set it.
|
---|
| 371 | else this->AddObject(new DoubleParam(enum_type,scalar)); //just add the new parameter.
|
---|
| 372 | }
|
---|
| 373 | /*}}}*/
|
---|
| 374 | /*FUNCTION Parameters::SetParam(char* string,int enum_type);{{{1*/
|
---|
| 375 | void Parameters::SetParam(char* string,int enum_type){
|
---|
| 376 |
|
---|
| 377 | Param* param=NULL;
|
---|
| 378 |
|
---|
| 379 | /*first, figure out if the param has already been created: */
|
---|
| 380 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 381 |
|
---|
| 382 | if(param) param->SetValue(string); //already exists, just set it.
|
---|
| 383 | else this->AddObject(new StringParam(enum_type,string)); //just add the new parameter.
|
---|
| 384 | }
|
---|
| 385 | /*}}}*/
|
---|
| 386 | /*FUNCTION Parameters::SetParam(char** stringarray,int M, int enum_type);{{{1*/
|
---|
| 387 | void Parameters::SetParam(char** stringarray,int M, int enum_type){
|
---|
| 388 |
|
---|
| 389 | Param* param=NULL;
|
---|
| 390 |
|
---|
| 391 | /*first, figure out if the param has already been created: */
|
---|
| 392 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 393 |
|
---|
| 394 | if(param) param->SetValue(stringarray,M); //already exists, just set it.
|
---|
| 395 | else this->AddObject(new StringArrayParam(enum_type,stringarray,M)); //just add the new parameter.
|
---|
| 396 | }
|
---|
| 397 | /*}}}*/
|
---|
| 398 | /*FUNCTION Parameters::SetParam(double* doublearray,int M,int enum_type);{{{1*/
|
---|
| 399 | void Parameters::SetParam(double* doublearray,int M, int enum_type){
|
---|
| 400 |
|
---|
| 401 | Param* param=NULL;
|
---|
| 402 |
|
---|
| 403 | /*first, figure out if the param has already been created: */
|
---|
| 404 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 405 |
|
---|
| 406 | if(param) param->SetValue(doublearray,M); //already exists, just set it.
|
---|
| 407 | else this->AddObject(new DoubleVecParam(enum_type,doublearray,M)); //just add the new parameter.
|
---|
| 408 | }
|
---|
| 409 | /*}}}*/
|
---|
| 410 | /*FUNCTION Parameters::SetParam(double* doublearray,int M,int N, int enum_type);{{{1*/
|
---|
| 411 | void Parameters::SetParam(double* doublearray,int M, int N, int enum_type){
|
---|
| 412 |
|
---|
| 413 | Param* param=NULL;
|
---|
| 414 |
|
---|
| 415 | /*first, figure out if the param has already been created: */
|
---|
| 416 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 417 |
|
---|
| 418 | if(param) param->SetValue(doublearray,M,N); //already exists, just set it.
|
---|
| 419 | else this->AddObject(new DoubleMatParam(enum_type,doublearray,M,N)); //just add the new parameter.
|
---|
| 420 | }
|
---|
| 421 | /*}}}*/
|
---|
| 422 | /*FUNCTION Parameters::SetParam(Vec vector,int enum_type);{{{1*/
|
---|
| 423 | void Parameters::SetParam(Vec vector,int enum_type){
|
---|
| 424 |
|
---|
| 425 | Param* param=NULL;
|
---|
| 426 |
|
---|
| 427 | /*first, figure out if the param has already been created: */
|
---|
| 428 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 429 |
|
---|
| 430 | if(param) param->SetValue(vector); //already exists, just set it.
|
---|
| 431 | else this->AddObject(new PetscVecParam(enum_type,vector)); //just add the new parameter.
|
---|
| 432 | }
|
---|
| 433 | /*}}}*/
|
---|
| 434 | /*FUNCTION Parameters::SetParam(Mat matrix,int enum_type);{{{1*/
|
---|
| 435 | void Parameters::SetParam(Mat matrix,int enum_type){
|
---|
| 436 |
|
---|
| 437 | Param* param=NULL;
|
---|
| 438 |
|
---|
| 439 | /*first, figure out if the param has already been created: */
|
---|
| 440 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 441 |
|
---|
| 442 | if(param) param->SetValue(matrix); //already exists, just set it.
|
---|
| 443 | else this->AddObject(new PetscMatParam(enum_type,matrix)); //just add the new parameter.
|
---|
| 444 | }
|
---|
| 445 | /*}}}*/
|
---|
[4873] | 446 | /*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{1*/
|
---|
| 447 | void Parameters::SetParam(FILE* fid,int enum_type){
|
---|
[4059] | 448 |
|
---|
[4873] | 449 | Param* param=NULL;
|
---|
| 450 |
|
---|
| 451 | /*first, figure out if the param has already been created: */
|
---|
| 452 | param=(Param*)this->FindParamObject(enum_type);
|
---|
| 453 |
|
---|
| 454 | if(param) param->SetValue(fid); //already exists, just set it.
|
---|
| 455 | else this->AddObject(new FileParam(enum_type,fid)); //just add the new parameter.
|
---|
| 456 | }
|
---|
| 457 | /*}}}*/
|
---|
| 458 |
|
---|
[3766] | 459 | /*FUNCTION Parameters::FindParamObject{{{1*/
|
---|
[3702] | 460 | Object* Parameters::FindParamObject(int enum_type){
|
---|
| 461 |
|
---|
| 462 | /*Go through a dataset, and find a Param* object
|
---|
| 463 | *which parameter name is "name" : */
|
---|
| 464 |
|
---|
| 465 | vector<Object*>::iterator object;
|
---|
| 466 | Param* param=NULL;
|
---|
| 467 |
|
---|
| 468 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
| 469 |
|
---|
[3766] | 470 | /*Ok, this object is a parameter, recover it and ask which name it has: */
|
---|
| 471 | param=(Param*)(*object);
|
---|
[3702] | 472 |
|
---|
[3766] | 473 | if(param->EnumType()==enum_type){
|
---|
| 474 | /*Ok, this is the one! Return the object: */
|
---|
| 475 | return (*object);
|
---|
[3702] | 476 | }
|
---|
| 477 | }
|
---|
| 478 | return NULL;
|
---|
| 479 | }
|
---|
| 480 | /*}}}*/
|
---|