1 | /*!\file IntInput.c
|
---|
2 | * \brief: implementation of the IntInput object
|
---|
3 | */
|
---|
4 |
|
---|
5 | #ifdef HAVE_CONFIG_H
|
---|
6 | #include "config.h"
|
---|
7 | #else
|
---|
8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | #include "stdio.h"
|
---|
12 | #include "./IntInput.h"
|
---|
13 | #include <string.h>
|
---|
14 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
15 | #include "../shared/shared.h"
|
---|
16 | #include "../DataSet/DataSet.h"
|
---|
17 | #include "../include/typedefs.h"
|
---|
18 | #include "../include/types.h"
|
---|
19 | #include "../include/macros.h"
|
---|
20 |
|
---|
21 | /*Object constructors and destructor*/
|
---|
22 | /*FUNCTION IntInput::IntInput(){{{1*/
|
---|
23 | IntInput::IntInput(){
|
---|
24 | return;
|
---|
25 | }
|
---|
26 | /*}}}*/
|
---|
27 | /*FUNCTION IntInput::IntInput(double* values){{{1*/
|
---|
28 | IntInput::IntInput(int in_enum_type,IssmInt in_value){
|
---|
29 |
|
---|
30 | enum_type=in_enum_type;
|
---|
31 | value=in_value;
|
---|
32 | }
|
---|
33 | /*}}}*/
|
---|
34 | /*FUNCTION IntInput::~IntInput(){{{1*/
|
---|
35 | IntInput::~IntInput(){
|
---|
36 | return;
|
---|
37 | }
|
---|
38 | /*}}}*/
|
---|
39 |
|
---|
40 | /*Object management*/
|
---|
41 | /*FUNCTION IntInput::copy{{{1*/
|
---|
42 | Object* IntInput::copy() {
|
---|
43 |
|
---|
44 | return new IntInput(this->enum_type,this->value);
|
---|
45 |
|
---|
46 | }
|
---|
47 | /*}}}*/
|
---|
48 | /*FUNCTION IntInput::DeepEcho{{{1*/
|
---|
49 | void IntInput::DeepEcho(void){
|
---|
50 |
|
---|
51 | printf("IntInput:\n");
|
---|
52 | printf(" enum: %i\n",this->enum_type);
|
---|
53 | printf(" %i\n",this->value);
|
---|
54 | }
|
---|
55 | /*}}}*/
|
---|
56 | /*FUNCTION IntInput::Demarshall{{{1*/
|
---|
57 | void IntInput::Demarshall(char** pmarshalled_dataset){
|
---|
58 |
|
---|
59 | char* marshalled_dataset=NULL;
|
---|
60 | int i;
|
---|
61 |
|
---|
62 | /*recover marshalled_dataset: */
|
---|
63 | marshalled_dataset=*pmarshalled_dataset;
|
---|
64 |
|
---|
65 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
66 | *object data (thanks to DataSet::Demarshall):*/
|
---|
67 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
68 | memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
|
---|
69 |
|
---|
70 | /*return: */
|
---|
71 | *pmarshalled_dataset=marshalled_dataset;
|
---|
72 | return;
|
---|
73 | }
|
---|
74 | /*}}}*/
|
---|
75 | /*FUNCTION IntInput::Echo {{{1*/
|
---|
76 | void IntInput::Echo(void){
|
---|
77 | this->DeepEcho();
|
---|
78 | }
|
---|
79 | /*}}}*/
|
---|
80 | /*FUNCTION IntInput::Enum{{{1*/
|
---|
81 | int IntInput::Enum(void){
|
---|
82 |
|
---|
83 | return IntInputEnum;
|
---|
84 |
|
---|
85 | }
|
---|
86 | /*}}}*/
|
---|
87 | /*FUNCTION IntInput::EnumType{{{1*/
|
---|
88 | int IntInput::EnumType(void){
|
---|
89 |
|
---|
90 | return this->enum_type;
|
---|
91 |
|
---|
92 | }
|
---|
93 | /*}}}*/
|
---|
94 | /*FUNCTION IntInput::GetId{{{1*/
|
---|
95 | int IntInput::GetId(void){ return -1; }
|
---|
96 | /*}}}*/
|
---|
97 | /*FUNCTION IntInput::GetName{{{1*/
|
---|
98 | char* IntInput::GetName(void){
|
---|
99 | return "intinput";
|
---|
100 | }
|
---|
101 | /*}}}*/
|
---|
102 | /*FUNCTION IntInput::Marshall{{{1*/
|
---|
103 | void IntInput::Marshall(char** pmarshalled_dataset){
|
---|
104 |
|
---|
105 | char* marshalled_dataset=NULL;
|
---|
106 | int enum_type=0;
|
---|
107 |
|
---|
108 | /*recover marshalled_dataset: */
|
---|
109 | marshalled_dataset=*pmarshalled_dataset;
|
---|
110 |
|
---|
111 | /*get enum type of IntInput: */
|
---|
112 | enum_type=IntInputEnum;
|
---|
113 |
|
---|
114 | /*marshall enum: */
|
---|
115 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
116 |
|
---|
117 | /*marshall IntInput data: */
|
---|
118 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
119 | memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
|
---|
120 |
|
---|
121 | *pmarshalled_dataset=marshalled_dataset;
|
---|
122 | }
|
---|
123 | /*}}}*/
|
---|
124 | /*FUNCTION IntInput::MarshallSize{{{1*/
|
---|
125 | int IntInput::MarshallSize(){
|
---|
126 |
|
---|
127 | return sizeof(value)+
|
---|
128 | sizeof(enum_type)+
|
---|
129 | +sizeof(int); //sizeof(int) for enum type
|
---|
130 | }
|
---|
131 | /*}}}*/
|
---|
132 | /*FUNCTION IntInput::MyRank{{{1*/
|
---|
133 | int IntInput::MyRank(void){
|
---|
134 | extern int my_rank;
|
---|
135 | return my_rank;
|
---|
136 | }
|
---|
137 | /*}}}*/
|
---|
138 |
|
---|
139 | /*Object functions*/
|
---|
140 |
|
---|