소스 검색

reworking key

submodule
Trevor Irons 6 년 전
부모
커밋
64b883ac2f

+ 28
- 23
Modules/FDEM1D/include/LayeredEarthEMReader.h 파일 보기

26
 namespace Lemma {
26
 namespace Lemma {
27
 
27
 
28
     /**
28
     /**
29
-      \brief
30
-      \details
29
+      \brief Reads ASCII representation of LayeredEarth, similiar to UBC format.
30
+      \details Largely superceded by YAML serialisation, this class remains for legacy purposes.
31
      */
31
      */
32
     class LayeredEarthEMReader : public LemmaObject {
32
     class LayeredEarthEMReader : public LemmaObject {
33
 
33
 
34
 		friend std::ostream &operator<<(std::ostream &stream,
34
 		friend std::ostream &operator<<(std::ostream &stream,
35
 			const LayeredEarthEMReader &ob);
35
 			const LayeredEarthEMReader &ob);
36
 
36
 
37
-        friend std::ostream &operator<<(std::ostream &stream,
38
-                const LayeredEarthEMReader &ob);
39
-
40
         struct ctor_key{};
37
         struct ctor_key{};
41
 
38
 
42
         public:
39
         public:
44
         // ====================  LIFECYCLE     =======================
41
         // ====================  LIFECYCLE     =======================
45
 
42
 
46
         /**
43
         /**
47
-         * @copybrief LemmaObject::New()
48
-         * @copydetails LemmaObject::New()
44
+         * @copybrief LemmaObject::NewSP()
45
+         * @copydetails LemmaObject::NewSP()
49
          */
46
          */
50
-        static LayeredEarthEMReader* New();
47
+        static std::shared_ptr<LayeredEarthEMReader> NewSP();
48
+
49
+        /** Default locked constructor, use New */
50
+        explicit LayeredEarthEMReader ( const ctor_key& );
51
+
52
+        /** Locked deserializing constructor. */
53
+			LayeredEarthEMReader ( const YAML::Node& node, const ctor_key& );
54
+
55
+        /** Default destructor */
56
+        virtual ~LayeredEarthEMReader ();
57
+
58
+        /** YAML Serializing method
59
+         */
60
+        YAML::Node Serialize() const;
51
 
61
 
52
         /**
62
         /**
53
-         *  @copybrief   LemmaObject::Delete()
54
-         *  @copydetails LemmaObject::Delete()
63
+         *   Constructs an object from a YAML::Node.
55
          */
64
          */
56
-        void Delete();
65
+        static std::shared_ptr< LayeredEarthEMReader > DeSerialize(const YAML::Node& node);
57
 
66
 
58
         // ====================  OPERATORS     =======================
67
         // ====================  OPERATORS     =======================
59
 
68
 
79
 
88
 
80
         // ====================  INQUIRY       =======================
89
         // ====================  INQUIRY       =======================
81
 
90
 
91
+        /** Returns the name of the underlying class, similiar to Python's type */
92
+        virtual std::string GetName() const {
93
+            return this->CName;
94
+        }
95
+
82
         protected:
96
         protected:
83
 
97
 
84
         // ====================  LIFECYCLE     =======================
98
         // ====================  LIFECYCLE     =======================
85
 
99
 
86
-        /** Default protected constructor, use New */
87
-        LayeredEarthEMReader (const std::string& name);
88
-
89
-        /** Default protected destructor, use Delete */
90
-        ~LayeredEarthEMReader ();
91
-
92
-        /**
93
-         *  @copybrief   LemmaObject::Release()
94
-         *  @copydetails LemmaObject::Release()
95
-         */
96
-        void Release();
97
-
98
         private:
100
         private:
99
 
101
 
100
         // ====================  DATA MEMBERS  =========================
102
         // ====================  DATA MEMBERS  =========================
101
 
103
 
102
         LayeredEarthEM*         LayEarth;
104
         LayeredEarthEM*         LayEarth;
103
 
105
 
106
+        /** ASCII string representation of the class name */
107
+        static constexpr auto CName = "LayeredEarthEMReader";
108
+
104
     }; // -----  end of class  LayeredEarthEMReader  -----
109
     }; // -----  end of class  LayeredEarthEMReader  -----
105
 
110
 
106
 
111
 

+ 1
- 0
Modules/FDEM1D/src/CMakeLists.txt 파일 보기

2
 	${FDEM1DSOURCE}
2
 	${FDEM1DSOURCE}
3
 
3
 
4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
5
+#	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEMReader.cpp
5
 	
6
 	
6
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
7
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
7
 	
8
 	

+ 1
- 1
Modules/FDEM1D/src/LayeredEarthEM.cpp 파일 보기

22
 
22
 
23
     // ====================  LIFECYCLE     ===================================
23
     // ====================  LIFECYCLE     ===================================
24
 
24
 
25
-    LayeredEarthEM::LayeredEarthEM( const ctor_key& ) : LayeredEarth() {
25
+    LayeredEarthEM::LayeredEarthEM( const ctor_key& key ) : LayeredEarth( LayeredEarth::ctor_key() ) {
26
     }
26
     }
27
 
27
 
28
     LayeredEarthEM::LayeredEarthEM( const YAML::Node& node, const ctor_key& ) : LayeredEarth(node) {
28
     LayeredEarthEM::LayeredEarthEM( const YAML::Node& node, const ctor_key& ) : LayeredEarth(node) {

+ 5
- 6
Modules/FDEM1D/src/LayeredEarthEMReader.cpp 파일 보기

22
 
22
 
23
     // ====================  FRIEND METHODS  =====================
23
     // ====================  FRIEND METHODS  =====================
24
 
24
 
25
-    std::ostream &operator<<(std::ostream &stream, const LayeredEarthEMReader &ob) {
26
-
27
-        stream << *(LemmaObject*)(&ob);
28
-
25
+    std::ostream &operator << (std::ostream &stream, const LayeredEarthEMReader &ob) {
26
+        stream << ob.Serialize()  << "\n---\n"; // End of doc ---
29
         return stream;
27
         return stream;
30
     }
28
     }
31
 
29
 
30
+
32
     // ====================  LIFECYCLE     =======================
31
     // ====================  LIFECYCLE     =======================
33
 
32
 
34
     //--------------------------------------------------------------------------------------
33
     //--------------------------------------------------------------------------------------
36
     //      Method:  LayeredEarthEMReader
35
     //      Method:  LayeredEarthEMReader
37
     // Description:  constructor (protected)
36
     // Description:  constructor (protected)
38
     //--------------------------------------------------------------------------------------
37
     //--------------------------------------------------------------------------------------
39
-    LayeredEarthEMReader::LayeredEarthEMReader (const std::string& name) : LemmaObject(name),
40
-        LayEarth(NULL) {
38
+    LayeredEarthEMReader::LayeredEarthEMReader ( const ctor_key& key ) : LemmaObject(),
39
+        LayEarth(nullptr) {
41
 
40
 
42
     }  // -----  end of method LayeredEarthEMReader::LayeredEarthEMReader  (constructor)  -----
41
     }  // -----  end of method LayeredEarthEMReader::LayeredEarthEMReader  (constructor)  -----
43
 
42
 

+ 1
- 1
Modules/LemmaCore/include/ASCIIParser.h 파일 보기

36
     /*
36
     /*
37
      *  This key is used to lock the constructors
37
      *  This key is used to lock the constructors
38
      */
38
      */
39
-    struct ctor_key {};
39
+    //struct ctor_key {};
40
 
40
 
41
     public:
41
     public:
42
 
42
 

+ 3
- 1
Modules/LemmaCore/include/LayeredEarth.h 파일 보기

30
         friend class LayeredEarthEM;
30
         friend class LayeredEarthEM;
31
         friend class LayeredEarthMR;
31
         friend class LayeredEarthMR;
32
 
32
 
33
+        struct ctor_key{};
34
+
33
 		public:
35
 		public:
34
 
36
 
35
 			// ====================    FRIENDS     ===========================
37
 			// ====================    FRIENDS     ===========================
102
 			// ====================  LIFECYCLE     ===========================
104
 			// ====================  LIFECYCLE     ===========================
103
 
105
 
104
 			/** Default protected constructor. */
106
 			/** Default protected constructor. */
105
-			LayeredEarth ( );
107
+			LayeredEarth ( const ctor_key& );
106
 
108
 
107
             /** Default protected constructor. */
109
             /** Default protected constructor. */
108
 			LayeredEarth (const YAML::Node& node);
110
 			LayeredEarth (const YAML::Node& node);

+ 6
- 9
Modules/LemmaCore/include/LemmaObject.h 파일 보기

41
      */
41
      */
42
     //friend YAML::Emitter& operator << (YAML::Emitter& out, const LemmaObject &ob) ;
42
     //friend YAML::Emitter& operator << (YAML::Emitter& out, const LemmaObject &ob) ;
43
 
43
 
44
-    friend class LemmaObjectDeleter;
44
+    protected:
45
+        struct ctor_key{};
45
 
46
 
46
     public:
47
     public:
48
+
47
         // Needed because many derived classes have Eigen vectors as members,
49
         // Needed because many derived classes have Eigen vectors as members,
48
         // causing alignment issues when vectorisation is enabled.
50
         // causing alignment issues when vectorisation is enabled.
49
         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51
         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
95
         /** Protected default constructor. This is an abstract class and
97
         /** Protected default constructor. This is an abstract class and
96
          *  cannot be instantiated.
98
          *  cannot be instantiated.
97
          */
99
          */
98
-        LemmaObject ( );
100
+        LemmaObject ( const ctor_key& );
99
 
101
 
100
         /** Protected DeSerializing constructor */
102
         /** Protected DeSerializing constructor */
101
-        LemmaObject (const YAML::Node& node);
103
+        LemmaObject ( const YAML::Node& node, const ctor_key& );
102
 
104
 
105
+        /** Disable copying Lemma Object */
103
         LemmaObject( const LemmaObject& ) = delete;
106
         LemmaObject( const LemmaObject& ) = delete;
104
 
107
 
105
         /** Protected default destructor. This is an abstract class and
108
         /** Protected default destructor. This is an abstract class and
117
 
120
 
118
 }; // -----  end of class  LemmaObject  -----
121
 }; // -----  end of class  LemmaObject  -----
119
 
122
 
120
-class LemmaObjectDeleter
121
-{
122
-    public:
123
-        void operator()(LemmaObject* p) { delete p; }
124
-};
125
-
126
     /////////////////////////////////////////////////////////////////
123
     /////////////////////////////////////////////////////////////////
127
     // Error Classes
124
     // Error Classes
128
 
125
 

+ 2
- 2
Modules/LemmaCore/src/ASCIIParser.cpp 파일 보기

35
     //      Method:  ASCIIParser
35
     //      Method:  ASCIIParser
36
     // Description:  constructor (locked)
36
     // Description:  constructor (locked)
37
     //--------------------------------------------------------------------------------------
37
     //--------------------------------------------------------------------------------------
38
-    ASCIIParser::ASCIIParser ( const ctor_key& ) : LemmaObject( ), input(),
38
+    ASCIIParser::ASCIIParser ( const ctor_key& key ) : LemmaObject( key ), input(),
39
             CommentString("//"), BufferSize(255) {
39
             CommentString("//"), BufferSize(255) {
40
 
40
 
41
     }  // -----  end of method ASCIIParser::ASCIIParser  (constructor)  -----
41
     }  // -----  end of method ASCIIParser::ASCIIParser  (constructor)  -----
96
     //      Method:  ASCIIParser
96
     //      Method:  ASCIIParser
97
     // Description:  DeSerializing constructor (protected)
97
     // Description:  DeSerializing constructor (protected)
98
     //--------------------------------------------------------------------------------------
98
     //--------------------------------------------------------------------------------------
99
-    ASCIIParser::ASCIIParser (const YAML::Node& node, const ctor_key&  key) : LemmaObject(node) {
99
+    ASCIIParser::ASCIIParser (const YAML::Node& node, const ctor_key&  key) : LemmaObject(node, key) {
100
         this->CommentString = node["CommentString"].as<std::string>();
100
         this->CommentString = node["CommentString"].as<std::string>();
101
         this->BufferSize = node["BufferSize"].as<int>();
101
         this->BufferSize = node["BufferSize"].as<int>();
102
     }  // -----  end of method ASCIIParser::ASCIIParser  (constructor)  -----
102
     }  // -----  end of method ASCIIParser::ASCIIParser  (constructor)  -----

+ 1
- 1
Modules/LemmaCore/src/LayeredEarth.cpp 파일 보기

24
 
24
 
25
 	// ====================  LIFECYCLE     ===================================
25
 	// ====================  LIFECYCLE     ===================================
26
 
26
 
27
-	LayeredEarth::LayeredEarth( ) : EarthModel( ),
27
+	LayeredEarth::LayeredEarth( const ctor_key& key ) : EarthModel( ),
28
 		NumberOfLayers(0), 	NumberOfInterfaces(0) {
28
 		NumberOfLayers(0), 	NumberOfInterfaces(0) {
29
 	}
29
 	}
30
 
30
 

+ 2
- 9
Modules/LemmaCore/src/LemmaObject.cpp 파일 보기

15
 
15
 
16
 namespace Lemma {
16
 namespace Lemma {
17
 
17
 
18
-//     YAML::Emitter& operator << (YAML::Emitter& out, const LemmaObject& ob) {
19
-//         out << YAML::Flow;
20
-//         out << YAML::BeginMap;
21
-//         out << YAML::Key <<"Class Name"    << YAML::Value << ob.GetName();
22
-//         return out;
23
-//     }
24
-
25
     // ====================  LIFECYCLE     ==============================
18
     // ====================  LIFECYCLE     ==============================
26
 
19
 
27
     // Constructor
20
     // Constructor
28
-    LemmaObject::LemmaObject(  ) {
21
+    LemmaObject::LemmaObject( const ctor_key& ) {
29
 
22
 
30
     }
23
     }
31
 
24
 
32
-    LemmaObject::LemmaObject(const YAML::Node &node) {
25
+    LemmaObject::LemmaObject( const YAML::Node &node, const ctor_key& ) {
33
     }
26
     }
34
 
27
 
35
     // Destructor
28
     // Destructor

Loading…
취소
저장