source: issm/trunk/src/c/classes/Params/IntVecParam.cpp@ 25836

Last change on this file since 25836 was 25836, checked in by Mathieu Morlighem, 4 years ago

merged trunk-jpl and trunk for revision 25834

File size: 2.3 KB
Line 
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*/
18IntVecParam::IntVecParam(){/*{{{*/
19 return;
20}
21/*}}}*/
22IntVecParam::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/*}}}*/
34IntVecParam::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/*}}}*/
46IntVecParam::~IntVecParam(){/*{{{*/
47 xDelete<int>(values);
48 return;
49}
50/*}}}*/
51
52/*Object virtual functions definitions:*/
53Param* IntVecParam::copy() {/*{{{*/
54
55 return new IntVecParam(this->enum_type,this->values,this->M);
56
57}
58/*}}}*/
59void 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/*}}}*/
65void IntVecParam::Echo(void){/*{{{*/
66
67 this->DeepEcho();
68}
69/*}}}*/
70int IntVecParam::Id(void){ return -1; }/*{{{*/
71/*}}}*/
72void 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/*}}}*/
88int IntVecParam::ObjectEnum(void){/*{{{*/
89
90 return IntVecParamEnum;
91
92}
93/*}}}*/
94
95/*IntVecParam virtual functions definitions: */
96void 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/*}}}*/
109void 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/*}}}*/
Note: See TracBrowser for help on using the repository browser.