]> www.ginac.de Git - ginac.git/blobdiff - ginac/color.cpp
A better return_type_tinfo() mechanism.
[ginac.git] / ginac / color.cpp
index 2c323e253cb81c3e714d6ce7fd3710b85ec5d1e7..437686333b9263998942652a79bcaa56e76cf13b 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's color (SU(3) Lie algebra) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2006 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
@@ -39,8 +39,6 @@ namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
 
-const tinfo_static_t color::return_type_tinfo_static[256] = {{}};
-
 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3one, tensor,
   print_func<print_dflt>(&su3one::do_print).
   print_func<print_latex>(&su3one::do_print_latex))
@@ -101,6 +99,11 @@ color::color(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(not_symme
        tinfo_key = &color::tinfo_static;
 }
 
+return_type_t color::return_type_tinfo() const
+{
+       return make_return_type_t<color>(representation_label);
+}
+
 //////////
 // archiving
 //////////
@@ -524,17 +527,16 @@ ex color_h(const ex & a, const ex & b, const ex & c)
 
 /** Check whether a given tinfo key (as returned by return_type_tinfo()
  *  is that of a color object (with an arbitrary representation label). */
-static bool is_color_tinfo(tinfo_t ti)
+static bool is_color_tinfo(const return_type_t& ti)
 {
-       p_int start_loc=(p_int)&color::return_type_tinfo_static;
-       return (p_int)ti>=start_loc && (p_int)ti<start_loc+256;
+       return *(ti.tinfo) == typeid(color);
 }
 
 /** Extract representation label from tinfo key (as returned by
  *  return_type_tinfo()). */
-static unsigned char get_representation_label(tinfo_t ti)
+static unsigned char get_representation_label(const return_type_t& ti)
 {
-       return (unsigned char)((p_int)ti-(p_int)&color::return_type_tinfo_static);
+       return (unsigned char)ti.rl;
 }
 
 ex color_trace(const ex & e, const std::set<unsigned char> & rls)