]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
- triggered.
[ginac.git] / ginac / function.pl
index bb6c974f6f83ee6b6634cec5b5c14f28d0962a16..16936d5a17eda54969eafc60645b158c539fec66 100755 (executable)
@@ -439,7 +439,9 @@ class function : public exprseq
     GINAC_DECLARE_REGISTERED_CLASS(function, exprseq)
 
     // CINT has a linking problem
+#ifndef __MAKECINT__
     friend void ginsh_get_ginac_functions(void);
+#endif // def __MAKECINT__
 
     friend class remember_table_entry;
     // friend class remember_table_list;
@@ -498,6 +500,7 @@ protected:
     void store_remember_table(ex const & result) const;
 public:
     static unsigned register_new(function_options const & opt);
+    static unsigned find_function(const string &name, unsigned nparams);
     unsigned getserial(void) const {return serial;}
     
 // member variables
@@ -1114,6 +1117,21 @@ unsigned function::register_new(function_options const & opt)
     return registered_functions().size()-1;
 }
 
+/** Find serial number of function by name and number of parameters.
+ *  Throws exception if function was not found. */
+unsigned function::find_function(const string &name, unsigned nparams)
+{
+    vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
+    unsigned serial = 0;
+    while (i != end) {
+        if (i->get_name() == name && i->get_nparams() == nparams)
+            return serial;
+        i++;
+        serial++;
+    }
+    throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined"));
+}
+
 //////////
 // static member variables
 //////////