Lemma is an Electromagnetics API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DCIPElectrode.cpp 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 11/10/2014 10:53:53 AM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@xri-geo.com
  14. * @copyright Copyright (c) 2014, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2014, Trevor Irons
  16. */
  17. #include "DCIPElectrode.h"
  18. namespace Lemma {
  19. // ==================== FRIEND METHODS =====================
  20. std::ostream &operator << (std::ostream &stream, const DCIPElectrode &ob) {
  21. stream << ob.Serialize() << "\n";
  22. return stream;
  23. }
  24. // ==================== LIFECYCLE =======================
  25. //--------------------------------------------------------------------------------------
  26. // Class: DCIPElectrode
  27. // Method: DCIPElectrode
  28. // Description: constructor (locked)
  29. //--------------------------------------------------------------------------------------
  30. DCIPElectrode::DCIPElectrode (const ctor_key& key) :
  31. LemmaObject(key), Node_ID(-1), Label(std::string("None")) {
  32. } // ----- end of method DCIPElectrode::DCIPElectrode (constructor) -----
  33. //--------------------------------------------------------------------------------------
  34. // Class: DCIPElectrode
  35. // Method: DCIPElectrode
  36. // Description: DeSerializing constructor (locked)
  37. //--------------------------------------------------------------------------------------
  38. DCIPElectrode::DCIPElectrode (const YAML::Node& node, const ctor_key& key) : LemmaObject(node, key) {
  39. if (node.Tag() != DCIPElectrode::CName) {
  40. throw std::runtime_error("In DCIPElectrode(node), node is of wrong type");
  41. }
  42. this->Location = node["Location"].as<Vector3r>();
  43. this->Node_ID = node["Node_ID"].as<int>();
  44. this->Label = node["Label"].as<std::string>();
  45. } // ----- end of method DCIPElectrode::DCIPElectrode (constructor) -----
  46. //--------------------------------------------------------------------------------------
  47. // Class: DCIPElectrode
  48. // Method: New()
  49. // Description: public constructor
  50. //--------------------------------------------------------------------------------------
  51. std::shared_ptr<DCIPElectrode> DCIPElectrode::NewSP() {
  52. return std::make_shared<DCIPElectrode>( ctor_key() );
  53. }
  54. //--------------------------------------------------------------------------------------
  55. // Class: DCIPElectrode
  56. // Method: ~DCIPElectrode
  57. // Description: destructor (protected)
  58. //--------------------------------------------------------------------------------------
  59. DCIPElectrode::~DCIPElectrode () {
  60. } // ----- end of method DCIPElectrode::~DCIPElectrode (destructor) -----
  61. //--------------------------------------------------------------------------------------
  62. // Class: DCIPElectrode
  63. // Method: Serialize
  64. //--------------------------------------------------------------------------------------
  65. YAML::Node DCIPElectrode::Serialize ( ) const {
  66. YAML::Node node = LemmaObject::Serialize();
  67. node.SetTag( this->GetName() );
  68. // FILL IN CLASS SPECIFICS HERE
  69. node["Location"] = Location;
  70. node["Node_ID"] = Node_ID;
  71. node["Label"] = Label;
  72. return node;
  73. } // ----- end of method DCIPElectrode::Serialize -----
  74. //--------------------------------------------------------------------------------------
  75. // Class: DCIPElectrode
  76. // Method: DeSerialize
  77. //--------------------------------------------------------------------------------------
  78. std::shared_ptr<DCIPElectrode> DCIPElectrode::DeSerialize ( const YAML::Node& node ) {
  79. if ( node.Tag() != DCIPElectrode::CName ) {
  80. throw DeSerializeTypeMismatch( DCIPElectrode::CName, node.Tag());
  81. }
  82. return std::make_shared< DCIPElectrode > ( node, ctor_key() );
  83. } // ----- end of method DCIPElectrode::DeSerialize -----
  84. //--------------------------------------------------------------------------------------
  85. // Class: DCIPElectrode
  86. // Method: SetLocation
  87. //--------------------------------------------------------------------------------------
  88. void DCIPElectrode::SetLocation ( const Vector3r& loc ) {
  89. Location = loc;
  90. return ;
  91. } // ----- end of method DCIPElectrode::SetLocation -----
  92. //--------------------------------------------------------------------------------------
  93. // Class: DCIPElectrode
  94. // Method: SetTag
  95. //--------------------------------------------------------------------------------------
  96. void DCIPElectrode::SetLabel ( const std::string& inLabel ) {
  97. Label = inLabel;
  98. return ;
  99. } // ----- end of method DCIPElectrode::SetTag -----
  100. //--------------------------------------------------------------------------------------
  101. // Class: DCIPElectrode
  102. // Method: get_Label
  103. //--------------------------------------------------------------------------------------
  104. std::string DCIPElectrode::GetLabel ( ) {
  105. return Label;
  106. } // ----- end of method DCIPElectrode::get_Label -----
  107. } // ----- end of Lemma name -----