1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-10 11:26:56 +01:00

Adding factories

This commit is contained in:
Guido Cossu
2017-01-16 10:18:09 +00:00
parent 0dfda4bb90
commit c6f59c2933
15 changed files with 583 additions and 171 deletions

View File

@ -69,6 +69,9 @@ namespace Grid {
class Serializable {};
// static polymorphism implemented using CRTP idiom
// Static abstract writer
@ -121,11 +124,19 @@ namespace Grid {
private:
T *upcast;
};
// type traits
// What is the vtype
template<typename T> struct isReader {
static const bool value = false;
};
template<typename T> struct isWriter {
static const bool value = false;
};
// Generic writer interface
template <typename T>
inline void push(Writer<T> &w, const std::string &s)
{
inline void push(Writer<T> &w, const std::string &s) {
w.push(s);
}

View File

@ -79,6 +79,18 @@ namespace Grid
std::string fileName_;
};
template <>
struct isReader< XmlReader > {
static const bool value = true;
};
template <>
struct isWriter<XmlWriter > {
static const bool value = true;
};
// Writer template implementation ////////////////////////////////////////////
template <typename U>
void XmlWriter::writeDefault(const std::string &s, const U &x)