Переглянути джерело

LemmaCore is up to enhancement 3

enhancement_3
T-bone 8 роки тому
джерело
коміт
9ec9386e76

+ 2
- 2
Documentation/dox/tutorial.dox Переглянути файл

@@ -73,11 +73,11 @@ wrappers for all of this would be a huge undertaking.
73 73
   to deliver expressive, fast code. Their benchmarks are right in line with 
74 74
   fast BLAS and LAPACK implementations. If you honestly feel that 
75 75
 \code
76
-DGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC )
76
+    DGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC )
77 77
 \endcode  
78 78
  is superior to
79 79
 \code
80
-  C = A*B.transpose(); 
80
+    C = A*B.transpose(); 
81 81
 \endcode 
82 82
  you are living in denial. Check out the benchmarks if you are still sceptical
83 83
 http://eigen.tuxfamily.org/index.php?title=Benchmark 

+ 4
- 1
Modules/LemmaCore/include/ASCIIParser.h Переглянути файл

@@ -56,7 +56,7 @@ class ASCIIParser : public LemmaObject {
56 56
      *       in c++-17, this curiosity may be resolved.
57 57
      * @see ASCIIParser::DeSerialize
58 58
      */
59
-    ASCIIParser ( const YAML::Node& node, const ctor_key& );
59
+    explicit ASCIIParser ( const YAML::Node& node, const ctor_key& );
60 60
 
61 61
     /** Default  destructor
62 62
      *  @note This should never be called explicitly, use NewSP
@@ -170,3 +170,6 @@ class ASCIIParser : public LemmaObject {
170 170
 }		// -----  end of Lemma  name  -----
171 171
 
172 172
 #endif   // ----- #ifndef ASCIIPARSER_INC  -----
173
+
174
+/* vim: set tabstop=4 expandtab: */
175
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 2
- 2
Modules/LemmaCore/include/CubicSplineInterpolator.h Переглянути файл

@@ -71,7 +71,7 @@ class CubicSplineInterpolator : public LemmaObject {
71 71
     /** Default constructor */
72 72
     explicit CubicSplineInterpolator ( const ctor_key& );
73 73
 
74
-    /** DeSerializing constructor, usees factory DeSerialize  method*/
74
+    /** DeSerializing constructor, locked use factory DeSerialize  method*/
75 75
     CubicSplineInterpolator ( const YAML::Node& node, const ctor_key& );
76 76
 
77 77
     /** Destructor use smart pointers to auto delete */
@@ -189,4 +189,4 @@ class CubicSplineInterpolator : public LemmaObject {
189 189
 #endif   // ----- #ifndef CUBICSPLINEINTERPOLATOR_INC  -----
190 190
 
191 191
 /* vim: set tabstop=4 expandtab: */
192
-/* vim: set filetype=cpp: */
192
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 4
- 0
Modules/LemmaCore/include/GridReader.h Переглянути файл

@@ -65,6 +65,10 @@ namespace Lemma {
65 65
             GridReader ( ) : LemmaObject( ) {
66 66
             }
67 67
 
68
+            /** Default protected constructor, use New */
69
+            GridReader ( const YAML::Node& node ) : LemmaObject( node ) {
70
+            }
71
+
68 72
             /** Default protected constructor, use Delete */
69 73
             ~GridReader () {
70 74
             }

+ 37
- 26
Modules/LemmaCore/include/RectilinearGrid.h Переглянути файл

@@ -18,18 +18,14 @@
18 18
 
19 19
 namespace Lemma {
20 20
 
21
-    // ===================================================================
22
-    //  Class:  RectilinearGrid
23 21
     /**
24
-      @class
25
-      \ingroup LemmaCore
26
-      \brief   Impliments a rectilinear grid.
27
-      \details A rectilinear grid can vary regularily in space but must be
28
-               constant variation across each dimension. In this way three
29
-               vectors can define the entire grid, and each cell is right
30
-               aligned with all its neighbours.
22
+     * \ingroup LemmaCore
23
+     * \brief   Impliments a rectilinear grid.
24
+     * \details A rectilinear grid can vary regularily in space but must be
25
+     *         constant variation across each dimension. In this way three
26
+     *         vectors can define the entire grid, and each cell is right
27
+     *         aligned with all its neighbours.
31 28
      */
32
-    // ===================================================================
33 29
     class RectilinearGrid : public Grid {
34 30
 
35 31
         friend std::ostream &operator<<(std::ostream &stream,
@@ -45,11 +41,29 @@ namespace Lemma {
45 41
             // ====================  LIFECYCLE     =======================
46 42
 
47 43
             /**
48
-             *  Factory method for generating concrete class.
49
-             *  @return a std::shared_ptr of type RectilinearGrid
44
+             * DeSerializing constructor.
45
+             * @note This method is locked, and cannot be called directly.
46
+             *       The reason that the method is public is to enable the use
47
+             *       of make_shared whilst enforcing the use of shared_ptr,
48
+             *       in c++-17, this curiosity may be resolved.
49
+             * @see RectilinearGrid::NewSP
50 50
              */
51
-            static std::shared_ptr<RectilinearGrid> NewSP();
51
+            explicit RectilinearGrid ( const ctor_key& );
52 52
 
53
+            /**
54
+             * DeSerializing constructor.
55
+             * @note This method is locked, and cannot be called directly.
56
+             *       The reason that the method is public is to enable the use
57
+             *       of make_shared whilst enforcing the use of shared_ptr,
58
+             *       in c++-17, this curiosity may be resolved.
59
+             * @see DeSerialize
60
+             */
61
+            explicit RectilinearGrid (const YAML::Node& node, const ctor_key& );
62
+
63
+            /** Default destructor.
64
+             *  @note This should never be called explicitly, use NewSP
65
+             */
66
+            virtual ~RectilinearGrid ();
53 67
 
54 68
             /**
55 69
              *  Uses YAML to serialize this object.
@@ -58,6 +72,12 @@ namespace Lemma {
58 72
             virtual YAML::Node Serialize() const;
59 73
 
60 74
             /**
75
+             *  Factory method for generating concrete class.
76
+             *  @return a std::shared_ptr of type RectilinearGrid
77
+             */
78
+            static std::shared_ptr<RectilinearGrid> NewSP();
79
+
80
+            /**
61 81
              *   Constructs an object from a YAML::Node.
62 82
              */
63 83
             static std::shared_ptr< RectilinearGrid > DeSerialize(const YAML::Node& node);
@@ -168,14 +188,10 @@ namespace Lemma {
168 188
 
169 189
             // ====================  LIFECYCLE     =======================
170 190
 
171
-            /** Default protected constructor. */
172
-            RectilinearGrid ( );
173
-
174
-            /** Protected DeDerializing constructor, use factory DeSerialize  method*/
175
-            RectilinearGrid (const YAML::Node& node);
191
+        private:
176 192
 
177
-            /** Default protected constructor. */
178
-            ~RectilinearGrid ();
193
+            /** ASCII string representation of the class name */
194
+            static constexpr auto CName = "RectilinearGrid";
179 195
 
180 196
             // ====================  DATA MEMBERS  =========================
181 197
 
@@ -206,11 +222,6 @@ namespace Lemma {
206 222
             /// Cell spacing in the z dimension
207 223
             VectorXr dz;
208 224
 
209
-        private:
210
-
211
-            /** ASCII string representation of the class name */
212
-            static constexpr auto CName = "RectilinearGrid";
213
-
214 225
     }; // -----  end of class  RectilinearGrid  -----
215 226
 
216 227
 }		// -----  end of Lemma  name  -----
@@ -218,4 +229,4 @@ namespace Lemma {
218 229
 #endif   // ----- #ifndef RECTILINEARGRID_INC  -----
219 230
 
220 231
 /* vim: set tabstop=4 expandtab: */
221
-/* vim: set filetype=cpp: */
232
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 42
- 6
Modules/LemmaCore/include/RectilinearGridReader.h Переглянути файл

@@ -36,16 +36,54 @@ namespace Lemma {
36 36
         friend std::ostream &operator<<(std::ostream &stream,
37 37
                 const RectilinearGridReader &ob);
38 38
 
39
+        /*
40
+         *  This key is used to lock the constructors
41
+         */
42
+        struct ctor_key {};
43
+
39 44
         public:
40 45
 
41 46
             // ====================  LIFECYCLE     =======================
42 47
 
48
+            /** Default constructor
49
+             * @note This method is locked
50
+             * @see NewSP
51
+             */
52
+            explicit RectilinearGridReader ( const ctor_key& );
53
+
54
+            /**
55
+             * DeSerializing constructor.
56
+             * @note This method is locked, and cannot be called directly.
57
+             *       The reason that the method is public is to enable the use
58
+             *       of make_shared whilst enforcing the use of shared_ptr,
59
+             *       in c++-17, this curiosity may be resolved.
60
+             * @see DeSerialize
61
+             */
62
+            explicit RectilinearGridReader ( const YAML::Node& node, const ctor_key& );
63
+
64
+            /** Default destructor.
65
+             *  @note This should never be called explicitly, use NewSP
66
+             */
67
+            ~RectilinearGridReader ( );
68
+
43 69
             /**
44 70
              *  Factory method for generating concrete class.
45 71
              *  @return a std::shared_ptr of type RectilinearGridReader
46 72
              */
47 73
             static std::shared_ptr< RectilinearGridReader > NewSP();
48 74
 
75
+            /**
76
+             *  Constructs an object from a YAML serialization
77
+             *  @return a std::shared_ptr of type RectilinearGridReader
78
+             */
79
+            static std::shared_ptr< RectilinearGridReader >  DeSerialize( const YAML::Node& node );
80
+
81
+            /**
82
+             *  Uses YAML to serialize this object.
83
+             *  @return a YAML::Node
84
+             */
85
+            virtual YAML::Node Serialize() const;
86
+
49 87
             // ====================  OPERATORS     =======================
50 88
 
51 89
             // ====================  OPERATIONS    =======================
@@ -84,12 +122,6 @@ namespace Lemma {
84 122
 
85 123
             // ====================  LIFECYCLE     =======================
86 124
 
87
-            /** Default protected constructor, use New */
88
-            RectilinearGridReader ( );
89
-
90
-            /** Default protected constructor, use Delete */
91
-            ~RectilinearGridReader ();
92
-
93 125
         private:
94 126
 
95 127
             // ====================  DATA MEMBERS  =========================
@@ -108,3 +140,7 @@ namespace Lemma {
108 140
 }		// -----  end of Lemma  name  -----
109 141
 
110 142
 #endif   // ----- #ifndef RECTILINEARGRIDREADER_INC  -----
143
+
144
+
145
+/* vim: set tabstop=4 expandtab: */
146
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 24
- 12
Modules/LemmaCore/include/RectilinearGridVTKExporter.h Переглянути файл

@@ -45,22 +45,38 @@ class RectilinearGridVTKExporter : public LemmaObject {
45 45
     friend std::ostream &operator<<(std::ostream &stream,
46 46
             const RectilinearGridVTKExporter &ob);
47 47
 
48
+    struct ctor_key {};
49
+
48 50
     public:
49 51
 
50 52
     // ====================  LIFECYCLE     =======================
51 53
 
52 54
     /**
53
-     * @copybrief LemmaObject::New()
54
-     * @copydetails LemmaObject::New()
55
-     */
56
-    static RectilinearGridVTKExporter* New();
57
-
58
-    /**
59 55
      *  Factory method for generating concrete class.
60 56
      *  @return a std::shared_ptr of type RectilinearGridVTKExporter
61 57
      */
62 58
     static std::shared_ptr< RectilinearGridVTKExporter > NewSP();
63 59
 
60
+    /** Default constructor */
61
+    explicit RectilinearGridVTKExporter ( const ctor_key& );
62
+
63
+    /** Deserializing constructor */
64
+    explicit RectilinearGridVTKExporter ( const YAML::Node& node, const ctor_key& );
65
+
66
+    /** Default protected destructor, use Delete */
67
+    virtual ~RectilinearGridVTKExporter ();
68
+
69
+    /**
70
+     *  Uses YAML to serialize this object.
71
+     *  @return a YAML::Node
72
+     */
73
+    virtual YAML::Node Serialize() const;
74
+
75
+    /**
76
+     *   Constructs an object from a YAML::Node.
77
+     */
78
+    static std::shared_ptr< RectilinearGridVTKExporter > DeSerialize(const YAML::Node& node);
79
+
64 80
     // ====================  OPERATORS     =======================
65 81
 
66 82
     // ====================  OPERATIONS    =======================
@@ -93,12 +109,6 @@ class RectilinearGridVTKExporter : public LemmaObject {
93 109
 
94 110
     // ====================  LIFECYCLE     =======================
95 111
 
96
-    /** Default protected constructor, use New */
97
-    RectilinearGridVTKExporter ( );
98
-
99
-    /** Default protected destructor, use Delete */
100
-    ~RectilinearGridVTKExporter ();
101
-
102 112
     private:
103 113
 
104 114
     /** ASCII string representation of the class name */
@@ -122,3 +132,5 @@ class RectilinearGridVTKExporter : public LemmaObject {
122 132
 
123 133
 #endif   // ----- #ifndef RECTILINEARGRIDVTKEXPORTER_INC  -----
124 134
 
135
+/* vim: set tabstop=4 expandtab: */
136
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 4
- 3
Modules/LemmaCore/src/ASCIIParser.cpp Переглянути файл

@@ -24,7 +24,7 @@ namespace Lemma {
24 24
     // ====================  FRIEND METHODS  =====================
25 25
 
26 26
     std::ostream &operator << (std::ostream &stream, const ASCIIParser &ob) {
27
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
27
+        stream << ob.Serialize()  << "\n---\n"; // End of doc
28 28
         return stream;
29 29
     }
30 30
 
@@ -33,7 +33,7 @@ namespace Lemma {
33 33
     //--------------------------------------------------------------------------------------
34 34
     //       Class:  ASCIIParser
35 35
     //      Method:  ASCIIParser
36
-    // Description:  constructor (protected)
36
+    // Description:  constructor (locked)
37 37
     //--------------------------------------------------------------------------------------
38 38
     ASCIIParser::ASCIIParser ( const ctor_key& ) : LemmaObject( ), input(),
39 39
             CommentString("//"), BufferSize(255) {
@@ -217,4 +217,5 @@ namespace Lemma {
217 217
 
218 218
 }		// -----  end of Lemma  name  -----
219 219
 
220
-
220
+/* vim: set tabstop=4 expandtab: */
221
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 3
- 3
Modules/LemmaCore/src/CMakeLists.txt Переглянути файл

@@ -5,9 +5,9 @@ set (SOURCE
5 5
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # fixed, key 
6 6
 	${CMAKE_CURRENT_SOURCE_DIR}/CubicSplineInterpolator.cpp    # fixed, key 
7 7
 	${CMAKE_CURRENT_SOURCE_DIR}/Grid.cpp                       # ABC, no key 
8
-	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGrid.cpp
9
-	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGridReader.cpp
10
-	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGridVTKExporter.cpp
8
+	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGrid.cpp            # fixed, key
9
+	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGridReader.cpp      # fixed, key
10
+	${CMAKE_CURRENT_SOURCE_DIR}/RectilinearGridVTKExporter.cpp # fixed, key
11 11
 	${CMAKE_CURRENT_SOURCE_DIR}/Filter.cpp                     # ABC, no key
12 12
 	${CMAKE_CURRENT_SOURCE_DIR}/WindowFilter.cpp			   # fixed, key
13 13
 	${CMAKE_CURRENT_SOURCE_DIR}/EarthModel.cpp                 # ABC, no key

+ 5
- 7
Modules/LemmaCore/src/RectilinearGrid.cpp Переглянути файл

@@ -22,11 +22,11 @@ namespace Lemma {
22 22
 
23 23
     // ====================  LIFECYCLE     =======================
24 24
 
25
-    RectilinearGrid::RectilinearGrid( ) : Grid( ), nx(0), ny(0), nz(0) {
25
+    RectilinearGrid::RectilinearGrid( const ctor_key& ) : Grid( ), nx(0), ny(0), nz(0) {
26 26
 
27 27
     }
28 28
 
29
-    RectilinearGrid::RectilinearGrid( const YAML::Node& node ) : Grid(node) {
29
+    RectilinearGrid::RectilinearGrid( const YAML::Node& node, const ctor_key& ) : Grid(node) {
30 30
 
31 31
         nx = node["nx"].as<int>( );
32 32
         ny = node["ny"].as<int>( );
@@ -47,8 +47,7 @@ namespace Lemma {
47 47
     }
48 48
 
49 49
     std::shared_ptr< RectilinearGrid > RectilinearGrid::NewSP() {
50
-        std::shared_ptr<RectilinearGrid> sp(new  RectilinearGrid( ), LemmaObjectDeleter() );
51
-        return sp;
50
+        return std::make_shared< RectilinearGrid > ( ctor_key() );
52 51
     }
53 52
 
54 53
     YAML::Node RectilinearGrid::Serialize() const {
@@ -79,8 +78,7 @@ namespace Lemma {
79 78
         if (node.Tag() != "RectilinearGrid") {
80 79
             throw  DeSerializeTypeMismatch( "RectilinearGrid", node.Tag());
81 80
         }
82
-        std::shared_ptr<RectilinearGrid> Object(new  RectilinearGrid(node), LemmaObjectDeleter() );
83
-        return Object ;
81
+        return std::make_shared< RectilinearGrid > ( node, ctor_key() );
84 82
     }
85 83
 
86 84
 
@@ -212,4 +210,4 @@ namespace Lemma {
212 210
 }		// -----  end of Lemma  name  -----
213 211
 
214 212
 /* vim: set tabstop=4 expandtab: */
215
-/* vim: set filetype=cpp: */
213
+/* vim: set filetype=cpp: syntax=cpp.doxygen*/

+ 34
- 7
Modules/LemmaCore/src/RectilinearGridReader.cpp Переглянути файл

@@ -22,7 +22,7 @@ namespace Lemma {
22 22
     // ====================  FRIEND METHODS  =====================
23 23
 
24 24
     std::ostream &operator << (std::ostream &stream, const RectilinearGridReader &ob) {
25
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
25
+        stream << ob.Serialize()  << "\n---\n"; // End of doc
26 26
         return stream;
27 27
     }
28 28
 
@@ -31,13 +31,20 @@ namespace Lemma {
31 31
     //--------------------------------------------------------------------------------------
32 32
     //       Class:  RectilinearGridReader
33 33
     //      Method:  RectilinearGridReader
34
-    // Description:  constructor (protected)
34
+    // Description:  constructor (locked)
35 35
     //--------------------------------------------------------------------------------------
36
-    RectilinearGridReader::RectilinearGridReader ( ) : GridReader( ),
36
+    RectilinearGridReader::RectilinearGridReader ( const ctor_key& ) : GridReader( ),
37 37
         rGrid( nullptr ), Parser( nullptr ) {
38 38
 
39 39
     }  // -----  end of method RectilinearGridReader::RectilinearGridReader  (constructor)  -----
40 40
 
41
+    //--------------------------------------------------------------------------------------
42
+    //       Class:  RectilinearGridReader
43
+    //      Method:  RectilinearGridReader
44
+    // Description:  DeSerializing constructor (protected)
45
+    //--------------------------------------------------------------------------------------
46
+    RectilinearGridReader::RectilinearGridReader (const YAML::Node& node, const ctor_key&  key) : GridReader(node) {
47
+    }  // -----  end of method RectilinearGridReader::RectilinearGridReader  (constructor)  -----
41 48
 
42 49
     //--------------------------------------------------------------------------------------
43 50
     //       Class:  RectilinearGridReader
@@ -45,12 +52,9 @@ namespace Lemma {
45 52
     // Description:  constructor
46 53
     //--------------------------------------------------------------------------------------
47 54
     std::shared_ptr< RectilinearGridReader > RectilinearGridReader::NewSP() {
48
-        std::shared_ptr<RectilinearGridReader> sp(new  RectilinearGridReader( ), LemmaObjectDeleter() );
49
-        return sp;
55
+        return std::make_shared< RectilinearGridReader > ( ctor_key() );
50 56
     }
51 57
 
52
-
53
-
54 58
     //--------------------------------------------------------------------------------------
55 59
     //       Class:  RectilinearGridReader
56 60
     //      Method:  ~RectilinearGridReader
@@ -60,6 +64,29 @@ namespace Lemma {
60 64
     }  // -----  end of method RectilinearGridReader::~RectilinearGridReader  (destructor)  -----
61 65
 
62 66
     //--------------------------------------------------------------------------------------
67
+    //       Class:  ASCIIParser
68
+    //      Method:  Serialize
69
+    //--------------------------------------------------------------------------------------
70
+    YAML::Node  RectilinearGridReader::Serialize (  ) const {
71
+        YAML::Node node = GridReader::Serialize();;
72
+        node.SetTag( GetName() );
73
+        //node["CommentString"] = CommentString;
74
+        //node["BufferSize"] = BufferSize;
75
+        return node;
76
+    }		// -----  end of method ASCIIParser::Serialize  -----
77
+
78
+    //--------------------------------------------------------------------------------------
79
+    //       Class:  RectilinearGridReader
80
+    //      Method:  DeSerialize
81
+    //--------------------------------------------------------------------------------------
82
+    std::shared_ptr<RectilinearGridReader> RectilinearGridReader::DeSerialize ( const YAML::Node& node ) {
83
+        if (node.Tag() != "RectilinearGridReader") {
84
+            throw  DeSerializeTypeMismatch( "RectilinearGridReader", node.Tag());
85
+        }
86
+        return std::make_shared< RectilinearGridReader >( node, ctor_key() ); //, ctor_key() );
87
+    }		// -----  end of method ASCIIParser::DeSerialize  -----
88
+
89
+    //--------------------------------------------------------------------------------------
63 90
     //       Class:  RectilinearGridReader
64 91
     //      Method:  ReadASCIIGridFile
65 92
     //--------------------------------------------------------------------------------------

+ 41
- 10
Modules/LemmaCore/src/RectilinearGridVTKExporter.cpp Переглянути файл

@@ -12,7 +12,7 @@
12 12
  * @date      09/25/2013 08:20:14 AM
13 13
  * @version   $Id$
14 14
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
15
+ * @email     tirons@egi.utah.edu
16 16
  * @copyright Copyright (c) 2013, Trevor Irons
17 17
  */
18 18
 
@@ -25,11 +25,10 @@ namespace Lemma {
25 25
 // ====================  FRIEND METHODS  =====================
26 26
 
27 27
 std::ostream &operator << (std::ostream &stream, const RectilinearGridVTKExporter &ob) {
28
-    stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
28
+    stream << ob.Serialize()  << "\n---\n"; // End of doc
29 29
     return stream;
30 30
 }
31 31
 
32
-
33 32
 // ====================  LIFECYCLE     =======================
34 33
 
35 34
 //--------------------------------------------------------------------------------------
@@ -37,10 +36,20 @@ std::ostream &operator << (std::ostream &stream, const RectilinearGridVTKExporte
37 36
 //      Method:  RectilinearGridVTKExporter
38 37
 // Description:  constructor (protected)
39 38
 //--------------------------------------------------------------------------------------
40
-RectilinearGridVTKExporter::RectilinearGridVTKExporter ( ) : LemmaObject( ), Grid(nullptr), VTKGrid(nullptr) {
39
+RectilinearGridVTKExporter::RectilinearGridVTKExporter ( const ctor_key& ) : LemmaObject( ), Grid(nullptr), VTKGrid(nullptr) {
41 40
 
42 41
 }  // -----  end of method RectilinearGridVTKExporter::RectilinearGridVTKExporter  (constructor)  -----
43 42
 
43
+//--------------------------------------------------------------------------------------
44
+//       Class:  RectilinearGridVTKExporter
45
+//      Method:  RectilinearGridVTKExporter
46
+// Description:  DeSerializing constructor (protected)
47
+//--------------------------------------------------------------------------------------
48
+RectilinearGridVTKExporter::RectilinearGridVTKExporter (const YAML::Node& node, const ctor_key&  key) : LemmaObject(node) {
49
+    if (node["Grid"]) {
50
+        this->Grid = RectilinearGrid::DeSerialize( node["Grid"] );
51
+    }
52
+}  // -----  end of method RectilinearGridVTKExporter::RectilinearGridVTKExporter  (constructor)  -----
44 53
 
45 54
 //--------------------------------------------------------------------------------------
46 55
 //       Class:  RectilinearGridVTKExporter
@@ -48,12 +57,9 @@ RectilinearGridVTKExporter::RectilinearGridVTKExporter ( ) : LemmaObject( ), Gri
48 57
 // Description:  public constructor
49 58
 //--------------------------------------------------------------------------------------
50 59
 std::shared_ptr< RectilinearGridVTKExporter > RectilinearGridVTKExporter::NewSP() {
51
-    std::shared_ptr<RectilinearGridVTKExporter> sp(new  RectilinearGridVTKExporter( ), LemmaObjectDeleter() );
52
-    return sp;
60
+    return std::make_shared< RectilinearGridVTKExporter > ( ctor_key() );
53 61
 }
54 62
 
55
-
56
-
57 63
 //--------------------------------------------------------------------------------------
58 64
 //       Class:  RectilinearGridVTKExporter
59 65
 //      Method:  ~RectilinearGridVTKExporter
@@ -75,6 +81,30 @@ void RectilinearGridVTKExporter::SetGrid ( std::shared_ptr<RectilinearGrid> Grid
75 81
 
76 82
 //--------------------------------------------------------------------------------------
77 83
 //       Class:  RectilinearGridVTKExporter
84
+//      Method:  Serialize
85
+//--------------------------------------------------------------------------------------
86
+YAML::Node  RectilinearGridVTKExporter::Serialize (  ) const {
87
+    YAML::Node node = LemmaObject::Serialize();;
88
+    node.SetTag( GetName() );
89
+    if (Grid != nullptr) {
90
+        node["Grid"] = Grid->Serialize();
91
+    }
92
+    return node;
93
+}		// -----  end of method RectilinearGridVTKExporter::Serialize  -----
94
+
95
+//--------------------------------------------------------------------------------------
96
+//       Class:  RectilinearGridVTKExporter
97
+//      Method:  DeSerialize
98
+//--------------------------------------------------------------------------------------
99
+std::shared_ptr<RectilinearGridVTKExporter> RectilinearGridVTKExporter::DeSerialize ( const YAML::Node& node ) {
100
+    if (node.Tag() != "RectilinearGridVTKExporter") {
101
+        throw  DeSerializeTypeMismatch( "RectilinearGridVTKExporter", node.Tag());
102
+    }
103
+    return std::make_shared< RectilinearGridVTKExporter >( node, ctor_key() ); //, ctor_key() );
104
+}		// -----  end of method RectilinearGridVTKExporter::DeSerialize  -----
105
+
106
+//--------------------------------------------------------------------------------------
107
+//       Class:  RectilinearGridVTKExporter
78 108
 //      Method:  GetVTKRectilinearGrid
79 109
 //--------------------------------------------------------------------------------------
80 110
 vtkSmartPointer<vtkRectilinearGrid> RectilinearGridVTKExporter::GetVTKGrid (  ) {
@@ -140,8 +170,9 @@ void RectilinearGridVTKExporter::BuildVTKRectilinearGrid (  ) {
140 170
     return ;
141 171
 }		// -----  end of method RectilinearGridVTKExporter::BuildVTKRectilinearGrid  -----
142 172
 
143
-
144
-
145 173
 }		// -----  end of Lemma  name  -----
146 174
 
147 175
 #endif     // -----  not LEMMAUSEVTK  -----
176
+
177
+/* vim: set tabstop=4 expandtab: */
178
+/* vim: set filetype=cpp syntax=cpp.doxygen: */

+ 18
- 10
Modules/LemmaCore/testing/SerializeCheck.h Переглянути файл

@@ -26,6 +26,16 @@ class MyTestSuite : public CxxTest::TestSuite
26 26
 {
27 27
     public:
28 28
 
29
+//     void test_trace(void)
30
+//     {
31
+//         TS_TRACE("This is a test tracing message.");
32
+//     }
33
+//
34
+//     void test_warn(void)
35
+//     {
36
+//         TS_WARN("This is a test warning message.");
37
+//     }
38
+
29 39
     void testASCIIParser( void )
30 40
     {
31 41
         auto Obj = ASCIIParser::NewSP();
@@ -50,6 +60,14 @@ class MyTestSuite : public CxxTest::TestSuite
50 60
         TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
51 61
     }
52 62
 
63
+    void testRectilinearGridReader( void )
64
+    {
65
+        auto Obj = RectilinearGridReader::NewSP();
66
+        YAML::Node node = Obj->Serialize();
67
+        auto Obj2 = RectilinearGridReader::DeSerialize(node);
68
+        TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
69
+    }
70
+
53 71
     void testWindowFilter( void )
54 72
     {
55 73
         auto Obj = WindowFilter::NewSP();
@@ -58,21 +76,11 @@ class MyTestSuite : public CxxTest::TestSuite
58 76
         TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
59 77
     }
60 78
 
61
-// /*
62
-//     void testRectilinearGridReader( void )
63
-//     {
64
-//         auto Obj = RectilinearGridReader::NewSP();
65
-//         TS_ASSERT_EQUALS( Obj->GetName(), std::string("RectilinearGridReader") );
66
-//     }
67
-//
68 79
 //     void testRectilinearGridVTKExporter( void )
69 80
 //     {
70 81
 //         auto Obj = RectilinearGridVTKExporter::NewSP();
71 82
 //         TS_ASSERT_EQUALS( Obj->GetName(), std::string("RectilinearGridVTKExporter") );
72 83
 //     }
73
-//
74
-
75
-// */
76 84
 
77 85
 };
78 86
 

+ 1
- 1
vim/c.vim Переглянути файл

@@ -17,7 +17,7 @@ syn keyword nspace Lemma YAML Eigen
17 17
 
18 18
 " Lemma types
19 19
 highlight leType ctermfg=Yellow guifg=Yellow
20
-syn keyword leType HankelTransform KernelEm1D KernelEM1DManager DipoleSource EarthModel LayeredEarth LayeredEarthEM TEMSurvey TEMSurveyLine TEMSurveyLineRecord TEMInductiveReceiver PolygonalWireAntenna TEMTransmitter TEMReceiver Instrument InstrumentTem LemmaObject ReceiverPoints DCIPElectrode TEMSurveyData TEMSurveyLineData TEMSurveyLineRecordData  ASCIIParser CubicSplineInterpolator RectilinearGrid RectilinearGridReader RectilinearGridVTKExporter Filter WindowFilter DEMParticle DEMGrain Data DataReader
20
+syn keyword leType HankelTransform KernelEm1D KernelEM1DManager DipoleSource EarthModel LayeredEarth LayeredEarthEM TEMSurvey TEMSurveyLine TEMSurveyLineRecord TEMInductiveReceiver PolygonalWireAntenna TEMTransmitter TEMReceiver Instrument InstrumentTem LemmaObject ReceiverPoints DCIPElectrode TEMSurveyData TEMSurveyLineData TEMSurveyLineRecordData  ASCIIParser CubicSplineInterpolator RectilinearGrid GridReader RectilinearGridReader RectilinearGridVTKExporter Filter WindowFilter DEMParticle DEMGrain Data DataReader
21 21
 
22 22
 " Deprecated Lemma Types
23 23
 highlight dleType ctermfg=Blue guifg=Blue 

Завантаження…
Відмінити
Зберегти