1 | /*!\file IntVecParam.c
|
---|
2 | * \brief: implementation of the IntVecParam object
|
---|
3 | */
|
---|
4 |
|
---|
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*/
|
---|
18 | IntVecParam::IntVecParam(){/*{{{*/
|
---|
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 | /*}}}*/
|
---|
46 | IntVecParam::~IntVecParam(){/*{{{*/
|
---|
47 | xDelete<int>(values);
|
---|
48 | return;
|
---|
49 | }
|
---|
50 | /*}}}*/
|
---|
51 |
|
---|
52 | /*Object virtual functions definitions:*/
|
---|
53 | Param* IntVecParam::copy() {/*{{{*/
|
---|
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 |
|
---|
74 | MARSHALLING_ENUM(IntVecParamEnum);
|
---|
75 |
|
---|
76 | MARSHALLING(enum_type);
|
---|
77 | MARSHALLING(M);
|
---|
78 | if(M) {
|
---|
79 | MARSHALLING_DYNAMIC(values,int,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 | /*}}}*/
|
---|