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(MarshallHandle* marshallhandle){ /*{{{*/
|
---|
73 |
|
---|
74 | int object_enum = IntVecParamEnum;
|
---|
75 | marshallhandle->call(object_enum);
|
---|
76 |
|
---|
77 | marshallhandle->call(this->enum_type);
|
---|
78 | marshallhandle->call(this->M);
|
---|
79 | if(M){
|
---|
80 | marshallhandle->call(this->values,M);
|
---|
81 | }
|
---|
82 | else{
|
---|
83 | this->values=NULL;
|
---|
84 | }
|
---|
85 |
|
---|
86 | }
|
---|
87 | /*}}}*/
|
---|
88 | int IntVecParam::ObjectEnum(void){/*{{{*/
|
---|
89 |
|
---|
90 | return IntVecParamEnum;
|
---|
91 |
|
---|
92 | }
|
---|
93 | /*}}}*/
|
---|
94 |
|
---|
95 | /*IntVecParam virtual functions definitions: */
|
---|
96 | void IntVecParam::GetParameterValue(int** pintarray,int* pM){/*{{{*/
|
---|
97 | int* output=NULL;
|
---|
98 |
|
---|
99 | if(M){
|
---|
100 | output=xNew<int>(M);
|
---|
101 | xMemCpy<int>(output,values,M);
|
---|
102 | }
|
---|
103 |
|
---|
104 | /*Assign output pointers:*/
|
---|
105 | if(pM) *pM=M;
|
---|
106 | *pintarray=output;
|
---|
107 | }
|
---|
108 | /*}}}*/
|
---|
109 | void IntVecParam::SetValue(int* intarray,int in_M){/*{{{*/
|
---|
110 |
|
---|
111 | /*avoid leak: */
|
---|
112 | xDelete<int>(this->values);
|
---|
113 |
|
---|
114 | if(in_M){
|
---|
115 | this->values=xNew<int>(in_M);
|
---|
116 | xMemCpy<int>(this->values,intarray,in_M);
|
---|
117 | }
|
---|
118 | else this->values=NULL;
|
---|
119 |
|
---|
120 | this->M=in_M;
|
---|
121 | }
|
---|
122 | /*}}}*/
|
---|