]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.h
registered_class_info: use typeid() instead of tinfo_static.
[ginac.git] / ginac / structure.h
index 23ae9c29bc43c911d09070f9712ad631b7d0c1a3..6c08618c7c4a7752e4033b0db2dbe65213ec3456 100644 (file)
@@ -3,7 +3,7 @@
  *  Wrapper template for making GiNaC classes out of C++ structures. */
 
 /*
- *  GiNaC Copyright (C) 1999-2005 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
@@ -33,8 +33,6 @@
 
 namespace GiNaC {
 
-extern unsigned next_structure_tinfo_key;
-
 
 /** Comparison policy: all structures of one type are equal */
 template <class T>
@@ -119,7 +117,7 @@ class structure : public basic, public ComparisonPolicy<T> {
        GINAC_DECLARE_REGISTERED_CLASS(structure, basic)
 
        // helpers
-       static unsigned get_tinfo() { return reg_info.options.get_id(); }
+       static tinfo_t get_tinfo() { return reg_info.options.get_id(); }
        static const char *get_class_name() { return "structure"; }
 
        // constructors
@@ -156,8 +154,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:
@@ -201,7 +199,13 @@ public:
 
        // 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
@@ -220,7 +224,6 @@ public:
        const T *operator->() const { return &obj; }
        T &get_struct() { return obj; }
        const T &get_struct() const { return obj; }
-
 private:
        T obj;
 };
@@ -259,7 +262,7 @@ int structure<T, CP>::compare_same_type(const basic & other) const
 }
 
 template <class T, template <class> class CP>
-registered_class_info structure<T, CP>::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", next_structure_tinfo_key++, &structure::unarchive));
+registered_class_info structure<T, CP>::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", typeid(structure<T, CP>), &structure::unarchive));
 
 
 } // namespace GiNaC