#ifndef DIALS_NEXUS_NXSAMPLE_H #define DIALS_NEXUS_NXSAMPLE_H #include #include #include #include #include #include #include namespace dials { namespace nexus { using scitbx::vec3; using scitbx::mat3; class NXsample { public: boost::optional name; boost::optional chemical_formula; boost::optional temperature; af::shared unit_cell_class; af::shared unit_cell_group; boost::optional< vec3 > sample_orientation; af::shared< mat3 > orientation_matrix; af::shared< af::tiny > unit_cell; boost::optional beam; }; template <> struct serialize { template static NXsample load(const Handle &handle) { NXsample result; // Process the objects in the group for (std::size_t i = 0; i < handle.getNumObjs(); ++i) { // Get the name of the object std::string name = handle.getObjnameByIdx(i); switch (handle.getObjTypeByIdx(i)) { case H5G_GROUP: { H5::Group group = handle.openGroup(name); if (is_nx_class(group, "NXbeam")) { result.beam.push_back(serialize::load(group)); } } break; case H5G_DATASET: { H5::DataSet dset = handle.openDataSet(name); if (name == "name") { result.name = serialize::load(dset); } else if (name == "chemical_formula") { result.chemical_formula = serialize::load(dset); } else if (name == "temperature") { result.temperature = serialize::load(dset); } else if (name == "unit_cell_class") { result.unit_cell_class = serialize< af::shared >::load(dset); } else if (name == "unit_cell_group") { result.unit_cell_group = serialize< af::shared >::load(dset); } else if (name == "sample_orientation") { result.sample_orientation = serialize< vec3 >::load(dset); } else if (name == "orientation_matrix") { result.orientation_matrix = serialize > >::load(dset); } else if (name == "unit_cell") { result.unit_cell = serialize > >::load(dset); } } break; default: break; }; } // Return the NXsample object return result; } template static void dump(const NXsample &obj, Handle &handle) { } }; }} // namespace dials::nexus #endif // DIALS_NEXUS_NXSAMPLE_H