Ice Sheet System Model  4.18
Code documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DoubleVecParam.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 /*DoubleVecParam constructors and destructor*/
19  return;
20 }
21 /*}}}*/
22 DoubleVecParam::DoubleVecParam(int in_enum_type,IssmDouble* in_values, int in_M){/*{{{*/
23 
24  enum_type=in_enum_type;
25  M=in_M;
26 
27  if(M){
28  values=xNew<IssmDouble>(M);
29  xMemCpy<IssmDouble>(values,in_values,M);
30  }
31  else values=NULL;
32 }
33 /*}}}*/
35  xDelete<IssmDouble>(values);
36  return;
37 }
38 /*}}}*/
39 
40 /*Object virtual functions definitions:*/
42 
43  return new DoubleVecParam(this->enum_type,this->values,this->M);
44 
45 }
46 /*}}}*/
47 void DoubleVecParam::DeepEcho(void){/*{{{*/
48  _printf_(setw(22)<<" DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" "<<"[");
49  for(int i=0;i<this->M;i++) _printf_(" "<< this->values[i]);
50  _printf_("\n");
51 }
52 /*}}}*/
53 void DoubleVecParam::Echo(void){/*{{{*/
54 
55  _printf_(setw(22)<<" DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n");
56 
57 }
58 /*}}}*/
59 int DoubleVecParam::Id(void){ return -1; }/*{{{*/
60 /*}}}*/
61 void DoubleVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
62 
64 
66  MARSHALLING(M);
68 
69 }
70 /*}}}*/
71 int DoubleVecParam::ObjectEnum(void){/*{{{*/
72 
73  return DoubleVecParamEnum;
74 
75 }
76 /*}}}*/
77 
78 /*DoubleVecParam virtual functions definitions: */
79 void DoubleVecParam::GetParameterValue(IssmDouble** poutput,int* pM){/*{{{*/
80 
81  IssmDouble* output=xNew<IssmDouble>(M);
82  xMemCpy<IssmDouble>(output,values,M);
83 
84  /*Assign output pointers:*/
85  if(pM) *pM=M;
86  *poutput=output;
87 }
88 /*}}}*/
89 void DoubleVecParam::GetParameterValue(IssmDouble** poutput,int* pM,int* pN){/*{{{*/
90 
91  IssmDouble* output=xNew<IssmDouble>(this->M);
92  xMemCpy<IssmDouble>(output,values,M);
93 
94  /*Assign output pointers:*/
95  if(pM) *pM=this->M;
96  if(pN) *pN=1;
97  *poutput=output;
98 }
99 /*}}}*/
100 void DoubleVecParam::GetParameterValue(int** pintarray,int* pM){/*{{{*/
101  _error_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
102 }
103 /*}}}*/
104 void DoubleVecParam::SetValue(IssmDouble* IssmDoublearray,int in_M){/*{{{*/
105 
106  /*avoid leak: */
107  xDelete<IssmDouble>(this->values);
108 
109  this->values=xNew<IssmDouble>(in_M);
110  xMemCpy<IssmDouble>(this->values,IssmDoublearray,in_M);
111 
112  this->M=in_M;
113 }
114 /*}}}*/
115 
116 /*DoubleVecParam specific routines:*/
117 void DoubleVecParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM){/*{{{*/
118 
119  /*Assign output pointers:*/
120  if(pM) *pM=M;
121  *pIssmDoublearray=values;
122 }
123 /*}}}*/
IssmDouble
double IssmDouble
Definition: types.h:37
Param
Definition: Param.h:21
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
DoubleVecParam::enum_type
int enum_type
Definition: DoubleVecParam.h:23
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
DoubleVecParam::DeepEcho
void DeepEcho()
Definition: DoubleVecParam.cpp:47
DoubleVecParam::copy
Param * copy()
Definition: DoubleVecParam.cpp:41
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
DoubleVecParam::M
int M
Definition: DoubleVecParam.h:25
DoubleVecParam::ObjectEnum
int ObjectEnum()
Definition: DoubleVecParam.cpp:71
DoubleVecParam::~DoubleVecParam
~DoubleVecParam()
Definition: DoubleVecParam.cpp:34
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
DoubleVecParam::values
IssmDouble * values
Definition: DoubleVecParam.h:24
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
DoubleVecParamEnum
@ DoubleVecParamEnum
Definition: EnumDefinitions.h:1048
DoubleVecParam::Echo
void Echo()
Definition: DoubleVecParam.cpp:53
DoubleVecParam::GetParameterValueByPointer
void GetParameterValueByPointer(IssmDouble **pIssmDoublearray, int *pM)
Definition: DoubleVecParam.cpp:117
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DoubleVecParam::DoubleVecParam
DoubleVecParam()
Definition: DoubleVecParam.cpp:18
DoubleVecParam::Id
int Id()
Definition: DoubleVecParam.cpp:59
DoubleVecParam::SetValue
void SetValue(bool boolean)
Definition: DoubleVecParam.h:60
shared.h
DoubleVecParam::GetParameterValue
void GetParameterValue(bool *pbool)
Definition: DoubleVecParam.h:42
DoubleVecParam::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: DoubleVecParam.cpp:61