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