X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fstructure.h;h=3987d8068577aaf7c75d59c6f3c2ea2f622df09d;hp=469acdecd998eb38c51c84c79576cf76e6789785;hb=8fdf123fe6dac43ad7b8020d7bb7446c51cf75e7;hpb=6d225ee55693c0617d254e6fa283c00c71bd2919 diff --git a/ginac/structure.h b/ginac/structure.h index 469acdec..3987d806 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -3,7 +3,7 @@ * Wrapper template for making GiNaC classes out of C++ structures. */ /* - * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 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 @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GINAC_STRUCTURE_H__ @@ -27,13 +27,12 @@ #include "ex.h" #include "ncmul.h" +#include "numeric.h" #include "operators.h" #include "print.h" namespace GiNaC { -extern unsigned next_structure_tinfo_key; - /** Comparison policy: all structures of one type are equal */ template @@ -118,13 +117,12 @@ class structure : public basic, public ComparisonPolicy { GINAC_DECLARE_REGISTERED_CLASS(structure, basic) // helpers - static unsigned get_tinfo() { return reg_info.options.get_id(); } static const char *get_class_name() { return "structure"; } // constructors public: /** Construct structure as a copy of a given C++ structure. */ - structure(const T & t) : inherited(get_tinfo()), obj(t) { } + structure(const T & t) : obj(t) { } // functions overriding virtual functions from base classes // All these are just defaults that can be specialized by the user @@ -155,8 +153,8 @@ public: ex & operator[](size_t i) { return inherited::operator[](i); } // pattern matching - bool has(const ex & other) const { return inherited::has(other); } - bool match(const ex & pattern, lst & repl_lst) const { return inherited::match(pattern, repl_lst); } + bool has(const ex & other, unsigned options = 0) const { return inherited::has(other, options); } + bool match(const ex & pattern, exmap& repl_lst) const { return inherited::match(pattern, repl_lst); } protected: bool match_same_type(const basic & other) const { return true; } public: @@ -195,12 +193,18 @@ public: // indexed objects exvector get_free_indices() const { return exvector(); } ex add_indexed(const ex & self, const ex & other) const { return self + other; } - ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * other; } + ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * ex(other); } bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { return false; } // noncommutativity unsigned return_type() const { return return_types::commutative; } - unsigned return_type_tinfo() const { return tinfo(); } + return_type_t return_type_tinfo() const + { + return_type_t r; + r.rl = 0; + r.tinfo = &typeid(*this); + return r; + } protected: bool is_equal_same_type(const basic & other) const @@ -219,7 +223,6 @@ public: const T *operator->() const { return &obj; } T &get_struct() { return obj; } const T &get_struct() const { return obj; } - private: T obj; }; @@ -227,7 +230,7 @@ private: /** Default constructor */ template class CP> -structure::structure() : inherited(get_tinfo()) { } +structure::structure() { } /** Construct object from archive_node. */ template class CP> @@ -258,7 +261,7 @@ int structure::compare_same_type(const basic & other) const } template class CP> -registered_class_info structure::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", next_structure_tinfo_key++, &structure::unarchive)); +registered_class_info structure::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", typeid(structure), &structure::unarchive)); } // namespace GiNaC