Lemma is an Electromagnetics API
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DCIPElectrode.cpp 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #ifdef HAVE_YAMLCPP
  21. std::ostream &operator << (std::ostream &stream, const DCIPElectrode &ob) {
  22. stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulate thingy
  23. return stream;
  24. }
  25. #else
  26. std::ostream &operator<<(std::ostream &stream, const DCIPElectrode& ob) {
  27. stream << *(LemmaObject*)(&ob);
  28. return stream;
  29. }
  30. #endif
  31. // ==================== LIFECYCLE =======================
  32. //--------------------------------------------------------------------------------------
  33. // Class: DCIPElectrode
  34. // Method: DCIPElectrode
  35. // Description: constructor (protected)
  36. //--------------------------------------------------------------------------------------
  37. DCIPElectrode::DCIPElectrode (const std::string& name) : LemmaObject(name), Node_ID(-1), Label(std::string("None")) {
  38. } // ----- end of method DCIPElectrode::DCIPElectrode (constructor) -----
  39. #ifdef HAVE_YAMLCPP
  40. //--------------------------------------------------------------------------------------
  41. // Class: DCIPElectrode
  42. // Method: DCIPElectrode
  43. // Description: DeSerializing constructor (protected)
  44. //--------------------------------------------------------------------------------------
  45. DCIPElectrode::DCIPElectrode (const YAML::Node& node) : LemmaObject(node) {
  46. if (node.Tag() != this->Name) {
  47. throw std::runtime_error("In DCIPElectrode(node), node is of wrong type");
  48. }
  49. this->Location = node["Location"].as<Vector3r>();
  50. this->Node_ID = node["Node_ID"].as<int>();
  51. this->Label = node["Label"].as<std::string>();
  52. } // ----- end of method DCIPElectrode::DCIPElectrode (constructor) -----
  53. #endif
  54. //--------------------------------------------------------------------------------------
  55. // Class: DCIPElectrode
  56. // Method: New()
  57. // Description: public constructor
  58. //--------------------------------------------------------------------------------------
  59. DCIPElectrode* DCIPElectrode::New() {
  60. DCIPElectrode* Obj = new DCIPElectrode("DCIPElectrode");
  61. Obj->AttachTo(Obj);
  62. return Obj;
  63. }
  64. //--------------------------------------------------------------------------------------
  65. // Class: DCIPElectrode
  66. // Method: ~DCIPElectrode
  67. // Description: destructor (protected)
  68. //--------------------------------------------------------------------------------------
  69. DCIPElectrode::~DCIPElectrode () {
  70. } // ----- end of method DCIPElectrode::~DCIPElectrode (destructor) -----
  71. //--------------------------------------------------------------------------------------
  72. // Class: DCIPElectrode
  73. // Method: Delete
  74. // Description: public destructor
  75. //--------------------------------------------------------------------------------------
  76. void DCIPElectrode::Delete() {
  77. this->DetachFrom(this);
  78. }
  79. //--------------------------------------------------------------------------------------
  80. // Class: DCIPElectrode
  81. // Method: Release
  82. // Description: destructor (protected)
  83. //--------------------------------------------------------------------------------------
  84. void DCIPElectrode::Release() {
  85. delete this;
  86. }
  87. #ifdef HAVE_YAMLCPP
  88. //--------------------------------------------------------------------------------------
  89. // Class: DCIPElectrode
  90. // Method: Serialize
  91. //--------------------------------------------------------------------------------------
  92. YAML::Node DCIPElectrode::Serialize ( ) const {
  93. YAML::Node node = LemmaObject::Serialize();
  94. node.SetTag( this->Name );
  95. // FILL IN CLASS SPECIFICS HERE
  96. node["Location"] = Location;
  97. node["Node_ID"] = Node_ID;
  98. node["Label"] = Label;
  99. return node;
  100. } // ----- end of method DCIPElectrode::Serialize -----
  101. //--------------------------------------------------------------------------------------
  102. // Class: DCIPElectrode
  103. // Method: DeSerialize
  104. //--------------------------------------------------------------------------------------
  105. DCIPElectrode* DCIPElectrode::DeSerialize ( const YAML::Node& node ) {
  106. DCIPElectrode* Object = new DCIPElectrode(node);
  107. Object->AttachTo(Object);
  108. DESERIALIZECHECK( node, Object )
  109. return Object ;
  110. } // ----- end of method DCIPElectrode::DeSerialize -----
  111. #endif
  112. //--------------------------------------------------------------------------------------
  113. // Class: DCIPElectrode
  114. // Method: SetLocation
  115. //--------------------------------------------------------------------------------------
  116. void DCIPElectrode::SetLocation ( const Vector3r& loc ) {
  117. Location = loc;
  118. return ;
  119. } // ----- end of method DCIPElectrode::SetLocation -----
  120. //--------------------------------------------------------------------------------------
  121. // Class: DCIPElectrode
  122. // Method: SetTag
  123. //--------------------------------------------------------------------------------------
  124. void DCIPElectrode::SetLabel ( const std::string& inLabel ) {
  125. Label = inLabel;
  126. return ;
  127. } // ----- end of method DCIPElectrode::SetTag -----
  128. //--------------------------------------------------------------------------------------
  129. // Class: DCIPElectrode
  130. // Method: get_Label
  131. //--------------------------------------------------------------------------------------
  132. std::string DCIPElectrode::GetLabel ( ) {
  133. return Label;
  134. } // ----- end of method DCIPElectrode::get_Label -----
  135. } // ----- end of Lemma name -----