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
RevLine 
[6165]1/*!\file IntVecParam.c
2 * \brief: implementation of the IntVecParam object
3 */
4
5/*header files: */
[12365]6/*{{{*/
[6165]7#ifdef HAVE_CONFIG_H
[9320]8 #include <config.h>
[6165]9#else
10#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11#endif
12
[15012]13#include "../classes.h"
14#include "../../shared/shared.h"
[6165]15/*}}}*/
16
17/*IntVecParam constructors and destructor*/
[18301]18IntVecParam::IntVecParam(){/*{{{*/
[6165]19 return;
20}
21/*}}}*/
[18301]22IntVecParam::IntVecParam(int in_enum_type,int* in_values, int in_M){/*{{{*/
[6165]23
24 enum_type=in_enum_type;
25 M=in_M;
26
[9111]27 if(M){
[12451]28 values=xNew<int>(M);
[12474]29 xMemCpy<int>(values,in_values,M);
[9111]30 }
31 else values=NULL;
[6165]32}
33/*}}}*/
[18301]34IntVecParam::IntVecParam(int in_enum_type,IssmDouble* in_values, int in_M){/*{{{*/
[6213]35
36 enum_type=in_enum_type;
37 M=in_M;
38
[9111]39 if(M){
[12451]40 values=xNew<int>(M);
[12559]41 for(int i=0;i<in_M;i++) values[i]=reCast<int>(in_values[i]);
[9111]42 }
43 else values=NULL;
[6213]44}
45/*}}}*/
[18301]46IntVecParam::~IntVecParam(){/*{{{*/
[12451]47 xDelete<int>(values);
[6165]48 return;
49}
50/*}}}*/
51
52/*Object virtual functions definitions:*/
[21341]53Param* IntVecParam::copy() {/*{{{*/
[6165]54
[21341]55 return new IntVecParam(this->enum_type,this->values,this->M);
[6165]56
57}
58/*}}}*/
[18301]59void IntVecParam::DeepEcho(void){/*{{{*/
[22758]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");
[6165]63}
64/*}}}*/
[21341]65void IntVecParam::Echo(void){/*{{{*/
[6165]66
[22758]67 this->DeepEcho();
[6165]68}
69/*}}}*/
[21341]70int IntVecParam::Id(void){ return -1; }/*{{{*/
[6165]71/*}}}*/
[25836]72void IntVecParam::Marshall(MarshallHandle* marshallhandle){ /*{{{*/
[6165]73
[25836]74 int object_enum = IntVecParamEnum;
75 marshallhandle->call(object_enum);
[20500]76
[25836]77 marshallhandle->call(this->enum_type);
78 marshallhandle->call(this->M);
79 if(M){
80 marshallhandle->call(this->values,M);
[20500]81 }
[25836]82 else{
83 this->values=NULL;
84 }
[20500]85
86}
87/*}}}*/
[21341]88int IntVecParam::ObjectEnum(void){/*{{{*/
[20500]89
[21341]90 return IntVecParamEnum;
91
92}
93/*}}}*/
94
[6165]95/*IntVecParam virtual functions definitions: */
[18301]96void IntVecParam::GetParameterValue(int** pintarray,int* pM){/*{{{*/
[6165]97 int* output=NULL;
98
[9111]99 if(M){
[12451]100 output=xNew<int>(M);
[12474]101 xMemCpy<int>(output,values,M);
[9111]102 }
[6165]103
104 /*Assign output pointers:*/
105 if(pM) *pM=M;
106 *pintarray=output;
107}
108/*}}}*/
[18301]109void IntVecParam::SetValue(int* intarray,int in_M){/*{{{*/
[6165]110
111 /*avoid leak: */
[12451]112 xDelete<int>(this->values);
[6165]113
[9111]114 if(in_M){
[12451]115 this->values=xNew<int>(in_M);
[12474]116 xMemCpy<int>(this->values,intarray,in_M);
[9111]117 }
118 else this->values=NULL;
[6165]119
120 this->M=in_M;
121}
122/*}}}*/
Note: See TracBrowser for help on using the repository browser.