JEMRIS  2.8.1
open-source MRI simulations
BinaryContext.h
Go to the documentation of this file.
1 
5 /*
6  * JEMRIS Copyright (C)
7  * 2006-2015 Tony Stoecker
8  * 2007-2015 Kaveh Vahedipour
9  * 2009-2015 Daniel Pflugfelder
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  */
25 
26 #ifndef BINARY_CONTEXT_H_
27 #define BINARY_CONTEXT_H_
28 
29 #include "Declarations.h"
30 
31 #include "BinaryIO.h"
32 #include "SimpleIO.h"
33 #include "HDF5IO.h"
34 
35 #include <vector>
36 #include <typeinfo>
37 
38 //const std::type_info& hdf5_t = typeid(&HDF5IO);
39 //const std::type_info& simple_t = typeid(&SimpleIO);
40 
42 
43 public:
44 
48  BinaryContext (const std::string& fname, IO::Mode mode);
49  virtual ~BinaryContext ();
50 
57  template<class T> IO::Status
58  Write (const NDData<T>& data, const std::string& urn, const std::string& url = "") {
59  if (m_strategy->IOStrategy() == IO::HDF5)
60  return ((HDF5IO*)m_strategy)->Write(data, urn, url);
61  else if (m_strategy->IOStrategy() == IO::SIMPLE)
62  return ((SimpleIO*)m_strategy)->Write(data, urn, url);
63  return IO::FILE_NOT_FOUND;
64  }
65 
66  template<class T> IO::Status
67  Write (const NDData<T>& data, const char* urn, const char* url = "") {
68  return Write(data, std::string(urn), std::string(url));
69  }
70 
71 
72  template<class T> IO::Status
73  Read (NDData<T>& data, const std::string& urn, const std::string& url = "") {
74  if (m_strategy->IOStrategy() == IO::HDF5)
75  return ((HDF5IO*)m_strategy)->Read(data, urn, url);
76  else if (m_strategy->IOStrategy() == IO::SIMPLE)
77  return ((SimpleIO*)m_strategy)->Read(data, urn, url);
78  return IO::FILE_NOT_FOUND;
79  }
80  template<class T> IO::Status
81  Read (NDData<T>& data, const char* urn, const char* url = "") {
82  return Read (data, std::string(urn), std::string(url));
83  }
90  Status () const;
91 
92 
93 
94 private:
95 
96  std::vector<BinaryIO*> m_strategies;
100 };
101 
102 #endif // BINARY_CONTEXT_H
Implementation of JEMRIS Declarations.
IO::Status m_status
Definition: BinaryContext.h:98
BinaryContext(const std::string &fname, IO::Mode mode)
Construct populating strategies.
Definition: BinaryContext.cpp:3
IO::Status Status() const
Get last status.
Definition: BinaryContext.cpp:12
HDF5 IO interface.
Definition: HDF5IO.h:68
BinaryIO * m_strategy
Definition: BinaryContext.h:97
Mode
Definition: Declarations.h:176
Implementation of binary I/O.
std::vector< BinaryIO * > m_strategies
Definition: BinaryContext.h:96
mode
Definition: Declarations.h:112
Implementation of JEMRIS Sample.
IO::Status Write(const NDData< T > &data, const std::string &urn, const std::string &url="")
Write data from container to file.
Definition: BinaryContext.h:58
Base class for binary IO strategies.
Definition: BinaryIO.h:51
Implementation of JEMRIS Sample.
Simple nd-data structure.
Definition: NDData.h:53
Definition: SimpleIO.h:31
Status
Definition: Declarations.h:148
Definition: BinaryContext.h:41

-- last change 17.06.2016 | Tony Stoecker | Imprint --