Ice Sheet System Model  4.18
Code documentation
IntVecParam.cpp
Go to the documentation of this file.
1 
5 /*header files: */
6 /*{{{*/
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 "../classes.h"
14 #include "../../shared/shared.h"
15 /*}}}*/
16 
17 /*IntVecParam constructors and destructor*/
19  return;
20 }
21 /*}}}*/
22 IntVecParam::IntVecParam(int in_enum_type,int* in_values, int in_M){/*{{{*/
23 
24  enum_type=in_enum_type;
25  M=in_M;
26 
27  if(M){
28  values=xNew<int>(M);
29  xMemCpy<int>(values,in_values,M);
30  }
31  else values=NULL;
32 }
33 /*}}}*/
34 IntVecParam::IntVecParam(int in_enum_type,IssmDouble* in_values, int in_M){/*{{{*/
35 
36  enum_type=in_enum_type;
37  M=in_M;
38 
39  if(M){
40  values=xNew<int>(M);
41  for(int i=0;i<in_M;i++) values[i]=reCast<int>(in_values[i]);
42  }
43  else values=NULL;
44 }
45 /*}}}*/
47  xDelete<int>(values);
48  return;
49 }
50 /*}}}*/
51 
52 /*Object virtual functions definitions:*/
54 
55  return new IntVecParam(this->enum_type,this->values,this->M);
56 
57 }
58 /*}}}*/
59 void IntVecParam::DeepEcho(void){/*{{{*/
60  _printf_(setw(22)<<" IntVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" [");
61  for(int i=0;i<this->M;i++) _printf_(" "<<this->values[i]);
62  _printf_("]\n");
63 }
64 /*}}}*/
65 void IntVecParam::Echo(void){/*{{{*/
66 
67  this->DeepEcho();
68 }
69 /*}}}*/
70 int IntVecParam::Id(void){ return -1; }/*{{{*/
71 /*}}}*/
72 void IntVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
73 
75 
77  MARSHALLING(M);
78  if(M) {
80  }
81  else values=NULL;
82 
83 }
84 /*}}}*/
85 int IntVecParam::ObjectEnum(void){/*{{{*/
86 
87  return IntVecParamEnum;
88 
89 }
90 /*}}}*/
91 
92 /*IntVecParam virtual functions definitions: */
93 void IntVecParam::GetParameterValue(int** pintarray,int* pM){/*{{{*/
94  int* output=NULL;
95 
96  if(M){
97  output=xNew<int>(M);
98  xMemCpy<int>(output,values,M);
99  }
100 
101  /*Assign output pointers:*/
102  if(pM) *pM=M;
103  *pintarray=output;
104 }
105 /*}}}*/
106 void IntVecParam::SetValue(int* intarray,int in_M){/*{{{*/
107 
108  /*avoid leak: */
109  xDelete<int>(this->values);
110 
111  if(in_M){
112  this->values=xNew<int>(in_M);
113  xMemCpy<int>(this->values,intarray,in_M);
114  }
115  else this->values=NULL;
116 
117  this->M=in_M;
118 }
119 /*}}}*/
IssmDouble
double IssmDouble
Definition: types.h:37
Param
Definition: Param.h:21
IntVecParam::~IntVecParam
~IntVecParam()
Definition: IntVecParam.cpp:46
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
IntVecParamEnum
@ IntVecParamEnum
Definition: EnumDefinitions.h:1129
IntVecParam::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: IntVecParam.cpp:72
IntVecParam::M
int M
Definition: IntVecParam.h:25
IntVecParam::ObjectEnum
int ObjectEnum()
Definition: IntVecParam.cpp:85
IntVecParam::enum_type
int enum_type
Definition: IntVecParam.h:23
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
IntVecParam::GetParameterValue
void GetParameterValue(bool *pbool)
Definition: IntVecParam.h:43
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
IntVecParam::SetValue
void SetValue(bool boolean)
Definition: IntVecParam.h:61
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
IntVecParam::Echo
void Echo()
Definition: IntVecParam.cpp:65
IntVecParam::DeepEcho
void DeepEcho()
Definition: IntVecParam.cpp:59
IntVecParam::values
int * values
Definition: IntVecParam.h:24
IntVecParam::Id
int Id()
Definition: IntVecParam.cpp:70
IntVecParam::copy
Param * copy()
Definition: IntVecParam.cpp:53
IntVecParam::IntVecParam
IntVecParam()
Definition: IntVecParam.cpp:18