Przeglądaj źródła

Updates to testing suite

enhancement_3
Trevor Irons 8 lat temu
rodzic
commit
a3db0266b7

+ 0
- 4
CMakeLists.txt Wyświetl plik

@@ -222,10 +222,6 @@ add_subdirectory (Modules)
222 222
 # 
223 223
 include_directories(${CMAKE_INSTALL_PREFIX}/include)
224 224
 
225
-#add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
226
-#target_link_libraries(Hello lemmacore)
227
-#add_dependencies(Hello YAML-CPP)
228
-
229 225
 # add a target to generate API documentation with Doxygen
230 226
 # ALL make documentation build by default if possible
231 227
 find_package(Doxygen)

+ 5
- 0
LemmaCore/include/Grid.h Wyświetl plik

@@ -34,6 +34,8 @@ class Grid : public LemmaObject {
34 34
 
35 35
         // ====================  LIFECYCLE     ===================================
36 36
 
37
+        YAML::Node Serialize() const;
38
+
37 39
         // ====================  OPERATORS     ===================================
38 40
 
39 41
         // ====================  OPERATIONS    ===================================
@@ -51,6 +53,9 @@ class Grid : public LemmaObject {
51 53
 
52 54
         // ====================  LIFECYCLE     ===================================
53 55
 
56
+        /** Protected DeDerializing constructor, use factory DeSerialize  method on non abstract classes*/
57
+        Grid (const YAML::Node& node);
58
+
54 59
         /// Default protected constructor.
55 60
         Grid ( );
56 61
 

+ 1
- 0
LemmaCore/include/RectilinearGrid.h Wyświetl plik

@@ -44,6 +44,7 @@ namespace Lemma {
44 44
              */
45 45
             static std::shared_ptr<RectilinearGrid> NewSP();
46 46
 
47
+
47 48
             /**
48 49
              *  Uses YAML to serialize this object.
49 50
              *  @return a YAML::Node

+ 13
- 0
LemmaCore/src/Grid.cpp Wyświetl plik

@@ -20,11 +20,24 @@ namespace Lemma {
20 20
         return stream;
21 21
     }
22 22
 
23
+    // ====================  LIFECYCLE     ===================================
23 24
 
24 25
 	Grid::Grid( ) : LemmaObject( ) {
25 26
 	}
26 27
 
28
+    Grid::Grid( const YAML::Node& node ) : LemmaObject(node) {
29
+
30
+    }
31
+
27 32
 	Grid::~Grid  ( ) {
28 33
 	}
29 34
 
35
+    YAML::Node Grid::Serialize() const {
36
+
37
+        YAML::Node node = LemmaObject::Serialize();
38
+        node.SetTag( this->GetName() );
39
+        return node;
40
+
41
+    }
42
+
30 43
 }

+ 49
- 13
LemmaCore/src/RectilinearGrid.cpp Wyświetl plik

@@ -20,25 +20,28 @@ namespace Lemma {
20 20
         return stream;
21 21
     }
22 22
 
23
-    /*
24
-	std::ostream &operator<<(std::ostream &stream, const
25
-	    RectilinearGrid &ob) {
26
-		stream << *(LemmaObject*)(&ob);
27
-        stream << "\tnx=" << ob.nx << "\tny=" << ob.ny << "\tnz=" << ob.nz << std::endl;
28
-        stream << "\tox=" << ob.ox << "\toy=" << ob.oy << "\toz=" << ob.oz << std::endl;
29
-        stream << "\tdx=" << ob.dx.transpose() << std::endl;
30
-        stream << "\tdy=" << ob.dy.transpose() << std::endl;
31
-        stream << "\tdz=" << ob.dz.transpose() << std::endl;
32
-		return stream;
33
-	}
34
-    */
35
-
36 23
     // ====================  LIFECYCLE     =======================
37 24
 
38 25
     RectilinearGrid::RectilinearGrid( ) : Grid( ), nx(0), ny(0), nz(0) {
39 26
 
40 27
     }
41 28
 
29
+    RectilinearGrid::RectilinearGrid( const YAML::Node& node ) : Grid(node) {
30
+
31
+        nx = node["nx"].as<int>( );
32
+        ny = node["ny"].as<int>( );
33
+        nz = node["nz"].as<int>( );
34
+
35
+        ox = node["ox"].as<Real>( );
36
+        oy = node["oy"].as<Real>( );
37
+        oz = node["oz"].as<Real>( );
38
+
39
+        dx = node["dx"].as< VectorXr >();
40
+        dy = node["dy"].as< VectorXr >();
41
+        dz = node["dz"].as< VectorXr >();
42
+
43
+    }
44
+
42 45
     RectilinearGrid::~RectilinearGrid() {
43 46
 
44 47
     }
@@ -48,6 +51,39 @@ namespace Lemma {
48 51
         return sp;
49 52
     }
50 53
 
54
+    YAML::Node RectilinearGrid::Serialize() const {
55
+        YAML::Node node = Grid::Serialize();
56
+
57
+        node["nx"] = nx;
58
+        node["ny"] = ny;
59
+        node["nz"] = nz;
60
+
61
+        node["ox"] = ox;
62
+        node["oy"] = oy;
63
+        node["oz"] = oz;
64
+
65
+        node["dx"] = dx;
66
+        node["dy"] = dy;
67
+        node["dz"] = dz;
68
+
69
+        node.SetTag( this->GetName() );
70
+        return node;
71
+    }
72
+
73
+
74
+    //--------------------------------------------------------------------------------------
75
+    //       Class:  RectilinearGrid
76
+    //      Method:  DeSerialize
77
+    //--------------------------------------------------------------------------------------
78
+    std::shared_ptr<RectilinearGrid> RectilinearGrid::DeSerialize ( const YAML::Node& node  ) {
79
+        if (node.Tag() != "RectilinearGrid") {
80
+            throw  DeSerializeTypeMismatch( "RectilinearGrid", node.Tag());
81
+        }
82
+        std::shared_ptr<RectilinearGrid> Object(new  RectilinearGrid(node), LemmaObjectDeleter() );
83
+        return Object ;
84
+    }
85
+
86
+
51 87
     // ====================  OPERATIONS    =======================
52 88
 
53 89
     void RectilinearGrid::SetDimensions (const int &inx, const int &iny,

+ 0
- 2
LemmaCore/testing/SerializeCheck.h Wyświetl plik

@@ -52,8 +52,6 @@ class MyTestSuite : public CxxTest::TestSuite
52 52
     }
53 53
 
54 54
 // /*
55
-
56
-//
57 55
 //     void testRectilinearGridReader( void )
58 56
 //     {
59 57
 //         auto Obj = RectilinearGridReader::NewSP();

Ładowanie…
Anuluj
Zapisz