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

Last change on this file since 16560 was 16560, checked in by Mathieu Morlighem, 11 years ago

merged trunk-jpl and trunk for revision 16554

File size: 2.7 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*/
[12365]18/*FUNCTION IntVecParam::IntVecParam(){{{*/
[6165]19IntVecParam::IntVecParam(){
20 return;
21}
22/*}}}*/
[12365]23/*FUNCTION IntVecParam::IntVecParam(int enum_type,int* values,int M){{{*/
[6165]24IntVecParam::IntVecParam(int in_enum_type,int* in_values, int in_M){
25
26 enum_type=in_enum_type;
27 M=in_M;
28
[9111]29 if(M){
[12451]30 values=xNew<int>(M);
[12474]31 xMemCpy<int>(values,in_values,M);
[9111]32 }
33 else values=NULL;
[6165]34}
35/*}}}*/
[12474]36/*FUNCTION IntVecParam::IntVecParam(int enum_type,IssmDouble* values,int M){{{*/
37IntVecParam::IntVecParam(int in_enum_type,IssmDouble* in_values, int in_M){
[6213]38
39 enum_type=in_enum_type;
40 M=in_M;
41
[9111]42 if(M){
[12451]43 values=xNew<int>(M);
[12559]44 for(int i=0;i<in_M;i++) values[i]=reCast<int>(in_values[i]);
[9111]45 }
46 else values=NULL;
[6213]47}
48/*}}}*/
[12365]49/*FUNCTION IntVecParam::~IntVecParam(){{{*/
[6165]50IntVecParam::~IntVecParam(){
[12451]51 xDelete<int>(values);
[6165]52 return;
53}
54/*}}}*/
55
56/*Object virtual functions definitions:*/
[12365]57/*FUNCTION IntVecParam::Echo {{{*/
[6165]58void IntVecParam::Echo(void){
59
[15104]60 _printf_("IntVecParam:\n");
61 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
[15100]62 _printf_(" vector size: " << this->M << "\n");
[6165]63
64}
65/*}}}*/
[12365]66/*FUNCTION IntVecParam::DeepEcho{{{*/
[6165]67void IntVecParam::DeepEcho(void){
68
69 int i;
[13622]70
[15104]71 _printf_("IntVecParam:\n");
72 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
[15100]73 _printf_(" vector size: " << this->M << "\n");
[6165]74 for(i=0;i<this->M;i++){
[15100]75 _printf_(i << " " << this->values[i] << "\n");
[6165]76 }
77}
78/*}}}*/
[12365]79/*FUNCTION IntVecParam::Id{{{*/
[6165]80int IntVecParam::Id(void){ return -1; }
81/*}}}*/
[12365]82/*FUNCTION IntVecParam::ObjectEnum{{{*/
[9883]83int IntVecParam::ObjectEnum(void){
[6165]84
85 return IntVecParamEnum;
86
87}
88/*}}}*/
[12365]89/*FUNCTION IntVecParam::copy{{{*/
[6165]90Object* IntVecParam::copy() {
[13622]91
[6165]92 return new IntVecParam(this->enum_type,this->values,this->M);
93
94}
95/*}}}*/
96
97/*IntVecParam virtual functions definitions: */
[12365]98/*FUNCTION IntVecParam::GetParameterValue{{{*/
[6165]99void IntVecParam::GetParameterValue(int** pintarray,int* pM){
100 int* output=NULL;
101
[9111]102 if(M){
[12451]103 output=xNew<int>(M);
[12474]104 xMemCpy<int>(output,values,M);
[9111]105 }
[6165]106
107 /*Assign output pointers:*/
108 if(pM) *pM=M;
109 *pintarray=output;
110}
111/*}}}*/
[12365]112/*FUNCTION IntVecParam::SetValue{{{*/
[6165]113void IntVecParam::SetValue(int* intarray,int in_M){
114
115 /*avoid leak: */
[12451]116 xDelete<int>(this->values);
[6165]117
[9111]118 if(in_M){
[12451]119 this->values=xNew<int>(in_M);
[12474]120 xMemCpy<int>(this->values,intarray,in_M);
[9111]121 }
122 else this->values=NULL;
[6165]123
124 this->M=in_M;
125}
126/*}}}*/
Note: See TracBrowser for help on using the repository browser.