| 1 | /*!\file DatasetInput.c
|
|---|
| 2 | * \brief: implementation of the datasetinput object
|
|---|
| 3 | */
|
|---|
| 4 | /*Headers{{{*/
|
|---|
| 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 <string.h>
|
|---|
| 13 | #include "../../classes.h"
|
|---|
| 14 | #include "../../../shared/Enum/Enum.h"
|
|---|
| 15 | #include "../../../shared/shared.h"
|
|---|
| 16 | /*}}}*/
|
|---|
| 17 |
|
|---|
| 18 | /*DatasetInput constructors and destructor*/
|
|---|
| 19 | /*FUNCTION DatasetInput::DatasetInput(){{{*/
|
|---|
| 20 | DatasetInput::DatasetInput(){
|
|---|
| 21 | enum_type=UNDEF;
|
|---|
| 22 | inputs=NULL;
|
|---|
| 23 | }
|
|---|
| 24 | /*}}}*/
|
|---|
| 25 | /*FUNCTION DatasetInput::DatasetInput(int in_enum_type) {{{*/
|
|---|
| 26 | DatasetInput::DatasetInput(int in_enum_type){
|
|---|
| 27 |
|
|---|
| 28 | enum_type = in_enum_type;
|
|---|
| 29 | inputs = new Inputs();
|
|---|
| 30 | }
|
|---|
| 31 | /*}}}*/
|
|---|
| 32 | /*FUNCTION DatasetInput::~DatasetInput(){{{*/
|
|---|
| 33 | DatasetInput::~DatasetInput(){
|
|---|
| 34 | delete inputs;
|
|---|
| 35 | }
|
|---|
| 36 | /*}}}*/
|
|---|
| 37 |
|
|---|
| 38 | /*Object virtual functions definitions:*/
|
|---|
| 39 | /*FUNCTION DatasetInput::Echo {{{*/
|
|---|
| 40 | void DatasetInput::Echo(void){
|
|---|
| 41 | this->DeepEcho();
|
|---|
| 42 | }
|
|---|
| 43 | /*}}}*/
|
|---|
| 44 | /*FUNCTION DatasetInput::DeepEcho{{{*/
|
|---|
| 45 | void DatasetInput::DeepEcho(void){
|
|---|
| 46 |
|
|---|
| 47 | _printLine_("DatasetInput:");
|
|---|
| 48 | _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
|
|---|
| 49 | _printLine_("---inputs: "); inputs->Echo();
|
|---|
| 50 | }
|
|---|
| 51 | /*}}}*/
|
|---|
| 52 | /*FUNCTION DatasetInput::Id{{{*/
|
|---|
| 53 | int DatasetInput::Id(void){ return -1; }
|
|---|
| 54 | /*}}}*/
|
|---|
| 55 | /*FUNCTION DatasetInput::ObjectEnum{{{*/
|
|---|
| 56 | int DatasetInput::ObjectEnum(void){
|
|---|
| 57 |
|
|---|
| 58 | return DatasetInputEnum;
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 | /*}}}*/
|
|---|
| 62 | /*FUNCTION DatasetInput::copy{{{*/
|
|---|
| 63 | Object* DatasetInput::copy() {
|
|---|
| 64 |
|
|---|
| 65 | DatasetInput* output=NULL;
|
|---|
| 66 |
|
|---|
| 67 | output = new DatasetInput();
|
|---|
| 68 | output->enum_type=this->enum_type;
|
|---|
| 69 | output->inputs=(Inputs*)this->inputs->Copy();
|
|---|
| 70 |
|
|---|
| 71 | return output;
|
|---|
| 72 | }
|
|---|
| 73 | /*}}}*/
|
|---|
| 74 | /*FUNCTION DatasetInput::SpawnTriaInput{{{*/
|
|---|
| 75 | Input* DatasetInput::SpawnTriaInput(int* indices){
|
|---|
| 76 |
|
|---|
| 77 | /*output*/
|
|---|
| 78 | DatasetInput* outinput=NULL;
|
|---|
| 79 |
|
|---|
| 80 | /*Create new Datasetinput (copy of current input)*/
|
|---|
| 81 | outinput=new DatasetInput();
|
|---|
| 82 | outinput->enum_type=this->enum_type;
|
|---|
| 83 | outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(indices));
|
|---|
| 84 |
|
|---|
| 85 | /*Assign output*/
|
|---|
| 86 | return outinput;
|
|---|
| 87 | }
|
|---|
| 88 | /*}}}*/
|
|---|
| 89 |
|
|---|
| 90 | /*DatasetInput management*/
|
|---|
| 91 | /*FUNCTION DatasetInput::InstanceEnum{{{*/
|
|---|
| 92 | int DatasetInput::InstanceEnum(void){
|
|---|
| 93 |
|
|---|
| 94 | return this->enum_type;
|
|---|
| 95 |
|
|---|
| 96 | }
|
|---|
| 97 | /*}}}*/
|
|---|
| 98 |
|
|---|
| 99 | /*Object functions*/
|
|---|
| 100 | /*FUNCTION DatasetInput::Configure{{{*/
|
|---|
| 101 | void DatasetInput::Configure(Parameters* parameters){
|
|---|
| 102 | /*do nothing: */
|
|---|
| 103 | }
|
|---|
| 104 | /*}}}*/
|
|---|
| 105 | /*FUNCTION DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){{{*/
|
|---|
| 106 | void DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){
|
|---|
| 107 |
|
|---|
| 108 | /*Get requested input within dataset*/
|
|---|
| 109 | if(index<0 || index > inputs->Size()-1) _error_("index requested (" << index << ") exceeds dataset size (" << inputs->Size() << ")");
|
|---|
| 110 | Input* input=dynamic_cast<Input*>(this->inputs->GetObjectByOffset(index));
|
|---|
| 111 |
|
|---|
| 112 | input->GetInputValue(pvalue,gauss);
|
|---|
| 113 | }
|
|---|
| 114 | /*}}}*/
|
|---|