]> www.ginac.de Git - ginac.git/blobdiff - ginac/constant.h
- use initializers in exception class pole_error.
[ginac.git] / ginac / constant.h
index d56f2bc861389e3e29ae236bd24f209350b29d6a..bdd8d69e79d16b3a5e1612a167341d19b6786627 100644 (file)
@@ -43,15 +43,12 @@ class constant : public basic
        
        // other ctors
 public:
-       constant(const std::string & initname, evalffunctype efun = 0);
-       constant(const std::string & initname, const numeric & initnumber);
+       constant(const std::string & initname, evalffunctype efun = 0, const std::string & texname = std::string());
+       constant(const std::string & initname, const numeric & initnumber, const std::string & texname = std::string());
        
-       // functions overriding virtual functions from bases classes
+       // functions overriding virtual functions from base classes
 public:
-       void print(std::ostream & os, unsigned upper_precedence = 0) const;
-       void printraw(std::ostream & os) const;
-       void printtree(std::ostream & os, unsigned indent) const;
-       void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const;
+       void print(const print_context & c, unsigned level = 0) const;
        int degree(const ex & s) const;
        int ldegree(const ex & s) const;
        ex coeff(const ex & s, int n = 1) const;
@@ -70,10 +67,11 @@ protected:
 // member variables
        
 private:
-       std::string name;   ///< printname of this constant
+       std::string name;     ///< printname of this constant
+       std::string TeX_name; ///< LaTeX name
        evalffunctype ef;
-       numeric *number;    ///< numerical value this constant evalf()s to
-       unsigned serial;    ///< unique serial number for comparison
+       numeric *number;      ///< numerical value this constant evalf()s to
+       unsigned serial;      ///< unique serial number for comparison
        static unsigned next_serial;
 };
 
@@ -82,11 +80,20 @@ extern const constant Catalan;
 extern const constant Euler;
 
 // utility functions
+
+/** Return the constant object handled by an ex.  Deprecated: use ex_to<constant>().
+ *  This is unsafe: you need to check the type first. */
 inline const constant &ex_to_constant(const ex &e)
 {
        return static_cast<const constant &>(*e.bp);
 }
 
+/** Specialization of is_exactly_a<constant>(obj) for constant objects. */
+template<> inline bool is_exactly_a<constant>(const basic & obj)
+{
+       return obj.tinfo()==TINFO_constant;
+}
+
 } // namespace GiNaC
 
 #endif // ndef __GINAC_CONSTANT_H__