mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-10 11:26:56 +01:00
Adding factories
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user