IMP logo
IMP Reference Guide  2.20.1
The Integrative Modeling Platform
EMReaderWriter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/EMReaderWriter.h
3  * \brief Classes to read or write density files in EM format.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_EM_READER_WRITER_H
10 #define IMPEM_EM_READER_WRITER_H
11 
12 #include <IMP/em/em_config.h>
13 #include "MapReaderWriter.h"
14 #include "DensityHeader.h"
15 #include "internal/EMHeader.h"
16 #include "def.h"
17 
18 IMPEM_BEGIN_NAMESPACE
19 /** Reader/writer for EM. */
20 class IMPEMEXPORT EMReaderWriter : public MapReaderWriter {
21  public:
22 #if !defined(DOXYGEN) && !defined(SWIG)
23  //! Reads a density file in EM format and stores the information
24  /**
25  \param[in] filename name of the file to read
26  \param[in] data pointer to the data
27  \param[in] header DensityHeader() to store the header information
28  \exception IOException in case that the filename was not found
29  */
30  void read(const char *filename, float **data,
31  DensityHeader &header) override;
32 
33  //! Writes a density file in EM format with the header information
34  /**
35  \param[in] filename name of the file to read
36  \param[in] data pointer to the data
37  \param[in] header DensityHeader() with the header information
38  */
39  void write(const char *filename, const float *data,
40  const DensityHeader &header) override;
41 #endif
42  protected:
43  //! Reads the header
44  //! Reads the data
45  /**
46  \param file ifstream of the file to read
47  \param header internal::EMHeader to store the header information
48  */
49  void read_header(std::ifstream &file, internal::EMHeader &header);
50  //! Reads the data
51  /**
52  \param file ifstream of the file to read
53  \param data pointer to store the data
54  \param header internal::EMHeader to store the header information
55  \exception IOException if the data allocation had failed
56  \exception IOException is the requested data type is not implemented
57  */
58  void read_data(std::ifstream &file, float **data,
59  const internal::EMHeader &header);
60  //! Writes the header
61  /**
62  \param[in] s
63  \param[in] header internal::EMHeader with the header information
64  \exception IOException if the writing operation had failed.
65  */
66  void write_header(std::ostream &s, const internal::EMHeader &header);
67 
69 };
70 
71 IMPEM_END_NAMESPACE
72 
73 #endif /* IMPEM_EM_READER_WRITER_H */
The base class to handle reading and writing of density maps.
Definitions for EMBED.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Metadata for a density file.
An abstract class for reading a map.