Changeset 7760


Ignore:
Timestamp:
04/01/11 15:22:11 (14 years ago)
Author:
Mathieu Morlighem
Message:

Added Get for double arrays

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

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk/src/c/Container/Options.cpp

    r7746 r7760  
    215215        }
    216216
     217}
     218/*}}}*/
     219/*FUNCTION Options::Get(double** pvalue,int* numel,const char* name){{{1*/
     220void Options::Get(double** pvalue,int* numel,const char* name){
     221
     222        vector<Object*>::iterator object;
     223        Option* option=NULL;
     224
     225        /*Get option*/
     226        option=GetOption(name);
     227
     228        /*If the pointer is not NULL, the option has been found*/
     229        if(option){
     230                option->Get(pvalue,numel);
     231        }
     232        /*Else, the Option does not exist, no default provided*/
     233        else{
     234                _error_("option of name \"%s\" not found, and no default value has been provided",name);
     235        }
    217236}
    218237/*}}}*/
  • TabularUnified issm/trunk/src/c/Container/Options.h

    r7746 r7760  
    2323                int  AddOption(Option* in_oobject);
    2424                Option* GetOption(const char* name);
    25                 void Get(double* pvalue,const char* name);
    26                 void Get(double* pvalue,const char* name,double default_value);
    27                 void Get(bool*   pvalue,const char* name);
    28                 void Get(bool*   pvalue,const char* name,bool default_value);
    29                 void Get(char**  pvalue,const char* name);
    30                 void Get(char**  pvalue,const char* name,const char* default_value);
     25                void Get(double*  pvalue,const char* name);
     26                void Get(double*  pvalue,const char* name,double default_value);
     27                void Get(bool*    pvalue,const char* name);
     28                void Get(bool*    pvalue,const char* name,bool default_value);
     29                void Get(char**   pvalue,const char* name);
     30                void Get(char**   pvalue,const char* name,const char* default_value);
     31                void Get(double** pvalue,int* numel,const char* name);
    3132};
    3233
  • TabularUnified issm/trunk/src/c/objects/Options/Option.h

    r7746 r7760  
    4848                virtual void  Get(bool* pvalue)=0;
    4949                virtual void  Get(char** pvalue)=0;
     50                virtual void  Get(double** pvalue,int *pnumel)=0;
    5051
    5152};
  • TabularUnified issm/trunk/src/c/objects/Options/OptionCell.h

    r7746 r7760  
    4545                void  Get(bool* pvalue){  _error_("An OptionCell object cannot return a bool");};
    4646                void  Get(char** pvalue){ _error_("An OptionCell object cannot return a string");};
     47                void  Get(double** pvalue,int *pnumel){ _error_("An OptionCell object cannot return a double vec");};
    4748
    4849};
  • TabularUnified issm/trunk/src/c/objects/Options/OptionChar.h

    r7746 r7760  
    4545                void  Get(bool* pvalue){  _error_("An OptionChar object cannot return a bool");};
    4646                void  Get(char** pvalue);
     47                void  Get(double** pvalue,int *pnumel){ _error_("An OptionChar object cannot return a double vec");};
    4748
    4849};
  • TabularUnified issm/trunk/src/c/objects/Options/OptionDouble.cpp

    r7746 r7760  
    131131}
    132132/*}}}*/
     133/*FUNCTION OptionDouble::Get(double** pvalue,int* numel) {{{1*/
     134void OptionDouble::Get(double** pvalue,int* numel){
     135
     136        /*We should first check that the size is one*/
     137        if(this->NumEl()<=0){
     138                _error_("option \"%s\" is empty and cannot return a double vector",this->name);
     139        }
     140
     141        /*Copy vector*/
     142        double* outvalue=(double*)xmalloc(this->NumEl()*sizeof(double));
     143        for(int i=0;i<this->NumEl();i++) outvalue[i]=this->values[i];
     144
     145        /*Assign output pointer*/
     146        *pvalue=outvalue;
     147        if(numel) *numel=this->NumEl();
     148}
     149/*}}}*/
  • TabularUnified issm/trunk/src/c/objects/Options/OptionDouble.h

    r7746 r7760  
    4545                void  Get(bool* pvalue){  _error_("An OptionDouble object cannot return a bool");};
    4646                void  Get(char** pvalue){ _error_("An OptionDouble object cannot return a string");};
     47                void  Get(double** pvalue,int* pnumel);
    4748
    4849};
  • TabularUnified issm/trunk/src/c/objects/Options/OptionLogical.h

    r7746 r7760  
    4545                void  Get(bool* pvalue);
    4646                void  Get(char** pvalue){ _error_("An OptionLogical object cannot return a string");};
     47                void  Get(double** pvalue,int *pnumel){ _error_("An OptionLogical object cannot return a double vec");};
    4748
    4849};
  • TabularUnified issm/trunk/src/c/objects/Options/OptionStruct.h

    r7746 r7760  
    4242                int   NDims();
    4343                int*  Size();
    44                 void  Get(double* pvalue){_error_("An OptionCell object cannot return a double");};
    45                 void  Get(bool* pvalue){  _error_("An OptionCell object cannot return a bool");};
    46                 void  Get(char** pvalue){ _error_("An OptionCell object cannot return a string");};
     44                void  Get(double* pvalue){_error_("An OptionStruct object cannot return a double");};
     45                void  Get(bool* pvalue){  _error_("An OptionStruct object cannot return a bool");};
     46                void  Get(char** pvalue){ _error_("An OptionStruct object cannot return a string");};
     47                void  Get(double** pvalue,int *pnumel){ _error_("An OptionStruct object cannot return a double vec");};
    4748
    4849};
Note: See TracChangeset for help on using the changeset viewer.