OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
map_io_mrc_handler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 #ifndef OST_IO_MAP_IO_MRC_HANDLER_HH
21 #define OST_IO_MAP_IO_MRC_HANDLER_HH
22 
23 #include "map_io_handler.hh"
24 
25 namespace ost { namespace io {
26 
27 class DLLEXPORT_OST_IO MRC: public ImageFormatBase
28 {
29  public:
30 
31  MRC(bool normalize_on_save = false, Subformat subformat = MRC_AUTO_FORMAT ,Endianess endianness_on_save = OST_LOCAL_ENDIAN, Format bit_depth = OST_DEFAULT_FORMAT);
32 
33  Format GetBitDepth() const;
34  void SetBitDepth ( Format bitdepth);
35 
36  Endianess GetEndianessOnSave() const;
37  void SetEndianessOnSave(Endianess end);
38 
39  bool GetNormalizeOnSave() const;
40  void SetNormalizeOnSave(bool normalize_on_save);
41 
42  Subformat GetSubformat() const;
43  void SetSubformat(Subformat subformat);
44 
45  static String FORMAT_STRING;
46 
47  private:
48 
49  Subformat subformat_;
50  bool normalize_on_save_;
51  Endianess endianess_on_save_;
52  Format bit_depth_;
53 };
54 
55 class DLLEXPORT_OST_IO CCP4: public MRC
56 {
57  public:
58  CCP4(bool normalize_on_save = false, Endianess endianness_on_save = OST_LOCAL_ENDIAN, Format bit_depth = OST_DEFAULT_FORMAT);
59 };
60 
61 typedef CCP4 MAP;
62 
63 class MapIOMrcHandler: public MapIOHandler {
64 public:
65 
67  is_file_(false),
68  filename_("") {}
69 
74  virtual void Import(img::MapHandle& sh, const boost::filesystem::path& loc,const ImageFormatBase& formatstruct );
75  virtual void Import(img::MapHandle& sh, std::istream& loc, const ImageFormatBase& formatstruct);
76  virtual void Export(const img::MapHandle& sh, const boost::filesystem::path& loc, const ImageFormatBase& formatstruct) const;
77  virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const;
78  static bool MatchContent(unsigned char* header);
79  static bool MatchType(const ImageFormatBase& type);
80  static bool MatchSuffix(const String& loc);
81  static bool ProvidesImport() { return true; }
82  static bool ProvidesExport() { return true; }
83  static String GetFormatName() { return String("Mrc"); };
84  static String GetFormatDescription() { return String("Format used by the MRC software package"); };
85 
86 private:
87 
88  mutable bool is_file_;
89  mutable String filename_;
90  char header_[256];
91 
92 };
93 
94 typedef MapIOHandlerFactory<MapIOMrcHandler> MapIOMrcHandlerFactory;
95 
96 }}
97 
98 
99 #endif
static bool MatchSuffix(const String &loc)
std::string String
Definition: base.hh:54
pointer_it< T > end(const std::vector< T > &values)
static bool MatchContent(unsigned char *header)
Endianess
Definition: convert.hh:44
virtual void Import(img::MapHandle &sh, const boost::filesystem::path &loc, const ImageFormatBase &formatstruct)
Map IO handler to read/write mrc and ccp4 map files.
#define DLLEXPORT_OST_IO
MapIOHandlerFactory< MapIOMrcHandler > MapIOMrcHandlerFactory
Manage shared instances of images.
static bool MatchType(const ImageFormatBase &type)
virtual void Export(const img::MapHandle &sh, const boost::filesystem::path &loc, const ImageFormatBase &formatstruct) const
static String GetFormatDescription()