| 1 | /*!\file VectorParam.c
|
|---|
| 2 | * \brief: implementation of the VectorParam 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 <stdio.h>
|
|---|
| 14 | #include <string.h>
|
|---|
| 15 | #include "../objects.h"
|
|---|
| 16 | #include "../../../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 17 | #include "../../../shared/shared.h"
|
|---|
| 18 | #include "../../../Container/Container.h"
|
|---|
| 19 | #include "../../../include/include.h"
|
|---|
| 20 | /*}}}*/
|
|---|
| 21 |
|
|---|
| 22 | /*VectorParam constructors and destructor*/
|
|---|
| 23 | /*FUNCTION VectorParam::VectorParam(){{{*/
|
|---|
| 24 | VectorParam::VectorParam(){
|
|---|
| 25 | return;
|
|---|
| 26 | }
|
|---|
| 27 | /*}}}*/
|
|---|
| 28 | /*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{*/
|
|---|
| 29 | VectorParam::VectorParam(int in_enum_type,Vector<IssmDouble>* in_value){
|
|---|
| 30 |
|
|---|
| 31 | enum_type=in_enum_type;
|
|---|
| 32 |
|
|---|
| 33 | value=NULL;
|
|---|
| 34 |
|
|---|
| 35 | if(in_value){
|
|---|
| 36 | value=in_value->Duplicate();
|
|---|
| 37 | in_value->Copy(value);
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | /*}}}*/
|
|---|
| 41 | /*FUNCTION VectorParam::~VectorParam(){{{*/
|
|---|
| 42 | VectorParam::~VectorParam(){
|
|---|
| 43 | xdelete(&value);
|
|---|
| 44 | }
|
|---|
| 45 | /*}}}*/
|
|---|
| 46 |
|
|---|
| 47 | /*Object virtual functions definitions:*/
|
|---|
| 48 | /*FUNCTION VectorParam::Echo {{{*/
|
|---|
| 49 | void VectorParam::Echo(void){
|
|---|
| 50 |
|
|---|
| 51 | _printLine_("VectorParam:");
|
|---|
| 52 | _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
|
|---|
| 53 |
|
|---|
| 54 | }
|
|---|
| 55 | /*}}}*/
|
|---|
| 56 | /*FUNCTION VectorParam::DeepEcho{{{*/
|
|---|
| 57 | void VectorParam::DeepEcho(void){
|
|---|
| 58 |
|
|---|
| 59 | int i;
|
|---|
| 60 | _printLine_("VectorParam:");
|
|---|
| 61 | _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
|
|---|
| 62 | value->Echo();
|
|---|
| 63 | }
|
|---|
| 64 | /*}}}*/
|
|---|
| 65 | /*FUNCTION VectorParam::Id{{{*/
|
|---|
| 66 | int VectorParam::Id(void){ return -1; }
|
|---|
| 67 | /*}}}*/
|
|---|
| 68 | /*FUNCTION VectorParam::ObjectEnum{{{*/
|
|---|
| 69 | int VectorParam::ObjectEnum(void){
|
|---|
| 70 |
|
|---|
| 71 | return VectorParamEnum;
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 | /*}}}*/
|
|---|
| 75 | /*FUNCTION VectorParam::copy{{{*/
|
|---|
| 76 | Object* VectorParam::copy() {
|
|---|
| 77 |
|
|---|
| 78 | return new VectorParam(this->enum_type,this->value);
|
|---|
| 79 |
|
|---|
| 80 | }
|
|---|
| 81 | /*}}}*/
|
|---|
| 82 |
|
|---|
| 83 | /*VectorParam virtual functions definitions: */
|
|---|
| 84 | /*FUNCTION VectorParam::GetParameterValue{{{*/
|
|---|
| 85 | void VectorParam::GetParameterValue(Vector<IssmDouble>** poutput){
|
|---|
| 86 | Vector<IssmDouble>* output=NULL;
|
|---|
| 87 |
|
|---|
| 88 | if(value){
|
|---|
| 89 | output=value->Duplicate();
|
|---|
| 90 | value->Copy(output);
|
|---|
| 91 | }
|
|---|
| 92 | *poutput=output;
|
|---|
| 93 | }
|
|---|
| 94 | /*}}}*/
|
|---|
| 95 | /*FUNCTION VectorParam::GetParameterName{{{*/
|
|---|
| 96 | void VectorParam::GetParameterName(char**pname){
|
|---|
| 97 | EnumToStringx(pname,this->enum_type);
|
|---|
| 98 | }
|
|---|
| 99 | /*}}}*/
|
|---|
| 100 | /*FUNCTION VectorParam::SetValue{{{*/
|
|---|
| 101 | void VectorParam::SetValue(Vector<IssmDouble>* vector){
|
|---|
| 102 |
|
|---|
| 103 | /*avoid leak: */
|
|---|
| 104 | xdelete(&value);
|
|---|
| 105 |
|
|---|
| 106 | /*copy: */
|
|---|
| 107 | value=vector->Duplicate();
|
|---|
| 108 | vector->Copy(value);
|
|---|
| 109 | }
|
|---|
| 110 | /*}}}*/
|
|---|
| 111 | /*FUNCTION VectorParam::UnitConversion{{{*/
|
|---|
| 112 | void VectorParam::UnitConversion(int direction_enum){
|
|---|
| 113 | /*do nothing, no unit conversion*/
|
|---|
| 114 | }
|
|---|
| 115 | /*}}}*/
|
|---|