]> www.ginac.de Git - ginac.git/blobdiff - ginac/numeric.h
Added callback mechanism to watch changes to 'Digits' (to be used for look-up tables)
[ginac.git] / ginac / numeric.h
index 188883159942e3fde1e96c9d6f8f9d9d7b08677f..f2a1adbdc52d8cc070a15c8ad4460fa151d6db3e 100644 (file)
@@ -27,6 +27,7 @@
 #include "ex.h"
 
 #include <stdexcept>
+#include <vector>
 
 #include <cln/complex.h>
 
 
 namespace GiNaC {
 
+/** Function pointer to implement callbacks in the case 'Digits' gets changed.
+ *  Main purpose of such callbacks is to adjust look-up tables of certain
+ *  functions to the new precision. Parameter contains the signed difference
+ *  between new Digits and old Digits. */
+typedef void (* digits_changed_callback)(long);
+
 /** This class is used to instantiate a global singleton object Digits
  *  which behaves just like Maple's Digits.  We need an object rather 
  *  than a dumber basic type since as a side-effect we let it change
@@ -55,11 +62,14 @@ public:
        _numeric_digits();
        _numeric_digits& operator=(long prec);
        operator long();
-       void print(std::ostream &os) const;
+       void print(std::ostream& os) const;
+       void add_callback(digits_changed_callback callback);
 // member variables
 private:
        long digits;                        ///< Number of decimal digits
        static bool too_late;               ///< Already one object present
+       // Holds a list of functions that get called when digits is changed.
+       std::vector<digits_changed_callback> callbacklist;
 };