source: issm/trunk-jpl/src/c/classes/objects/Params/VectorParam.cpp@ 13216

Last change on this file since 13216 was 13216, checked in by Eric.Larour, 13 years ago

NEW: large change to the code, to adapt to ADOLC requirements.

This change relates to the introduction of template classes and functions for the
Option.h abstract class. This is needed, because we want to make the Matlab
API independent from the libCore objects, which are dependent on the IssmDouble*
ADOLC type (adouble), when the Matlab API is dependent on the IssmPDouble* type (double).

To make them independent, we need to be able to specify at run time Options, Matrix and
Vector objects that hold either IssmDouble or IssmPDouble objects. The only way to do
that is through the use of templated classes for Option.h, Matrix and Vector.

The change gets rid of a lot of useless code (especially in the classes/objects/Options
directory), by introducing template versions of the same code.

The bulk of the changes to src/modules and src/mex modules is to adapt to this
new runtime declaration of templated Matrix, Vector and Option objects.

File size: 2.6 KB
Line 
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(){{{*/
24VectorParam::VectorParam(){
25 return;
26}
27/*}}}*/
28/*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{*/
29VectorParam::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(){{{*/
42VectorParam::~VectorParam(){
43 xdelete(&value);
44}
45/*}}}*/
46
47/*Object virtual functions definitions:*/
48/*FUNCTION VectorParam::Echo {{{*/
49void VectorParam::Echo(void){
50
51 _printLine_("VectorParam:");
52 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
53
54}
55/*}}}*/
56/*FUNCTION VectorParam::DeepEcho{{{*/
57void 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{{{*/
66int VectorParam::Id(void){ return -1; }
67/*}}}*/
68/*FUNCTION VectorParam::MyRank{{{*/
69int VectorParam::MyRank(void){
70 extern int my_rank;
71 return my_rank;
72}
73/*}}}*/
74/*FUNCTION VectorParam::ObjectEnum{{{*/
75int VectorParam::ObjectEnum(void){
76
77 return VectorParamEnum;
78
79}
80/*}}}*/
81/*FUNCTION VectorParam::copy{{{*/
82Object* VectorParam::copy() {
83
84 return new VectorParam(this->enum_type,this->value);
85
86}
87/*}}}*/
88
89/*VectorParam virtual functions definitions: */
90/*FUNCTION VectorParam::GetParameterValue{{{*/
91void VectorParam::GetParameterValue(Vector<IssmDouble>** poutput){
92 Vector<IssmDouble>* output=NULL;
93
94 if(value){
95 output=value->Duplicate();
96 value->Copy(output);
97 }
98 *poutput=output;
99}
100/*}}}*/
101/*FUNCTION VectorParam::GetParameterName{{{*/
102void VectorParam::GetParameterName(char**pname){
103 EnumToStringx(pname,this->enum_type);
104}
105/*}}}*/
106/*FUNCTION VectorParam::SetValue{{{*/
107void VectorParam::SetValue(Vector<IssmDouble>* vector){
108
109 /*avoid leak: */
110 xdelete(&value);
111
112 /*copy: */
113 value=vector->Duplicate();
114 vector->Copy(value);
115}
116/*}}}*/
117/*FUNCTION VectorParam::UnitConversion{{{*/
118void VectorParam::UnitConversion(int direction_enum){
119 /*do nothing, no unit conversion*/
120}
121/*}}}*/
Note: See TracBrowser for help on using the repository browser.