X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Floaderaction.h;h=82fd3b437902a3494167ae295c7f065184424a5b;hp=afca01e9ba3b478d95bd320e550f0cf7fbf08fff;hb=3b78eeb8b92dc3524d6a0456b4daf0a0f3dbf813;hpb=a82776d980239e48d2b509d33b56e77a1ea44dda diff --git a/source/loaderaction.h b/source/loaderaction.h index afca01e..82fd3b4 100644 --- a/source/loaderaction.h +++ b/source/loaderaction.h @@ -1,6 +1,7 @@ #ifndef MSP_DATAFILE_LOADERACTION_H_ #define MSP_DATAFILE_LOADERACTION_H_ +#include "argumentstore.h" #include "statement.h" namespace Msp { @@ -21,6 +22,8 @@ public: /** Called to process a statement. */ virtual void execute(Loader &, const Statement &) const = 0; + virtual void execute(Loader &, const ArgumentStore &) const = 0; + virtual std::string get_signature() const = 0; }; @@ -44,6 +47,11 @@ public: (dynamic_cast(l).*func)(); }; + virtual void execute(Loader &l, const ArgumentStore &) const + { + (dynamic_cast(l).*func)(); + }; + virtual std::string get_signature() const { return std::string(); } }; @@ -68,6 +76,11 @@ public: (dynamic_cast(l).*func)(st.args[0].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + (dynamic_cast(l).*func)(as.get(0)); + } + virtual std::string get_signature() const { return std::string(1, TypeInfo::signature); } }; @@ -96,6 +109,16 @@ public: (dynamic_cast(l).*func)(values); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + std::vector values; + unsigned n_args = as.get_info().key.signature.size(); + values.reserve(n_args); + for(unsigned i=0; i(i)); + (dynamic_cast(l).*func)(values); + } + virtual std::string get_signature() const { std::string result; @@ -125,6 +148,11 @@ public: (dynamic_cast(l).*func)(st); } + virtual void execute(Loader &, const ArgumentStore &) const + { + throw std::logic_error("incompatible format"); + } + virtual std::string get_signature() const { return "*"; } }; @@ -146,6 +174,11 @@ public: (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + (dynamic_cast(l).*func)(as.get(0), as.get(1)); + } + virtual std::string get_signature() const { std::string result; @@ -172,6 +205,11 @@ public: (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + (dynamic_cast(l).*func)(as.get(0), as.get(1), as.get(2)); + } + virtual std::string get_signature() const { std::string result; @@ -199,6 +237,11 @@ public: (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + (dynamic_cast(l).*func)(as.get(0), as.get(1), as.get(2), as.get(3)); + } + virtual std::string get_signature() const { std::string result; @@ -227,6 +270,11 @@ public: (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get(), st.args[4].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + (dynamic_cast(l).*func)(as.get(0), as.get(1), as.get(2), as.get(3), as.get(4)); + } + virtual std::string get_signature() const { std::string result; @@ -256,6 +304,11 @@ public: dynamic_cast(l).get_object().*ptr0 = st.args[0].get(); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + dynamic_cast(l).get_object().*ptr0 = as.get(0); + } + virtual std::string get_signature() const { return std::string(1, TypeInfo::signature); } }; @@ -278,6 +331,12 @@ public: ldr.get_object().*ptr0 = &ldr.get_collection().template get(st.args[0].get()); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + typename L::Loader &ldr = dynamic_cast(l); + ldr.get_object().*ptr0 = &ldr.get_collection().template get(as.get(0)); + } + virtual std::string get_signature() const { return std::string(1, TypeInfo::signature); } }; @@ -302,6 +361,12 @@ public: dynamic_cast(l).get_object().*ptr1 = st.args[1].get(); } + virtual void execute(Loader &l, const ArgumentStore &as) const + { + dynamic_cast(l).get_object().*ptr0 = as.get(0); + dynamic_cast(l).get_object().*ptr1 = as.get(1); + } + virtual std::string get_signature() const { std::string result;