]> www.ginac.de Git - ginac.git/blobdiff - ginac/symbol.h
Make symbol::name be initialized lazily.
[ginac.git] / ginac / symbol.h
index bd894c9479dad78eb0a985eb2243ced0dcf73be9..ec371f8c3ed8ad40374b8bfc96b845f5d8a66e12 100644 (file)
@@ -3,7 +3,7 @@
  *  Interface to GiNaC's symbolic objects. */
 
 /*
- *  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
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef __GINAC_SYMBOL_H__
-#define __GINAC_SYMBOL_H__
+#ifndef GINAC_SYMBOL_H
+#define GINAC_SYMBOL_H
 
-#include <string>
-#include <typeinfo>
 #include "basic.h"
 #include "ex.h"
 #include "ptr.h"
+#include "archive.h"
+
+#include <string>
+#include <typeinfo>
 
 namespace GiNaC {
 
@@ -36,7 +38,6 @@ namespace GiNaC {
 class symbol : public basic
 {
        GINAC_DECLARE_REGISTERED_CLASS(symbol, basic)
-
        // other constructors
 public:
        explicit symbol(const std::string & initname);
@@ -56,6 +57,10 @@ public:
        ex real_part() const;
        ex imag_part() const;
        bool is_polynomial(const ex & var) const;
+       /** Save (a.k.a. serialize) object into archive. */
+       void archive(archive_node& n) const;
+       /** Read (a.k.a. deserialize) object from archive. */
+       void read_archive(const archive_node& n, lst& syms);
 protected:
        ex derivative(const symbol & s) const;
        bool is_equal_same_type(const basic & other) const;
@@ -64,7 +69,7 @@ protected:
        // non-virtual functions in this class
 public:
        void set_name(const std::string & n) { name = n; }
-       std::string get_name() const { return name; }
+       std::string get_name() const;
        virtual unsigned get_domain() const { return domain::complex; }
 protected:
        void do_print(const print_context & c, unsigned level) const;
@@ -76,11 +81,12 @@ protected:
 
 protected:
        unsigned serial;                 ///< unique serial number for comparison
-       std::string name;                ///< printname of this symbol
+       mutable std::string name;        ///< printname of this symbol
        std::string TeX_name;            ///< LaTeX name of this symbol
 private:
        static unsigned next_serial;
 };
+GINAC_DECLARE_UNARCHIVER(symbol);
 
 
 /** Specialization of symbol to real domain */
@@ -99,9 +105,10 @@ public:
 
        realsymbol* duplicate() const { return new realsymbol(*this); }
 };
+GINAC_DECLARE_UNARCHIVER(realsymbol);
 
 
-/** Specialization of symbol to real domain */
+/** Specialization of symbol to real positive domain */
 class possymbol : public realsymbol
 {
 public:
@@ -113,7 +120,8 @@ public:
 
        possymbol* duplicate() const { return new possymbol(*this); }
 };
+GINAC_DECLARE_UNARCHIVER(possymbol);
 
 } // namespace GiNaC
 
-#endif // ndef __GINAC_SYMBOL_H__
+#endif // ndef GINAC_SYMBOL_H