X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floaderaction.h;h=82fd3b437902a3494167ae295c7f065184424a5b;hb=b39ce68f12c30eedb272b65fe78baec5864d89ca;hp=22fb82ad13691209b484383fa421c48fd188b024;hpb=7df5e45c7f414f6a07681dc4ec2abb63b091a309;p=libs%2Fdatafile.git diff --git a/source/loaderaction.h b/source/loaderaction.h index 22fb82a..82fd3b4 100644 --- a/source/loaderaction.h +++ b/source/loaderaction.h @@ -1,7 +1,7 @@ #ifndef MSP_DATAFILE_LOADERACTION_H_ #define MSP_DATAFILE_LOADERACTION_H_ -#include "except.h" +#include "argumentstore.h" #include "statement.h" namespace Msp { @@ -22,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; }; @@ -45,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(); } }; @@ -69,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); } }; @@ -97,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; @@ -126,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 "*"; } }; @@ -147,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; @@ -173,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; @@ -200,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; @@ -228,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; @@ -257,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); } }; @@ -276,9 +328,13 @@ public: virtual void execute(Loader &l, const Statement &st) const { typename L::Loader &ldr = dynamic_cast(l); - if(!ldr.is_pointer_reload_allowed() && ldr.get_object().*ptr0) - throw InvalidState("The pointer has already been loaded"); - ldr.get_object().*ptr0 = ldr.get_collection().template get(st.args[0].get()); + 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 @@ -305,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;