| 1 | /*!\file IntMatParam.c
|
|---|
| 2 | * \brief: implementation of the IntMatParam 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 | /*IntMatParam constructors and destructor*/
|
|---|
| 18 | IntMatParam::IntMatParam(){/*{{{*/
|
|---|
| 19 | return;
|
|---|
| 20 | }
|
|---|
| 21 | /*}}}*/
|
|---|
| 22 | IntMatParam::IntMatParam(int in_enum_type,int* in_value, int in_M,int in_N){/*{{{*/
|
|---|
| 23 |
|
|---|
| 24 | enum_type=in_enum_type;
|
|---|
| 25 | M=in_M;
|
|---|
| 26 | N=in_N;
|
|---|
| 27 |
|
|---|
| 28 | value=xNew<int>(M*N);
|
|---|
| 29 | xMemCpy<int>(value,in_value,M*N);
|
|---|
| 30 | }
|
|---|
| 31 | /*}}}*/
|
|---|
| 32 | IntMatParam::~IntMatParam(){/*{{{*/
|
|---|
| 33 | xDelete<int>(value);
|
|---|
| 34 | return;
|
|---|
| 35 | }
|
|---|
| 36 | /*}}}*/
|
|---|
| 37 |
|
|---|
| 38 | /*Object virtual functions definitions:*/
|
|---|
| 39 | Param* IntMatParam::copy() {/*{{{*/
|
|---|
| 40 |
|
|---|
| 41 | return new IntMatParam(this->enum_type,this->value,this->M,this->N);
|
|---|
| 42 |
|
|---|
| 43 | }
|
|---|
| 44 | /*}}}*/
|
|---|
| 45 | void IntMatParam::DeepEcho(void){/*{{{*/
|
|---|
| 46 |
|
|---|
| 47 | int i,j;
|
|---|
| 48 |
|
|---|
| 49 | _printf_("IntMatParam:\n");
|
|---|
| 50 | _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
|
|---|
| 51 | _printf_(" matrix size: " << this->M << "x" << this->N << "\n");
|
|---|
| 52 | for(i=0;i<this->M;i++){
|
|---|
| 53 | for(j=0;j<this->N;j++){
|
|---|
| 54 | _printf_("(" << i << "," << j << ") " << *(this->value+N*i+j) << "\n");
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 | /*}}}*/
|
|---|
| 59 | void IntMatParam::Echo(void){/*{{{*/
|
|---|
| 60 |
|
|---|
| 61 | _printf_("IntMatParam:\n");
|
|---|
| 62 | _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
|
|---|
| 63 | _printf_(" matrix size: " << this->M << "x" << this->N << "\n");
|
|---|
| 64 |
|
|---|
| 65 | }
|
|---|
| 66 | /*}}}*/
|
|---|
| 67 | int IntMatParam::Id(void){ return -1; }/*{{{*/
|
|---|
| 68 | /*}}}*/
|
|---|
| 69 | void IntMatParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
|
|---|
| 70 |
|
|---|
| 71 | MARSHALLING_ENUM(IntMatParamEnum);
|
|---|
| 72 |
|
|---|
| 73 | MARSHALLING(enum_type);
|
|---|
| 74 | MARSHALLING(M);
|
|---|
| 75 | MARSHALLING(N);
|
|---|
| 76 | MARSHALLING_DYNAMIC(value,int,M*N);
|
|---|
| 77 | }
|
|---|
| 78 | /*}}}*/
|
|---|
| 79 | int IntMatParam::ObjectEnum(void){/*{{{*/
|
|---|
| 80 |
|
|---|
| 81 | return IntMatParamEnum;
|
|---|
| 82 |
|
|---|
| 83 | }
|
|---|
| 84 | /*}}}*/
|
|---|
| 85 |
|
|---|
| 86 | /*IntMatParam virtual functions definitions: */
|
|---|
| 87 | void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){/*{{{*/
|
|---|
| 88 | int* output=NULL;
|
|---|
| 89 |
|
|---|
| 90 | output=xNew<int>(M*N);
|
|---|
| 91 | xMemCpy<int>(output,value,M*N);
|
|---|
| 92 |
|
|---|
| 93 | /*Assign output pointers:*/
|
|---|
| 94 | if(pM) *pM=M;
|
|---|
| 95 | if(pN) *pN=N;
|
|---|
| 96 | *pintarray=output;
|
|---|
| 97 | }
|
|---|
| 98 | /*}}}*/
|
|---|
| 99 | void IntMatParam::SetValue(int* intarray,int in_M,int in_N){/*{{{*/
|
|---|
| 100 |
|
|---|
| 101 | /*avoid leak: */
|
|---|
| 102 | xDelete<int>(this->value);
|
|---|
| 103 |
|
|---|
| 104 | this->value=xNew<int>(in_M*in_N);
|
|---|
| 105 | xMemCpy<int>(this->value,intarray,in_M*in_N);
|
|---|
| 106 |
|
|---|
| 107 | this->M=in_M;
|
|---|
| 108 | this->N=in_N;
|
|---|
| 109 | }
|
|---|
| 110 | /*}}}*/
|
|---|