[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] | 18 | IntVecParam::IntVecParam(){/*{{{*/
|
---|
[6165] | 19 | return;
|
---|
| 20 | }
|
---|
| 21 | /*}}}*/
|
---|
[18301] | 22 | IntVecParam::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] | 34 | IntVecParam::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] | 46 | IntVecParam::~IntVecParam(){/*{{{*/
|
---|
[12451] | 47 | xDelete<int>(values);
|
---|
[6165] | 48 | return;
|
---|
| 49 | }
|
---|
| 50 | /*}}}*/
|
---|
| 51 |
|
---|
| 52 | /*Object virtual functions definitions:*/
|
---|
[18301] | 53 | void IntVecParam::Echo(void){/*{{{*/
|
---|
[6165] | 54 |
|
---|
[15104] | 55 | _printf_("IntVecParam:\n");
|
---|
| 56 | _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
|
---|
[15100] | 57 | _printf_(" vector size: " << this->M << "\n");
|
---|
[6165] | 58 |
|
---|
| 59 | }
|
---|
| 60 | /*}}}*/
|
---|
[18301] | 61 | void IntVecParam::DeepEcho(void){/*{{{*/
|
---|
[6165] | 62 |
|
---|
| 63 | int i;
|
---|
[13622] | 64 |
|
---|
[15104] | 65 | _printf_("IntVecParam:\n");
|
---|
| 66 | _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
|
---|
[15100] | 67 | _printf_(" vector size: " << this->M << "\n");
|
---|
[6165] | 68 | for(i=0;i<this->M;i++){
|
---|
[15100] | 69 | _printf_(i << " " << this->values[i] << "\n");
|
---|
[6165] | 70 | }
|
---|
| 71 | }
|
---|
| 72 | /*}}}*/
|
---|
[20500] | 73 | int IntVecParam::Id(void){ return -1; }/*{{{*/
|
---|
[6165] | 74 | /*}}}*/
|
---|
[20500] | 75 | int IntVecParam::ObjectEnum(void){/*{{{*/
|
---|
[6165] | 76 |
|
---|
| 77 | return IntVecParamEnum;
|
---|
| 78 |
|
---|
| 79 | }
|
---|
| 80 | /*}}}*/
|
---|
[18301] | 81 | Object* IntVecParam::copy() {/*{{{*/
|
---|
[13622] | 82 |
|
---|
[6165] | 83 | return new IntVecParam(this->enum_type,this->values,this->M);
|
---|
| 84 |
|
---|
| 85 | }
|
---|
| 86 | /*}}}*/
|
---|
[20500] | 87 | void IntVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
|
---|
[6165] | 88 |
|
---|
[20500] | 89 | MARSHALLING_ENUM(IntVecParamEnum);
|
---|
| 90 |
|
---|
| 91 | MARSHALLING(enum_type);
|
---|
| 92 | MARSHALLING(M);
|
---|
| 93 | if(M) {
|
---|
| 94 | MARSHALLING_DYNAMIC(values,int,M);
|
---|
| 95 | }
|
---|
| 96 | else values=NULL;
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 | /*}}}*/
|
---|
| 100 |
|
---|
[6165] | 101 | /*IntVecParam virtual functions definitions: */
|
---|
[18301] | 102 | void IntVecParam::GetParameterValue(int** pintarray,int* pM){/*{{{*/
|
---|
[6165] | 103 | int* output=NULL;
|
---|
| 104 |
|
---|
[9111] | 105 | if(M){
|
---|
[12451] | 106 | output=xNew<int>(M);
|
---|
[12474] | 107 | xMemCpy<int>(output,values,M);
|
---|
[9111] | 108 | }
|
---|
[6165] | 109 |
|
---|
| 110 | /*Assign output pointers:*/
|
---|
| 111 | if(pM) *pM=M;
|
---|
| 112 | *pintarray=output;
|
---|
| 113 | }
|
---|
| 114 | /*}}}*/
|
---|
[18301] | 115 | void IntVecParam::SetValue(int* intarray,int in_M){/*{{{*/
|
---|
[6165] | 116 |
|
---|
| 117 | /*avoid leak: */
|
---|
[12451] | 118 | xDelete<int>(this->values);
|
---|
[6165] | 119 |
|
---|
[9111] | 120 | if(in_M){
|
---|
[12451] | 121 | this->values=xNew<int>(in_M);
|
---|
[12474] | 122 | xMemCpy<int>(this->values,intarray,in_M);
|
---|
[9111] | 123 | }
|
---|
| 124 | else this->values=NULL;
|
---|
[6165] | 125 |
|
---|
| 126 | this->M=in_M;
|
---|
| 127 | }
|
---|
| 128 | /*}}}*/
|
---|