https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Separate interface from implementation.
* oln/core/gen/zero.hh,
* oln/io/save_pgm.hh,
* oln/io/load_pgm.hh,
* oln/io/pnm.hh: Separte interface from implementation.
core/gen/zero.hh | 16 ++++++++++++----
io/load_pgm.hh | 32 +++++++++++++++++++++++++++++++-
io/pnm.hh | 37 ++++++++++++++++++++++++++++++++++++-
io/save_pgm.hh | 5 +++++
4 files changed, 84 insertions(+), 6 deletions(-)
Index: oln/core/gen/zero.hh
--- oln/core/gen/zero.hh (revision 1007)
+++ oln/core/gen/zero.hh (working copy)
@@ -36,18 +36,26 @@
struct zero_t;
+ // Forward declartions
+ void assignment_(int& i, const zero_t&);
+ void assignment_(unsigned& u, const zero_t&);
+ void assignment_(float& f, const zero_t&);
+ void assignment_(double& d, const zero_t&);
+ struct zero_t : public Literal< zero_t >
+ {
+ };
+
+#ifndef OLN_INCLUDE_ONLY
void assignment_(int& i, const zero_t&) { i = 0; }
void assignment_(unsigned& u, const zero_t&) { u = 0u; }
void assignment_(float& f, const zero_t&) { f = 0.f; }
void assignment_(double& d, const zero_t&) { d = 0.; }
- struct zero_t : public Literal< zero_t >
- {
- }
+ struct zero_t zero;
+#endif // ! OLN_INCLUDE_ONLY
- zero;
Index: oln/io/save_pgm.hh
--- oln/io/save_pgm.hh (revision 1007)
+++ oln/io/save_pgm.hh (working copy)
@@ -40,6 +40,9 @@
namespace io
{
+ void save_pgm(const image2d<unsigned char>& ima, const std::string&
filename);
+
+#ifndef OLN_INCLUDE_ONLY
void save_pgm(const image2d<unsigned char>& ima, const std::string&
filename)
{
@@ -60,6 +63,8 @@
file.write((char*)(&(ima.at(row, col))), len);
}
+#endif // !OLN_INCLUDE_ONLY
+
} // end of namespace oln::io
} // end of namespace oln
Index: oln/io/load_pgm.hh
--- oln/io/load_pgm.hh (revision 1007)
+++ oln/io/load_pgm.hh (working copy)
@@ -42,6 +42,28 @@
namespace internal {
+ // Forward declaration
+ void abort();
+
+ bool read_pnm_header(std::istream& istr,
+ char& type,
+ int& nrows, int& ncols,
+ bool test = false);
+
+ void read_pnm_header(char ascii, char raw,
+ std::istream& istr,
+ char& type,
+ int& nrows, int& ncols);
+
+ template <typename I>
+ void load_pgm_ascii(std::ifstream& file, I& ima);
+
+ template <typename I>
+ void load_pgm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
void abort()
{
std::cerr << " aborting." << std::endl;
@@ -51,7 +73,7 @@
bool read_pnm_header(std::istream& istr,
char& type,
int& nrows, int& ncols,
- bool test = false)
+ bool test)
{
// check magic
if (istr.get() != 'P' )
@@ -136,10 +158,16 @@
file.read((char*)(&(ima.at(row, col))), len);
}
+#endif // ! OLN_INCLUDE_ONLY
+
} // end of namespace oln::io::internal
+ image2d<unsigned char> load_pgm(const std::string& filename);
+
+#ifndef OLN_INCLUDE_ONLY
+
image2d<unsigned char> load_pgm(const std::string& filename)
{
std::ifstream file(filename.c_str());
@@ -161,6 +189,8 @@
return ima;
}
+#endif // ! OLN_INCLUDE_ONLY
+
} // end of namespace oln::io
} // end of namespace oln
Index: oln/io/pnm.hh
--- oln/io/pnm.hh (revision 1007)
+++ oln/io/pnm.hh (working copy)
@@ -43,6 +43,31 @@
namespace internal {
+ // forward declaration
+ void abort();
+
+ bool read_pnm_header(std::istream& istr,
+ char& type,
+ int& nrows, int& ncols,
+ bool test = false);
+
+ void read_pnm_header(char ascii, char raw,
+ std::istream& istr,
+ char& type,
+ int& nrows, int& ncols);
+
+ template <typename I>
+ void load_pbm_raw(std::ifstream& file, I& ima);
+
+ template <typename I>
+ void load_pbm_ascii(std::ifstream& file, I& ima);
+
+ template <typename I>
+ void load_pnm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
void abort()
{
std::cerr << " aborting." << std::endl;
@@ -52,7 +77,7 @@
bool read_pnm_header(std::istream& istr,
char& type,
int& nrows, int& ncols,
- bool test = false)
+ bool test)
{
// check magic
if (istr.get() != 'P' )
@@ -170,10 +195,18 @@
len * sizeof(oln_value(I)));
}
+#endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::io::internal
+ // Forward declaration
+ image2d<unsigned char> load_pgm(const std::string& filename);
+ image2d<bool> load_pbm(const std::string& filename);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
image2d<bool> load_pbm(const std::string& filename)
{
std::ifstream file(filename.c_str());
@@ -217,6 +250,8 @@
return ima;
}
+#endif // ! OLN_INCLUDE_ONLY
+
} // end of namespace oln::io
} // end of namespace oln