Browse Source

Updates to testing suite

enhancement_3
Trevor Irons 8 years ago
parent
commit
a3db0266b7

+ 0
- 4
CMakeLists.txt View File

222
 # 
222
 # 
223
 include_directories(${CMAKE_INSTALL_PREFIX}/include)
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
 # add a target to generate API documentation with Doxygen
225
 # add a target to generate API documentation with Doxygen
230
 # ALL make documentation build by default if possible
226
 # ALL make documentation build by default if possible
231
 find_package(Doxygen)
227
 find_package(Doxygen)

+ 5
- 0
LemmaCore/include/Grid.h View File

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

+ 1
- 0
LemmaCore/include/RectilinearGrid.h View File

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

+ 13
- 0
LemmaCore/src/Grid.cpp View File

20
         return stream;
20
         return stream;
21
     }
21
     }
22
 
22
 
23
+    // ====================  LIFECYCLE     ===================================
23
 
24
 
24
 	Grid::Grid( ) : LemmaObject( ) {
25
 	Grid::Grid( ) : LemmaObject( ) {
25
 	}
26
 	}
26
 
27
 
28
+    Grid::Grid( const YAML::Node& node ) : LemmaObject(node) {
29
+
30
+    }
31
+
27
 	Grid::~Grid  ( ) {
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 View File

20
         return stream;
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
     // ====================  LIFECYCLE     =======================
23
     // ====================  LIFECYCLE     =======================
37
 
24
 
38
     RectilinearGrid::RectilinearGrid( ) : Grid( ), nx(0), ny(0), nz(0) {
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
     RectilinearGrid::~RectilinearGrid() {
45
     RectilinearGrid::~RectilinearGrid() {
43
 
46
 
44
     }
47
     }
48
         return sp;
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
     // ====================  OPERATIONS    =======================
87
     // ====================  OPERATIONS    =======================
52
 
88
 
53
     void RectilinearGrid::SetDimensions (const int &inx, const int &iny,
89
     void RectilinearGrid::SetDimensions (const int &inx, const int &iny,

+ 0
- 2
LemmaCore/testing/SerializeCheck.h View File

52
     }
52
     }
53
 
53
 
54
 // /*
54
 // /*
55
-
56
-//
57
 //     void testRectilinearGridReader( void )
55
 //     void testRectilinearGridReader( void )
58
 //     {
56
 //     {
59
 //         auto Obj = RectilinearGridReader::NewSP();
57
 //         auto Obj = RectilinearGridReader::NewSP();

Loading…
Cancel
Save