X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fstructure.h;h=83c49b03c64ecd9c222da0e6a5ca523c4fb8fcd1;hp=26dff67beefd88ed12e38ba4a03b25f4e2b212e2;hb=cb390522ea713a08a43799fbc1884fb7ad480784;hpb=7d870583a6bf21a2ffb7b6f051b702064623892e diff --git a/ginac/structure.h b/ginac/structure.h index 26dff67b..83c49b03 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-2008 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2010 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 @@ -20,10 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __GINAC_STRUCTURE_H__ -#define __GINAC_STRUCTURE_H__ - -#include +#ifndef GINAC_STRUCTURE_H +#define GINAC_STRUCTURE_H #include "ex.h" #include "ncmul.h" @@ -31,8 +29,9 @@ #include "operators.h" #include "print.h" -namespace GiNaC { +#include +namespace GiNaC { /** Comparison policy: all structures of one type are equal */ template @@ -117,14 +116,11 @@ class structure : public basic, public ComparisonPolicy { GINAC_DECLARE_REGISTERED_CLASS(structure, basic) // helpers - static tinfo_t get_tinfo() { return reg_info.options.get_id(); } static const char *get_class_name() { return "structure"; } - static tinfo_t next_structure_tinfo_key() { return new tinfo_static_t; } - // 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 @@ -156,7 +152,7 @@ public: // pattern matching bool has(const ex & other, unsigned options = 0) const { return inherited::has(other, options); } - bool match(const ex & pattern, lst & repl_lst) const { return inherited::match(pattern, repl_lst); } + 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: @@ -200,7 +196,13 @@ public: // noncommutativity unsigned return_type() const { return return_types::commutative; } - tinfo_t return_type_tinfo() const { return this; } + 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 @@ -226,25 +228,7 @@ private: /** Default constructor */ template class CP> -structure::structure() : inherited(get_tinfo()) { } - -/** Construct object from archive_node. */ -template class CP> -structure::structure(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) {} - -/** Unarchive the object. */ -template class CP> -ex structure::unarchive(const archive_node &n, lst &sym_lst) -{ - return (new structure(n, sym_lst))->setflag(status_flags::dynallocated); -} - -/** Archive the object. */ -template class CP> -void structure::archive(archive_node &n) const -{ - inherited::archive(n); -} +structure::structure() { } /** Compare two structures of the same type. */ template class CP> @@ -257,9 +241,8 @@ 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", structure::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))); } // namespace GiNaC -#endif // ndef __GINAC_STRUCTURE_H__ +#endif // ndef GINAC_STRUCTURE_H