Browse Source

LemmaCore is up to enhancement 3

enhancement_3
T-bone 8 years ago
parent
commit
9ec9386e76

+ 2
- 2
Documentation/dox/tutorial.dox View File

73
   to deliver expressive, fast code. Their benchmarks are right in line with 
73
   to deliver expressive, fast code. Their benchmarks are right in line with 
74
   fast BLAS and LAPACK implementations. If you honestly feel that 
74
   fast BLAS and LAPACK implementations. If you honestly feel that 
75
 \code
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
 \endcode  
77
 \endcode  
78
  is superior to
78
  is superior to
79
 \code
79
 \code
80
-  C = A*B.transpose(); 
80
+    C = A*B.transpose(); 
81
 \endcode 
81
 \endcode 
82
  you are living in denial. Check out the benchmarks if you are still sceptical
82
  you are living in denial. Check out the benchmarks if you are still sceptical
83
 http://eigen.tuxfamily.org/index.php?title=Benchmark 
83
 http://eigen.tuxfamily.org/index.php?title=Benchmark 

+ 4
- 1
Modules/LemmaCore/include/ASCIIParser.h View File

56
      *       in c++-17, this curiosity may be resolved.
56
      *       in c++-17, this curiosity may be resolved.
57
      * @see ASCIIParser::DeSerialize
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
     /** Default  destructor
61
     /** Default  destructor
62
      *  @note This should never be called explicitly, use NewSP
62
      *  @note This should never be called explicitly, use NewSP
170
 }		// -----  end of Lemma  name  -----
170
 }		// -----  end of Lemma  name  -----
171
 
171
 
172
 #endif   // ----- #ifndef ASCIIPARSER_INC  -----
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 View File

71
     /** Default constructor */
71
     /** Default constructor */
72
     explicit CubicSplineInterpolator ( const ctor_key& );
72
     explicit CubicSplineInterpolator ( const ctor_key& );
73
 
73
 
74
-    /** DeSerializing constructor, usees factory DeSerialize  method*/
74
+    /** DeSerializing constructor, locked use factory DeSerialize  method*/
75
     CubicSplineInterpolator ( const YAML::Node& node, const ctor_key& );
75
     CubicSplineInterpolator ( const YAML::Node& node, const ctor_key& );
76
 
76
 
77
     /** Destructor use smart pointers to auto delete */
77
     /** Destructor use smart pointers to auto delete */
189
 #endif   // ----- #ifndef CUBICSPLINEINTERPOLATOR_INC  -----
189
 #endif   // ----- #ifndef CUBICSPLINEINTERPOLATOR_INC  -----
190
 
190
 
191
 /* vim: set tabstop=4 expandtab: */
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 View File

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

+ 37
- 26
Modules/LemmaCore/include/RectilinearGrid.h View File

18
 
18
 
19
 namespace Lemma {
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
     class RectilinearGrid : public Grid {
29
     class RectilinearGrid : public Grid {
34
 
30
 
35
         friend std::ostream &operator<<(std::ostream &stream,
31
         friend std::ostream &operator<<(std::ostream &stream,
45
             // ====================  LIFECYCLE     =======================
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
              *  Uses YAML to serialize this object.
69
              *  Uses YAML to serialize this object.
58
             virtual YAML::Node Serialize() const;
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
              *   Constructs an object from a YAML::Node.
81
              *   Constructs an object from a YAML::Node.
62
              */
82
              */
63
             static std::shared_ptr< RectilinearGrid > DeSerialize(const YAML::Node& node);
83
             static std::shared_ptr< RectilinearGrid > DeSerialize(const YAML::Node& node);
168
 
188
 
169
             // ====================  LIFECYCLE     =======================
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
             // ====================  DATA MEMBERS  =========================
196
             // ====================  DATA MEMBERS  =========================
181
 
197
 
206
             /// Cell spacing in the z dimension
222
             /// Cell spacing in the z dimension
207
             VectorXr dz;
223
             VectorXr dz;
208
 
224
 
209
-        private:
210
-
211
-            /** ASCII string representation of the class name */
212
-            static constexpr auto CName = "RectilinearGrid";
213
-
214
     }; // -----  end of class  RectilinearGrid  -----
225
     }; // -----  end of class  RectilinearGrid  -----
215
 
226
 
216
 }		// -----  end of Lemma  name  -----
227
 }		// -----  end of Lemma  name  -----
218
 #endif   // ----- #ifndef RECTILINEARGRID_INC  -----
229
 #endif   // ----- #ifndef RECTILINEARGRID_INC  -----
219
 
230
 
220
 /* vim: set tabstop=4 expandtab: */
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 View File

36
         friend std::ostream &operator<<(std::ostream &stream,
36
         friend std::ostream &operator<<(std::ostream &stream,
37
                 const RectilinearGridReader &ob);
37
                 const RectilinearGridReader &ob);
38
 
38
 
39
+        /*
40
+         *  This key is used to lock the constructors
41
+         */
42
+        struct ctor_key {};
43
+
39
         public:
44
         public:
40
 
45
 
41
             // ====================  LIFECYCLE     =======================
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
              *  Factory method for generating concrete class.
70
              *  Factory method for generating concrete class.
45
              *  @return a std::shared_ptr of type RectilinearGridReader
71
              *  @return a std::shared_ptr of type RectilinearGridReader
46
              */
72
              */
47
             static std::shared_ptr< RectilinearGridReader > NewSP();
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
             // ====================  OPERATORS     =======================
87
             // ====================  OPERATORS     =======================
50
 
88
 
51
             // ====================  OPERATIONS    =======================
89
             // ====================  OPERATIONS    =======================
84
 
122
 
85
             // ====================  LIFECYCLE     =======================
123
             // ====================  LIFECYCLE     =======================
86
 
124
 
87
-            /** Default protected constructor, use New */
88
-            RectilinearGridReader ( );
89
-
90
-            /** Default protected constructor, use Delete */
91
-            ~RectilinearGridReader ();
92
-
93
         private:
125
         private:
94
 
126
 
95
             // ====================  DATA MEMBERS  =========================
127
             // ====================  DATA MEMBERS  =========================
108
 }		// -----  end of Lemma  name  -----
140
 }		// -----  end of Lemma  name  -----
109
 
141
 
110
 #endif   // ----- #ifndef RECTILINEARGRIDREADER_INC  -----
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 View File

45
     friend std::ostream &operator<<(std::ostream &stream,
45
     friend std::ostream &operator<<(std::ostream &stream,
46
             const RectilinearGridVTKExporter &ob);
46
             const RectilinearGridVTKExporter &ob);
47
 
47
 
48
+    struct ctor_key {};
49
+
48
     public:
50
     public:
49
 
51
 
50
     // ====================  LIFECYCLE     =======================
52
     // ====================  LIFECYCLE     =======================
51
 
53
 
52
     /**
54
     /**
53
-     * @copybrief LemmaObject::New()
54
-     * @copydetails LemmaObject::New()
55
-     */
56
-    static RectilinearGridVTKExporter* New();
57
-
58
-    /**
59
      *  Factory method for generating concrete class.
55
      *  Factory method for generating concrete class.
60
      *  @return a std::shared_ptr of type RectilinearGridVTKExporter
56
      *  @return a std::shared_ptr of type RectilinearGridVTKExporter
61
      */
57
      */
62
     static std::shared_ptr< RectilinearGridVTKExporter > NewSP();
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
     // ====================  OPERATORS     =======================
80
     // ====================  OPERATORS     =======================
65
 
81
 
66
     // ====================  OPERATIONS    =======================
82
     // ====================  OPERATIONS    =======================
93
 
109
 
94
     // ====================  LIFECYCLE     =======================
110
     // ====================  LIFECYCLE     =======================
95
 
111
 
96
-    /** Default protected constructor, use New */
97
-    RectilinearGridVTKExporter ( );
98
-
99
-    /** Default protected destructor, use Delete */
100
-    ~RectilinearGridVTKExporter ();
101
-
102
     private:
112
     private:
103
 
113
 
104
     /** ASCII string representation of the class name */
114
     /** ASCII string representation of the class name */
122
 
132
 
123
 #endif   // ----- #ifndef RECTILINEARGRIDVTKEXPORTER_INC  -----
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 View File

24
     // ====================  FRIEND METHODS  =====================
24
     // ====================  FRIEND METHODS  =====================
25
 
25
 
26
     std::ostream &operator << (std::ostream &stream, const ASCIIParser &ob) {
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
         return stream;
28
         return stream;
29
     }
29
     }
30
 
30
 
33
     //--------------------------------------------------------------------------------------
33
     //--------------------------------------------------------------------------------------
34
     //       Class:  ASCIIParser
34
     //       Class:  ASCIIParser
35
     //      Method:  ASCIIParser
35
     //      Method:  ASCIIParser
36
-    // Description:  constructor (protected)
36
+    // Description:  constructor (locked)
37
     //--------------------------------------------------------------------------------------
37
     //--------------------------------------------------------------------------------------
38
     ASCIIParser::ASCIIParser ( const ctor_key& ) : LemmaObject( ), input(),
38
     ASCIIParser::ASCIIParser ( const ctor_key& ) : LemmaObject( ), input(),
39
             CommentString("//"), BufferSize(255) {
39
             CommentString("//"), BufferSize(255) {
217
 
217
 
218
 }		// -----  end of Lemma  name  -----
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 View File

5
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # fixed, key 
5
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # fixed, key 
6
 	${CMAKE_CURRENT_SOURCE_DIR}/CubicSplineInterpolator.cpp    # fixed, key 
6
 	${CMAKE_CURRENT_SOURCE_DIR}/CubicSplineInterpolator.cpp    # fixed, key 
7
 	${CMAKE_CURRENT_SOURCE_DIR}/Grid.cpp                       # ABC, no key 
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
 	${CMAKE_CURRENT_SOURCE_DIR}/Filter.cpp                     # ABC, no key
11
 	${CMAKE_CURRENT_SOURCE_DIR}/Filter.cpp                     # ABC, no key
12
 	${CMAKE_CURRENT_SOURCE_DIR}/WindowFilter.cpp			   # fixed, key
12
 	${CMAKE_CURRENT_SOURCE_DIR}/WindowFilter.cpp			   # fixed, key
13
 	${CMAKE_CURRENT_SOURCE_DIR}/EarthModel.cpp                 # ABC, no key
13
 	${CMAKE_CURRENT_SOURCE_DIR}/EarthModel.cpp                 # ABC, no key

+ 5
- 7
Modules/LemmaCore/src/RectilinearGrid.cpp View File

22
 
22
 
23
     // ====================  LIFECYCLE     =======================
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
         nx = node["nx"].as<int>( );
31
         nx = node["nx"].as<int>( );
32
         ny = node["ny"].as<int>( );
32
         ny = node["ny"].as<int>( );
47
     }
47
     }
48
 
48
 
49
     std::shared_ptr< RectilinearGrid > RectilinearGrid::NewSP() {
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
     YAML::Node RectilinearGrid::Serialize() const {
53
     YAML::Node RectilinearGrid::Serialize() const {
79
         if (node.Tag() != "RectilinearGrid") {
78
         if (node.Tag() != "RectilinearGrid") {
80
             throw  DeSerializeTypeMismatch( "RectilinearGrid", node.Tag());
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
 }		// -----  end of Lemma  name  -----
210
 }		// -----  end of Lemma  name  -----
213
 
211
 
214
 /* vim: set tabstop=4 expandtab: */
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 View File

22
     // ====================  FRIEND METHODS  =====================
22
     // ====================  FRIEND METHODS  =====================
23
 
23
 
24
     std::ostream &operator << (std::ostream &stream, const RectilinearGridReader &ob) {
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
         return stream;
26
         return stream;
27
     }
27
     }
28
 
28
 
31
     //--------------------------------------------------------------------------------------
31
     //--------------------------------------------------------------------------------------
32
     //       Class:  RectilinearGridReader
32
     //       Class:  RectilinearGridReader
33
     //      Method:  RectilinearGridReader
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
         rGrid( nullptr ), Parser( nullptr ) {
37
         rGrid( nullptr ), Parser( nullptr ) {
38
 
38
 
39
     }  // -----  end of method RectilinearGridReader::RectilinearGridReader  (constructor)  -----
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
     //       Class:  RectilinearGridReader
50
     //       Class:  RectilinearGridReader
45
     // Description:  constructor
52
     // Description:  constructor
46
     //--------------------------------------------------------------------------------------
53
     //--------------------------------------------------------------------------------------
47
     std::shared_ptr< RectilinearGridReader > RectilinearGridReader::NewSP() {
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
     //       Class:  RectilinearGridReader
59
     //       Class:  RectilinearGridReader
56
     //      Method:  ~RectilinearGridReader
60
     //      Method:  ~RectilinearGridReader
60
     }  // -----  end of method RectilinearGridReader::~RectilinearGridReader  (destructor)  -----
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
     //       Class:  RectilinearGridReader
90
     //       Class:  RectilinearGridReader
64
     //      Method:  ReadASCIIGridFile
91
     //      Method:  ReadASCIIGridFile
65
     //--------------------------------------------------------------------------------------
92
     //--------------------------------------------------------------------------------------

+ 41
- 10
Modules/LemmaCore/src/RectilinearGridVTKExporter.cpp View File

12
  * @date      09/25/2013 08:20:14 AM
12
  * @date      09/25/2013 08:20:14 AM
13
  * @version   $Id$
13
  * @version   $Id$
14
  * @author    Trevor Irons (ti)
14
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
15
+ * @email     tirons@egi.utah.edu
16
  * @copyright Copyright (c) 2013, Trevor Irons
16
  * @copyright Copyright (c) 2013, Trevor Irons
17
  */
17
  */
18
 
18
 
25
 // ====================  FRIEND METHODS  =====================
25
 // ====================  FRIEND METHODS  =====================
26
 
26
 
27
 std::ostream &operator << (std::ostream &stream, const RectilinearGridVTKExporter &ob) {
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
     return stream;
29
     return stream;
30
 }
30
 }
31
 
31
 
32
-
33
 // ====================  LIFECYCLE     =======================
32
 // ====================  LIFECYCLE     =======================
34
 
33
 
35
 //--------------------------------------------------------------------------------------
34
 //--------------------------------------------------------------------------------------
37
 //      Method:  RectilinearGridVTKExporter
36
 //      Method:  RectilinearGridVTKExporter
38
 // Description:  constructor (protected)
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
 }  // -----  end of method RectilinearGridVTKExporter::RectilinearGridVTKExporter  (constructor)  -----
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
 //       Class:  RectilinearGridVTKExporter
55
 //       Class:  RectilinearGridVTKExporter
48
 // Description:  public constructor
57
 // Description:  public constructor
49
 //--------------------------------------------------------------------------------------
58
 //--------------------------------------------------------------------------------------
50
 std::shared_ptr< RectilinearGridVTKExporter > RectilinearGridVTKExporter::NewSP() {
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
 //       Class:  RectilinearGridVTKExporter
64
 //       Class:  RectilinearGridVTKExporter
59
 //      Method:  ~RectilinearGridVTKExporter
65
 //      Method:  ~RectilinearGridVTKExporter
75
 
81
 
76
 //--------------------------------------------------------------------------------------
82
 //--------------------------------------------------------------------------------------
77
 //       Class:  RectilinearGridVTKExporter
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
 //      Method:  GetVTKRectilinearGrid
108
 //      Method:  GetVTKRectilinearGrid
79
 //--------------------------------------------------------------------------------------
109
 //--------------------------------------------------------------------------------------
80
 vtkSmartPointer<vtkRectilinearGrid> RectilinearGridVTKExporter::GetVTKGrid (  ) {
110
 vtkSmartPointer<vtkRectilinearGrid> RectilinearGridVTKExporter::GetVTKGrid (  ) {
140
     return ;
170
     return ;
141
 }		// -----  end of method RectilinearGridVTKExporter::BuildVTKRectilinearGrid  -----
171
 }		// -----  end of method RectilinearGridVTKExporter::BuildVTKRectilinearGrid  -----
142
 
172
 
143
-
144
-
145
 }		// -----  end of Lemma  name  -----
173
 }		// -----  end of Lemma  name  -----
146
 
174
 
147
 #endif     // -----  not LEMMAUSEVTK  -----
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 View File

26
 {
26
 {
27
     public:
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
     void testASCIIParser( void )
39
     void testASCIIParser( void )
30
     {
40
     {
31
         auto Obj = ASCIIParser::NewSP();
41
         auto Obj = ASCIIParser::NewSP();
50
         TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
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
     void testWindowFilter( void )
71
     void testWindowFilter( void )
54
     {
72
     {
55
         auto Obj = WindowFilter::NewSP();
73
         auto Obj = WindowFilter::NewSP();
58
         TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
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
 //     void testRectilinearGridVTKExporter( void )
79
 //     void testRectilinearGridVTKExporter( void )
69
 //     {
80
 //     {
70
 //         auto Obj = RectilinearGridVTKExporter::NewSP();
81
 //         auto Obj = RectilinearGridVTKExporter::NewSP();
71
 //         TS_ASSERT_EQUALS( Obj->GetName(), std::string("RectilinearGridVTKExporter") );
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 View File

17
 
17
 
18
 " Lemma types
18
 " Lemma types
19
 highlight leType ctermfg=Yellow guifg=Yellow
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
 " Deprecated Lemma Types
22
 " Deprecated Lemma Types
23
 highlight dleType ctermfg=Blue guifg=Blue 
23
 highlight dleType ctermfg=Blue guifg=Blue 

Loading…
Cancel
Save