Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Private Attributes
StringArrayParam Class Reference

#include <StringArrayParam.h>

Inheritance diagram for StringArrayParam:
Param Object

Public Member Functions

 StringArrayParam ()
 
 StringArrayParam (int enum_type, char **values, int numstrings)
 
 ~StringArrayParam ()
 
Paramcopy ()
 
void DeepEcho ()
 
void Echo ()
 
int Id ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
int ObjectEnum ()
 
void GetParameterValue (bool *pbool)
 
void GetParameterValue (int *pinteger)
 
void GetParameterValue (int **pintarray, int *pM)
 
void GetParameterValue (int **pintarray, int *pM, int *pN)
 
void GetParameterValue (IssmDouble *pIssmDouble)
 
void GetParameterValue (IssmDouble *pdouble, IssmDouble time)
 
void GetParameterValue (char **pstring)
 
void GetParameterValue (char ***pstringarray, int *pM)
 
void GetParameterValue (IssmDouble **pIssmDoublearray, int *pM)
 
void GetParameterValue (IssmDouble **pIssmDoublearray, int *pM, int *pN)
 
void GetParameterValue (IssmDouble ***parray, int *pM, int **pmdims, int **pndims)
 
void GetParameterValue (Vector< IssmDouble > **pvec)
 
void GetParameterValue (Matrix< IssmDouble > **pmat)
 
void GetParameterValue (FILE **pfid)
 
void GetParameterValue (DataSet **pdataset)
 
int InstanceEnum ()
 
void SetEnum (int enum_in)
 
void SetValue (bool boolean)
 
void SetValue (int integer)
 
void SetValue (IssmDouble scalar)
 
void SetValue (char *string)
 
void SetValue (char **stringarray, int M)
 
void SetValue (IssmDouble *IssmDoublearray, int M)
 
void SetValue (IssmDouble *pIssmDoublearray, int M, int N)
 
void SetValue (int *intarray, int M)
 
void SetValue (int *pintarray, int M, int N)
 
void SetValue (Vector< IssmDouble > *vec)
 
void SetValue (Matrix< IssmDouble > *mat)
 
void SetValue (FILE *fid)
 
void SetValue (IssmDouble **array, int M, int *mdim_array, int *ndim_array)
 
- Public Member Functions inherited from Param
virtual ~Param ()
 
virtual void GetParameterValue (IssmDouble *pdouble, int row, IssmDouble time)
 
virtual void SetValue (DataSet *dataset)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 

Private Attributes

int enum_type
 
char ** value
 
int numstrings
 

Detailed Description

Definition at line 20 of file StringArrayParam.h.

Constructor & Destructor Documentation

◆ StringArrayParam() [1/2]

StringArrayParam::StringArrayParam ( )

Definition at line 18 of file StringArrayParam.cpp.

18  {/*{{{*/
19  return;
20 }

◆ StringArrayParam() [2/2]

StringArrayParam::StringArrayParam ( int  enum_type,
char **  values,
int  numstrings 
)

Definition at line 22 of file StringArrayParam.cpp.

22  {/*{{{*/
23 
24  this->enum_type=in_enum_type;
25  this->numstrings=in_numstrings;
26 
27  if(numstrings){
28  this->value=xNew<char*>(numstrings);
29  for(int i=0;i<numstrings;i++){
30  int size=strlen(in_values[i])+1;
31  char* string=xNew<char>(size);
32  xMemCpy<char>(string,in_values[i],size);
33  this->value[i]=string;
34  }
35  }
36  else{
37  this->value=NULL;
38  }
39 
40 }

◆ ~StringArrayParam()

StringArrayParam::~StringArrayParam ( )

Definition at line 42 of file StringArrayParam.cpp.

42  {/*{{{*/
43 
44  int i;
45 
46  char* string=NULL;
47  for(i=0;i<this->numstrings;i++){
48  string=value[i];
49  xDelete<char>(string);
50  }
51  xDelete<char*>(value);
52 }

Member Function Documentation

◆ copy()

Param * StringArrayParam::copy ( void  )
virtual

Implements Param.

Definition at line 56 of file StringArrayParam.cpp.

56  {/*{{{*/
57 
58  return new StringArrayParam(this->enum_type,this->value,this->numstrings);
59 
60 }

◆ DeepEcho()

void StringArrayParam::DeepEcho ( void  )
virtual

Implements Param.

Definition at line 62 of file StringArrayParam.cpp.

62  {/*{{{*/
63 
64  _printf_(setw(22)<<" StringArrayParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" {");
65  for(int i=0;i<this->numstrings;i++) _printf_(" '"<<this->value[i]<<"'");
66  _printf_("}\n");
67 }

◆ Echo()

void StringArrayParam::Echo ( void  )
virtual

Implements Param.

Definition at line 69 of file StringArrayParam.cpp.

69  {/*{{{*/
70  this->DeepEcho();
71 }

◆ Id()

int StringArrayParam::Id ( void  )
virtual

Implements Object.

Definition at line 73 of file StringArrayParam.cpp.

73 { return -1; }/*{{{*/

◆ Marshall()

void StringArrayParam::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
virtual

Implements Param.

Definition at line 75 of file StringArrayParam.cpp.

75  { /*{{{*/
76 
77  int* sizes=NULL;
78 
79  if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){
80  if(numstrings)sizes=xNew<int>(numstrings);
81  for(int i=0;i<numstrings;i++)sizes[i]=strlen(value[i])+1;
82  }
83 
85 
88 
89  if(numstrings){
91  if(marshall_direction==MARSHALLING_BACKWARD) value=xNew<char*>(numstrings);
92  for(int i=0;i<numstrings;i++)MARSHALLING_DYNAMIC(value[i],char,sizes[i]);
93  }
94  else value=NULL;
95 
96  //cleanup sizes array
97  if(sizes) xDelete<int>(sizes);
98 
99 }

◆ ObjectEnum()

int StringArrayParam::ObjectEnum ( void  )
virtual

Implements Param.

Definition at line 101 of file StringArrayParam.cpp.

101  {/*{{{*/
102 
103  return StringArrayParamEnum;
104 
105 }

◆ GetParameterValue() [1/15]

void StringArrayParam::GetParameterValue ( bool *  pbool)
inlinevirtual

Implements Param.

Definition at line 42 of file StringArrayParam.h.

42 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}

◆ GetParameterValue() [2/15]

void StringArrayParam::GetParameterValue ( int *  pinteger)
inlinevirtual

Implements Param.

Definition at line 43 of file StringArrayParam.h.

43 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}

◆ GetParameterValue() [3/15]

void StringArrayParam::GetParameterValue ( int **  pintarray,
int *  pM 
)
inlinevirtual

Implements Param.

Definition at line 44 of file StringArrayParam.h.

44 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return an array of integers");}

◆ GetParameterValue() [4/15]

void StringArrayParam::GetParameterValue ( int **  pintarray,
int *  pM,
int *  pN 
)
inlinevirtual

Implements Param.

Definition at line 45 of file StringArrayParam.h.

45 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return an array of integers");}

◆ GetParameterValue() [5/15]

void StringArrayParam::GetParameterValue ( IssmDouble pIssmDouble)
inlinevirtual

Implements Param.

Definition at line 46 of file StringArrayParam.h.

46 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");}

◆ GetParameterValue() [6/15]

void StringArrayParam::GetParameterValue ( IssmDouble pdouble,
IssmDouble  time 
)
inlinevirtual

Implements Param.

Definition at line 47 of file StringArrayParam.h.

47 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");}

◆ GetParameterValue() [7/15]

void StringArrayParam::GetParameterValue ( char **  pstring)
inlinevirtual

Implements Param.

Definition at line 48 of file StringArrayParam.h.

48 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");}

◆ GetParameterValue() [8/15]

void StringArrayParam::GetParameterValue ( char ***  pstringarray,
int *  pM 
)
virtual

Implements Param.

Definition at line 109 of file StringArrayParam.cpp.

109  {/*{{{*/
110 
111  int i;
112  char** outstrings=NULL;
113  int M;
114  char* string=NULL;
115  char* string2=NULL;
116  int stringsize;
117 
118  M=this->numstrings;
119  if(this->numstrings){
120  outstrings=xNew<char*>(this->numstrings);
121 
122  for(i=0;i<this->numstrings;i++){
123  string=this->value[i];
124  stringsize=strlen(string)+1;
125 
126  string2=xNew<char>(stringsize);
127  xMemCpy<char>(string2,string,stringsize);
128 
129  outstrings[i]=string2;
130  }
131  }
132  else outstrings=NULL;
133 
134  /*Assign output pointers:*/
135  if(pM) *pM=M;
136  *pstringarray=outstrings;
137 }

◆ GetParameterValue() [9/15]

void StringArrayParam::GetParameterValue ( IssmDouble **  pIssmDoublearray,
int *  pM 
)
inlinevirtual

Implements Param.

Definition at line 50 of file StringArrayParam.h.

50 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}

◆ GetParameterValue() [10/15]

void StringArrayParam::GetParameterValue ( IssmDouble **  pIssmDoublearray,
int *  pM,
int *  pN 
)
inlinevirtual

Implements Param.

Definition at line 51 of file StringArrayParam.h.

51 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble array");}

◆ GetParameterValue() [11/15]

void StringArrayParam::GetParameterValue ( IssmDouble ***  parray,
int *  pM,
int **  pmdims,
int **  pndims 
)
inlinevirtual

Implements Param.

Definition at line 52 of file StringArrayParam.h.

52 {_error_("Vec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}

◆ GetParameterValue() [12/15]

void StringArrayParam::GetParameterValue ( Vector< IssmDouble > **  pvec)
inlinevirtual

Implements Param.

Definition at line 53 of file StringArrayParam.h.

53 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}

◆ GetParameterValue() [13/15]

void StringArrayParam::GetParameterValue ( Matrix< IssmDouble > **  pmat)
inlinevirtual

Implements Param.

Definition at line 54 of file StringArrayParam.h.

54 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}

◆ GetParameterValue() [14/15]

void StringArrayParam::GetParameterValue ( FILE **  pfid)
inlinevirtual

Implements Param.

Definition at line 55 of file StringArrayParam.h.

55 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}

◆ GetParameterValue() [15/15]

void StringArrayParam::GetParameterValue ( DataSet **  pdataset)
inlinevirtual

Implements Param.

Definition at line 56 of file StringArrayParam.h.

56 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}

◆ InstanceEnum()

int StringArrayParam::InstanceEnum ( )
inlinevirtual

Implements Param.

Definition at line 57 of file StringArrayParam.h.

57 {return enum_type;}

◆ SetEnum()

void StringArrayParam::SetEnum ( int  enum_in)
inlinevirtual

Implements Param.

Definition at line 59 of file StringArrayParam.h.

59 {this->enum_type = enum_in;};

◆ SetValue() [1/13]

void StringArrayParam::SetValue ( bool  boolean)
inlinevirtual

Implements Param.

Definition at line 60 of file StringArrayParam.h.

60 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}

◆ SetValue() [2/13]

void StringArrayParam::SetValue ( int  integer)
inlinevirtual

Implements Param.

Definition at line 61 of file StringArrayParam.h.

61 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

◆ SetValue() [3/13]

void StringArrayParam::SetValue ( IssmDouble  scalar)
inlinevirtual

Implements Param.

Definition at line 62 of file StringArrayParam.h.

62 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a scalar");}

◆ SetValue() [4/13]

void StringArrayParam::SetValue ( char *  string)
inlinevirtual

Implements Param.

Definition at line 63 of file StringArrayParam.h.

63 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}

◆ SetValue() [5/13]

void StringArrayParam::SetValue ( char **  stringarray,
int  M 
)
virtual

Implements Param.

Definition at line 139 of file StringArrayParam.cpp.

139  {/*{{{*/
140 
141  int i;
142  char *string = NULL;
143  char *string2 = NULL;
144  int stringsize;
145 
146  /*first, avoid leak: */
147  for(i=0;i<this->numstrings;i++){
148  string=this->value[i];
149  xDelete<char>(string);
150  }
151  xDelete<char*>(this->value);
152 
153  /*copy: */
154  this->numstrings=M;
155  this->value=xNew<char*>(this->numstrings);
156  for(i=0;i<this->numstrings;i++){
157  string=stringarray[i];
158  stringsize=strlen(string)+1;
159 
160  string2=xNew<char>(stringsize);
161  xMemCpy<char>(string2,string,stringsize);
162 
163  this->value[i]=string2;
164  }
165 }

◆ SetValue() [6/13]

void StringArrayParam::SetValue ( IssmDouble IssmDoublearray,
int  M 
)
inlinevirtual

Implements Param.

Definition at line 65 of file StringArrayParam.h.

65 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}

◆ SetValue() [7/13]

void StringArrayParam::SetValue ( IssmDouble pIssmDoublearray,
int  M,
int  N 
)
inlinevirtual

Implements Param.

Definition at line 66 of file StringArrayParam.h.

66 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble array");}

◆ SetValue() [8/13]

void StringArrayParam::SetValue ( int *  intarray,
int  M 
)
inlinevirtual

Implements Param.

Definition at line 67 of file StringArrayParam.h.

67 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a int array");}

◆ SetValue() [9/13]

void StringArrayParam::SetValue ( int *  pintarray,
int  M,
int  N 
)
inlinevirtual

Implements Param.

Definition at line 68 of file StringArrayParam.h.

68 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a int array");}

◆ SetValue() [10/13]

void StringArrayParam::SetValue ( Vector< IssmDouble > *  vec)
inlinevirtual

Implements Param.

Definition at line 69 of file StringArrayParam.h.

69 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a Vec");}

◆ SetValue() [11/13]

void StringArrayParam::SetValue ( Matrix< IssmDouble > *  mat)
inlinevirtual

Implements Param.

Definition at line 70 of file StringArrayParam.h.

70 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a Mat");}

◆ SetValue() [12/13]

void StringArrayParam::SetValue ( FILE *  fid)
inlinevirtual

Implements Param.

Definition at line 71 of file StringArrayParam.h.

71 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}

◆ SetValue() [13/13]

void StringArrayParam::SetValue ( IssmDouble **  array,
int  M,
int *  mdim_array,
int *  ndim_array 
)
inlinevirtual

Implements Param.

Definition at line 72 of file StringArrayParam.h.

72 {_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}

Field Documentation

◆ enum_type

int StringArrayParam::enum_type
private

Definition at line 23 of file StringArrayParam.h.

◆ value

char** StringArrayParam::value
private

Definition at line 24 of file StringArrayParam.h.

◆ numstrings

int StringArrayParam::numstrings
private

Definition at line 25 of file StringArrayParam.h.


The documentation for this class was generated from the following files:
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
MARSHALLING_SIZE
@ MARSHALLING_SIZE
Definition: Marshalling.h:11
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
StringArrayParam::value
char ** value
Definition: StringArrayParam.h:24
StringArrayParam::DeepEcho
void DeepEcho()
Definition: StringArrayParam.cpp:62
StringArrayParam::enum_type
int enum_type
Definition: StringArrayParam.h:23
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
StringArrayParam::numstrings
int numstrings
Definition: StringArrayParam.h:25
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
MARSHALLING_BACKWARD
@ MARSHALLING_BACKWARD
Definition: Marshalling.h:10
StringArrayParamEnum
@ StringArrayParamEnum
Definition: EnumDefinitions.h:1290
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
MARSHALLING_FORWARD
@ MARSHALLING_FORWARD
Definition: Marshalling.h:9
StringArrayParam::StringArrayParam
StringArrayParam()
Definition: StringArrayParam.cpp:18