* Please do not modify it directly, edit the perl script instead!
* function.pl options: \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
and user defined functions */
class function : public exprseq
{
+ GINAC_DECLARE_REGISTERED_CLASS(function, exprseq)
+
// CINT has a linking problem
friend void ginsh_get_ginac_functions(void);
* Please do not modify it directly, edit the perl script instead!
* function.pl options: \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "function.h"
#include "ex.h"
+#include "archive.h"
#include "utils.h"
#include "debugmsg.h"
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
tinfo_key = TINFO_function;
}
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+ debugmsg("function constructor from archive_node", LOGLEVEL_CONSTRUCT);
+
+ // Find serial number by function name
+ string s;
+ if (n.find_string("name", s)) {
+ unsigned int ser = 0;
+ vector<registered_function_info>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
+ while (i != iend) {
+ if (s == i->name) {
+ serial = ser;
+ return;
+ }
+ i++; ser++;
+ }
+ throw (std::runtime_error("unknown function '" + s + "' in archive"));
+ } else
+ throw (std::runtime_error("unnamed function in archive"));
+}
+
+/** Unarchive the object. */
+ex function::unarchive(const archive_node &n, const lst &sym_lst)
+{
+ return (new function(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void function::archive(archive_node &n) const
+{
+ inherited::archive(n);
+ GINAC_ASSERT(serial < registered_functions().size());
+ n.add_string("name", registered_functions()[serial].name);
+}
+
//////////
// functions overriding virtual functions from bases classes
//////////
<< ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
<< ", flags=" << flags
<< ", nops=" << nops() << endl;
- for (int i=0; i<nops(); ++i) {
+ for (unsigned i=0; i<nops(); ++i) {
seq[i].printtree(os,indent+delta_indent);
}
os << string(indent+delta_indent,' ') << "=====" << endl;