Changeset 3766


Ignore:
Timestamp:
05/17/10 09:03:42 (15 years ago)
Author:
Mathieu Morlighem
Message:

in DataSet/Parameters.cpp, no need to check that object enum is a Params

Location:
issm/trunk/src/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/DataSet/Parameters.cpp

    r3732 r3766  
    2323using namespace std;
    2424/*}}}*/
    25 /*Parameters: {{{1*/
    26 
    2725
    2826/*Object constructors and destructor*/
    29 /*FUNCTION Parameters::Parameters(){{{2*/
     27/*FUNCTION Parameters::Parameters(){{{1*/
    3028Parameters::Parameters(){
    3129        return;
    3230}
    3331/*}}}*/
    34 /*FUNCTION Parameters::Parameters(int in_enum){{{2*/
     32/*FUNCTION Parameters::Parameters(int in_enum){{{1*/
    3533Parameters::Parameters(int in_enum): DataSet(in_enum){
    3634        //do nothing;
     
    3836}
    3937/*}}}*/
    40 /*FUNCTION Parameters::~Parameters(){{{2*/
     38/*FUNCTION Parameters::~Parameters(){{{1*/
    4139Parameters::~Parameters(){
    4240        return;
     
    4543
    4644/*Object management*/
    47 /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{2*/
     45/*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{1*/
    4846int   Parameters::FindParam(bool* pbool,int enum_type){
    4947       
     
    5957        for ( object=objects.begin() ; object < objects.end(); object++ ){
    6058
    61                 /*Find param type objects: */
    62                 if((*object)->Enum()==ParamEnum){
    63 
    64                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    65                         param=(Param*)(*object);
    66 
    67                         if(param->EnumType()==enum_type){
    68                                 /*Ok, this is the one! Recover the value of this parameter: */
    69                                 param->GetParameterValue(pbool);
    70                                 found=1;
    71                                 break;
    72                         }
    73                 }
    74         }
    75         return found;
    76 }
    77 /*}}}*/
    78 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{2*/
     59                /*Ok, this object is a parameter, recover it and ask which name it has: */
     60                param=(Param*)(*object);
     61
     62                if(param->EnumType()==enum_type){
     63                        /*Ok, this is the one! Recover the value of this parameter: */
     64                        param->GetParameterValue(pbool);
     65                        found=1;
     66                        break;
     67                }
     68        }
     69        return found;
     70}
     71/*}}}*/
     72/*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{1*/
    7973int   Parameters::FindParam(int* pinteger,int enum_type){
    8074       
    81        
    82         /*Go through a dataset, and find a Param* object
    83          *which parameter name is "name" : */
    84        
    85         vector<Object*>::iterator object;
    86         Param* param=NULL;
    87 
    88         int found=0;
    89 
    90         for ( object=objects.begin() ; object < objects.end(); object++ ){
    91 
    92                 /*Find param type objects: */
    93                 if((*object)->Enum()==ParamEnum){
    94 
    95                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    96                         param=(Param*)(*object);
    97 
    98                         if(param->EnumType()==enum_type){
    99                                 /*Ok, this is the one! Recover the value of this parameter: */
    100                                 param->GetParameterValue(pinteger);
    101                                 found=1;
    102                                 break;
    103                         }
    104                 }
    105         }
    106         return found;
    107 }
    108 /*}}}*/
    109 /*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{2*/
     75        /*Go through a dataset, and find a Param* object
     76         *which parameter name is "name" : */
     77       
     78        vector<Object*>::iterator object;
     79        Param* param=NULL;
     80
     81        int found=0;
     82
     83        for ( object=objects.begin() ; object < objects.end(); object++ ){
     84
     85                /*Ok, this object is a parameter, recover it and ask which name it has: */
     86                param=(Param*)(*object);
     87
     88                if(param->EnumType()==enum_type){
     89                        /*Ok, this is the one! Recover the value of this parameter: */
     90                        param->GetParameterValue(pinteger);
     91                        found=1;
     92                        break;
     93                }
     94        }
     95        return found;
     96}
     97/*}}}*/
     98/*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{1*/
    11099int   Parameters::FindParam(double* pscalar, int enum_type){
    111100       
     
    120109        for ( object=objects.begin() ; object < objects.end(); object++ ){
    121110
    122                 /*Find param type objects: */
    123                 if((*object)->Enum()==ParamEnum){
    124 
    125                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    126                         param=(Param*)(*object);
    127 
    128                         if(param->EnumType()==enum_type){
    129                                 /*Ok, this is the one! Recover the value of this parameter: */
    130                                 param->GetParameterValue(pscalar);
    131                                 found=1;
    132                                 break;
    133                         }
    134                 }
    135         }
    136         return found;
    137 }
    138 /*}}}*/
    139 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{2*/
     111                /*Ok, this object is a parameter, recover it and ask which name it has: */
     112                param=(Param*)(*object);
     113
     114                if(param->EnumType()==enum_type){
     115                        /*Ok, this is the one! Recover the value of this parameter: */
     116                        param->GetParameterValue(pscalar);
     117                        found=1;
     118                        break;
     119                }
     120        }
     121        return found;
     122}
     123/*}}}*/
     124/*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{1*/
    140125int   Parameters::FindParam(char** pstring,int enum_type){
    141126       
     
    150135        for ( object=objects.begin() ; object < objects.end(); object++ ){
    151136
    152                 /*Find param type objects: */
    153                 if((*object)->Enum()==ParamEnum){
    154 
    155                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    156                         param=(Param*)(*object);
    157 
    158                         if(param->EnumType()==enum_type){
    159                                 /*Ok, this is the one! Recover the value of this parameter: */
    160                                 param->GetParameterValue(pstring);
    161                                 found=1;
    162                                 break;
    163                         }
    164                 }
    165         }
    166         return found;
    167 
    168 }
    169 /*}}}*/
    170 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{2*/
     137                /*Ok, this object is a parameter, recover it and ask which name it has: */
     138                param=(Param*)(*object);
     139
     140                if(param->EnumType()==enum_type){
     141                        /*Ok, this is the one! Recover the value of this parameter: */
     142                        param->GetParameterValue(pstring);
     143                        found=1;
     144                        break;
     145                }
     146        }
     147        return found;
     148
     149}
     150/*}}}*/
     151/*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{1*/
    171152int   Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){
    172153       
     
    181162        for ( object=objects.begin() ; object < objects.end(); object++ ){
    182163
    183                 /*Find param type objects: */
    184                 if((*object)->Enum()==ParamEnum){
    185 
    186                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    187                         param=(Param*)(*object);
    188 
    189                         if(param->EnumType()==enum_type){
    190                                 /*Ok, this is the one! Recover the value of this parameter: */
    191                                 param->GetParameterValue(pstringarray,pM);
    192                                 found=1;
    193                                 break;
    194                         }
    195                 }
    196         }
    197         return found;
    198 
    199 }
    200 /*}}}*/
    201 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{2*/
     164                /*Ok, this object is a parameter, recover it and ask which name it has: */
     165                param=(Param*)(*object);
     166
     167                if(param->EnumType()==enum_type){
     168                        /*Ok, this is the one! Recover the value of this parameter: */
     169                        param->GetParameterValue(pstringarray,pM);
     170                        found=1;
     171                        break;
     172                }
     173        }
     174        return found;
     175
     176}
     177/*}}}*/
     178/*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{1*/
    202179int   Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){
    203180       
     
    212189        for ( object=objects.begin() ; object < objects.end(); object++ ){
    213190
    214                 /*Find param type objects: */
    215                 if((*object)->Enum()==ParamEnum){
    216 
    217                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    218                         param=(Param*)(*object);
    219 
    220                         if(param->EnumType()==enum_type){
    221                                 /*Ok, this is the one! Recover the value of this parameter: */
    222                                 param->GetParameterValue(pdoublearray,pM);
    223                                 found=1;
    224                                 break;
    225                         }
    226                 }
    227         }
    228         return found;
    229 
    230 }
    231 /*}}}*/
    232 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{2*/
     191                /*Ok, this object is a parameter, recover it and ask which name it has: */
     192                param=(Param*)(*object);
     193
     194                if(param->EnumType()==enum_type){
     195                        /*Ok, this is the one! Recover the value of this parameter: */
     196                        param->GetParameterValue(pdoublearray,pM);
     197                        found=1;
     198                        break;
     199                }
     200        }
     201        return found;
     202
     203}
     204/*}}}*/
     205/*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{1*/
    233206int   Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){
    234207       
     
    243216        for ( object=objects.begin() ; object < objects.end(); object++ ){
    244217
    245                 /*Find param type objects: */
    246                 if((*object)->Enum()==ParamEnum){
    247 
    248                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    249                         param=(Param*)(*object);
    250 
    251                         if(param->EnumType()==enum_type){
    252                                 /*Ok, this is the one! Recover the value of this parameter: */
    253                                 param->GetParameterValue(pdoublearray,pM,pN);
    254                                 found=1;
    255                                 break;
    256                         }
    257                 }
    258         }
    259         return found;
    260 
    261 }
    262 /*}}}*/
    263 /*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{2*/
     218                /*Ok, this object is a parameter, recover it and ask which name it has: */
     219                param=(Param*)(*object);
     220
     221                if(param->EnumType()==enum_type){
     222                        /*Ok, this is the one! Recover the value of this parameter: */
     223                        param->GetParameterValue(pdoublearray,pM,pN);
     224                        found=1;
     225                        break;
     226                }
     227        }
     228        return found;
     229
     230}
     231/*}}}*/
     232/*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/
    264233int   Parameters::FindParam(Vec* pvec,int enum_type){
    265234       
     
    274243        for ( object=objects.begin() ; object < objects.end(); object++ ){
    275244
    276                 /*Find param type objects: */
    277                 if((*object)->Enum()==ParamEnum){
    278 
    279                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    280                         param=(Param*)(*object);
    281 
    282                         if(param->EnumType()==enum_type){
    283                                 /*Ok, this is the one! Recover the value of this parameter: */
    284                                 param->GetParameterValue(pvec);
    285                                 found=1;
    286                                 break;
    287                         }
    288                 }
    289         }
    290         return found;
    291 
    292 }
    293 /*}}}*/
    294 /*FUNCTION Parameters::FindParamMat* pmat,int enum_type){{{2*/
     245                /*Ok, this object is a parameter, recover it and ask which name it has: */
     246                param=(Param*)(*object);
     247
     248                if(param->EnumType()==enum_type){
     249                        /*Ok, this is the one! Recover the value of this parameter: */
     250                        param->GetParameterValue(pvec);
     251                        found=1;
     252                        break;
     253                }
     254        }
     255        return found;
     256
     257}
     258/*}}}*/
     259/*FUNCTION Parameters::FindParamMat* pmat,int enum_type){{{1*/
    295260int   Parameters::FindParam(Mat* pmat,int enum_type){
    296261       
     
    305270        for ( object=objects.begin() ; object < objects.end(); object++ ){
    306271
    307                 /*Find param type objects: */
    308                 if((*object)->Enum()==ParamEnum){
    309 
    310                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    311                         param=(Param*)(*object);
    312 
    313                         if(param->EnumType()==enum_type){
    314                                 /*Ok, this is the one! Recover the value of this parameter: */
    315                                 param->GetParameterValue(pmat);
    316                                 found=1;
    317                                 break;
    318                         }
    319                 }
    320         }
    321         return found;
    322 
    323 }
    324 /*}}}*/
    325 /*FUNCTION Parameters::FindParamObject{{{2*/
     272                /*Ok, this object is a parameter, recover it and ask which name it has: */
     273                param=(Param*)(*object);
     274
     275                if(param->EnumType()==enum_type){
     276                        /*Ok, this is the one! Recover the value of this parameter: */
     277                        param->GetParameterValue(pmat);
     278                        found=1;
     279                        break;
     280                }
     281        }
     282        return found;
     283
     284}
     285/*}}}*/
     286/*FUNCTION Parameters::FindParamObject{{{1*/
    326287Object* Parameters::FindParamObject(int enum_type){
    327288
     
    334295        for ( object=objects.begin() ; object < objects.end(); object++ ){
    335296
    336                 /*Find param type objects: */
    337                 if((*object)->Enum()==ParamEnum){
    338 
    339                         /*Ok, this object is a parameter, recover it and ask which name it has: */
    340                         param=(Param*)(*object);
    341 
    342                         if(param->EnumType()==enum_type){
    343                                 /*Ok, this is the one! Return the object: */
    344                                 return (*object);
    345                         }
     297                /*Ok, this object is a parameter, recover it and ask which name it has: */
     298                param=(Param*)(*object);
     299
     300                if(param->EnumType()==enum_type){
     301                        /*Ok, this is the one! Return the object: */
     302                        return (*object);
    346303                }
    347304        }
     
    349306}
    350307/*}}}*/
    351 
    352 /*Object functions*/
    353 
    354 
    355 /*}}}*/
  • issm/trunk/src/c/ModelProcessorx/CreateParameters.cpp

    r3713 r3766  
    3030        if (strcmp(iomodel->meshtype,"2d")==0) parameters->AddObject(new IntParam(DimEnum,2));
    3131        else parameters->AddObject(new IntParam(DimEnum,3));
    32         parameters->AddObject(new   StringParam(OutputFileNameEnum,iomodel->outputfilename));
     32        parameters->AddObject(new StringParam(OutputFileNameEnum,iomodel->outputfilename));
    3333        parameters->AddObject(new   BoolParam(IsHutterEnum,iomodel->ishutter));
    3434        parameters->AddObject(new   BoolParam(IsMacAyealPattynEnum,iomodel->ismacayealpattyn));
     
    5858        parameters->AddObject(new DoubleParam(ViscosityOvershootEnum,iomodel->viscosity_overshoot));
    5959        parameters->AddObject(new   BoolParam(WaitOnLockEnum,iomodel->waitonlock));
    60         parameters->AddObject(new   StringParam(SolverStringEnum,iomodel->solverstring));
     60        parameters->AddObject(new StringParam(SolverStringEnum,iomodel->solverstring));
    6161        parameters->AddObject(new    IntParam(NumberOfVerticesEnum,iomodel->numberofvertices));
    6262        parameters->AddObject(new    IntParam(NumberOfElementsEnum,iomodel->numberofelements));
Note: See TracChangeset for help on using the changeset viewer.