Commit 256a69ca4c02888cb324c61a9ca4d9ea676f66d6

Authored by Josh Klontz
1 parent e3a2aca7

make it easier to read/write through Format interface

openbr/openbr_plugin.cpp
@@ -1255,6 +1255,17 @@ void MatrixOutput::set(float value, int i, int j) @@ -1255,6 +1255,17 @@ void MatrixOutput::set(float value, int i, int j)
1255 1255
1256 BR_REGISTER(Output, MatrixOutput) 1256 BR_REGISTER(Output, MatrixOutput)
1257 1257
  1258 +/* Format - public methods */
  1259 +Template Format::read(const QString &file)
  1260 +{
  1261 + return QScopedPointer<Format>(Factory<Format>::make(file))->read();
  1262 +}
  1263 +
  1264 +void Format::write(const QString &file, const Template &t)
  1265 +{
  1266 + QScopedPointer<Format>(Factory<Format>::make(file))->write(t);
  1267 +}
  1268 +
1258 /* Gallery - public methods */ 1269 /* Gallery - public methods */
1259 TemplateList Gallery::read() 1270 TemplateList Gallery::read()
1260 { 1271 {
openbr/openbr_plugin.h
@@ -1080,6 +1080,8 @@ public: @@ -1080,6 +1080,8 @@ public:
1080 virtual ~Format() {} 1080 virtual ~Format() {}
1081 virtual Template read() const = 0; /*!< \brief Returns a br::Template created by reading #br::Object::file. */ 1081 virtual Template read() const = 0; /*!< \brief Returns a br::Template created by reading #br::Object::file. */
1082 virtual void write(const Template &t) const = 0; /*!< \brief Writes the br::Template to #br::Object::file. */ 1082 virtual void write(const Template &t) const = 0; /*!< \brief Writes the br::Template to #br::Object::file. */
  1083 + static Template read(const QString &file);
  1084 + static void write(const QString &file, const Template &t);
1083 }; 1085 };
1084 1086
1085 /*! 1087 /*!
openbr/plugins/format.cpp
@@ -293,7 +293,11 @@ class mtxFormat : public Format @@ -293,7 +293,11 @@ class mtxFormat : public Format
293 293
294 Template read() const 294 Template read() const
295 { 295 {
296 - return BEE::readMatrix(file); 296 + QString target, query;
  297 + Template result = BEE::readMatrix(file, &target, &query);
  298 + result.file.set("Target", target);
  299 + result.file.set("Query", query);
  300 + return result;
297 } 301 }
298 302
299 void write(const Template &t) const 303 void write(const Template &t) const