Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

inversesolver.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 07/14/2010
  9. @version $Id: inversesolver.cpp 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #include "inversesolver.h"
  12. namespace Lemma {
  13. std::ostream &operator<<(std::ostream &stream,
  14. const InverseSolver &ob) {
  15. stream << *(LemmaObject*)(&ob);
  16. return stream;
  17. }
  18. // ==================== LIFECYCLE =======================
  19. InverseSolver::InverseSolver(const std::string &name) :
  20. LemmaObject(name), ObservedData(NULL),
  21. PredictedData(NULL), ModelInstrument(NULL) {
  22. }
  23. InverseSolver::~InverseSolver() {
  24. if (NumberOfReferences != 0) throw DeleteObjectWithReferences(this);
  25. if (ObservedData != NULL) ObservedData->DetachFrom(this);
  26. if (PredictedData != NULL) {
  27. PredictedData->Delete();
  28. }
  29. if (ModelInstrument != NULL) ModelInstrument->DetachFrom(this);
  30. }
  31. // ==================== ACCESS =======================
  32. void InverseSolver::SetObservedData(Data* ObsData) {
  33. if (ObservedData != NULL) {
  34. ObservedData->DetachFrom(this);
  35. ObservedData = NULL;
  36. }
  37. if (PredictedData != NULL) {
  38. PredictedData->Delete();
  39. PredictedData = NULL;
  40. }
  41. ObsData->AttachTo(this);
  42. this->ObservedData = ObsData;
  43. // Obs and predicted data need to be aligned.
  44. PredictedData = ObservedData->Clone();
  45. //PredictedData->AttachTo(this);
  46. }
  47. void InverseSolver::SetInstrument(Instrument* inst) {
  48. if (ModelInstrument != NULL) {
  49. ModelInstrument->DetachFrom(this);
  50. }
  51. inst->AttachTo(this);
  52. this->ModelInstrument = inst;
  53. }
  54. Data* InverseSolver::GetPredictedData() {
  55. return PredictedData; //->ThrowPointer();
  56. }
  57. } // ----- end of Lemma name -----