Main Lemma Repository
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

LemmaObject.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 06/25/2009
  9. @version $Id: LemmaObject.cpp 266 2015-04-01 03:24:00Z tirons $
  10. **/
  11. #include "LemmaObject.h"
  12. namespace Lemma {
  13. std::ostream &operator << (std::ostream &stream,
  14. const LemmaObject &ob) {
  15. stream << "Class name= " << ob.Name << "\n";
  16. return stream;
  17. }
  18. #ifdef HAVE_YAMLCPP
  19. YAML::Emitter& operator << (YAML::Emitter& out, const LemmaObject& ob) {
  20. out << YAML::BeginMap;
  21. out << YAML::Key <<"Class Name" << YAML::Value << ob.GetName();
  22. return out;
  23. }
  24. #endif
  25. // ==================== LIFECYCLE ==============================
  26. // Constructor
  27. LemmaObject::LemmaObject(const std::string& name) : Name(name) {
  28. }
  29. #ifdef HAVE_YAMLCPP
  30. LemmaObject::LemmaObject(const YAML::Node &node) : Name(node.Tag()) {
  31. }
  32. #endif
  33. // Destructor
  34. LemmaObject::~LemmaObject() {
  35. std::cout << "~LemmaObject()" << std::endl;
  36. }
  37. // ==================== OPERATIONS ==============================
  38. // ==================== INQUIRY ==============================
  39. std::string LemmaObject::GetName() const {
  40. return Name;
  41. }
  42. // ==================== ACCESS ==============================
  43. // ==================== ACCESS ==============================
  44. // ==================== OPERATORS ==============================
  45. //////////////////////////////////////////////////////////////////////
  46. //////////////////////////////////////////////////////////////////////
  47. DeSerializeTypeMismatch::DeSerializeTypeMismatch(LemmaObject *ptr, const std::string& got) :
  48. runtime_error("DESERIALIZE TYPE MISMATCH") {
  49. std::cerr << "Expected " << ptr->GetName() << " got " << got << std::endl;
  50. }
  51. RequestToReturnNullPointer::
  52. RequestToReturnNullPointer(LemmaObject *ptr) :
  53. runtime_error("REQUEST TO RETURN NULL POINTER"){
  54. std::cerr << "Thrown by instance of "
  55. << ptr->GetName() << std::endl;
  56. }
  57. MatFileCannotBeOpened::
  58. MatFileCannotBeOpened() :
  59. runtime_error("MATFILE CANNOT BE OPENED"){}
  60. AssignmentOutOfBounds::
  61. AssignmentOutOfBounds(LemmaObject *ptr) :
  62. runtime_error("ASSIGNMENT OUT OF BOUNDS"){
  63. std::cerr << "Thrown by instance of "
  64. << ptr->GetName() << std::endl;
  65. }
  66. GenericFileIOError::
  67. GenericFileIOError(LemmaObject *ptr, const std::string &filename) : runtime_error("FILE I/O ERROR"){
  68. std::cerr << std::endl;
  69. std::cerr << "FILE I/O ERROR" << std::endl;
  70. std::cerr << std::endl;
  71. std::cerr << "Thrown by instance of "
  72. << ptr->GetName() << std::endl;
  73. std::cerr << " while trying to access " << filename << std::endl;
  74. std::cerr << std::endl;
  75. }
  76. } // end of namespace Lemma